/* === Variables === */
:root {
    --sidebar-width: 250px;
    --topbar-height: 56px;
    --sidebar-bg: #343a40;
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(255, 255, 255, 0.15);
    --sidebar-active-text: #ffffff;
    --content-bg: #f4f6f9;
}

body {
    background-color: var(--content-bg);
}

/* === Sidebar === */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 1050;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--topbar-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.sidebar-brand {
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.3px;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.4rem;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
}

.sidebar-close-btn:hover {
    color: #ffffff;
}

.sidebar-nav {
    padding: 0.5rem 0;
    flex: 1;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-right: 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-active-text);
}

.sidebar-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 500;
}

.sidebar-sublink {
    padding-left: 2.75rem;
    font-size: 0.83rem;
}

.sidebar-sublink::before {
    content: '›';
    margin-right: 6px;
    opacity: 0.5;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.sidebar-username {
    padding: 0.5rem 1.25rem;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-username-link {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
}

.sidebar-logout {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

/* === Overlay (мобильные) === */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

.sidebar-overlay.active {
    display: block;
}

/* === Topbar (мобильные) === */

.topbar {
    height: var(--topbar-height);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-toggle {
    background: none;
    border: none;
    padding: 5px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-right: 12px;
}

.topbar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: #343a40;
    border-radius: 1px;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #343a40;
    text-decoration: none;
}

.topbar-brand:hover {
    color: #343a40;
}

/* === Main wrapper === */

#main-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .page-content {
        padding: 1rem 0;
    }

    .page-content .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }

    .page-content h1 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .page-content .alert {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .card-body.p-0 {
        overflow-x: auto;
    }

    #order-panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* === Desktop: sidebar always visible === */

@media (min-width: 992px) {
    #main-wrapper {
        margin-left: var(--sidebar-width);
    }
}

/* === Mobile: sidebar hidden by default === */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

/* === Print === */

@media print {
    .no-print {
        display: none !important;
    }

    #main-wrapper {
        margin-left: 0 !important;
    }
}
