:root {
    --sidebar-bg: #131c2b;
    --sidebar-bg-hover: #1f2c42;
    --sidebar-bg-active: #243348;
    --sidebar-fg: #c8d3e0;
    --sidebar-fg-muted: #6b7a90;
    --sidebar-accent: #4a90e2;
    --sidebar-border: #232f44;
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 60px;
    --content-overlay: rgba(10, 16, 28, 0.55);
}

html, body {
    margin: 0;
    padding: 0;
    border: 0;
}

body {
    min-height: 100vh;
    background: #0a101c url(/Images/main_menu_background.jpg) no-repeat center center fixed;
    background-size: cover;
    color: #e6edf5;
    font-family: "Segoe UI", system-ui, -apple-system, Verdana, sans-serif;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--content-overlay);
    z-index: -1;
    pointer-events: none;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease, transform 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 60px;
    gap: 8px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
}

.sidebar-brand:hover,
.sidebar-brand:visited,
.sidebar-brand:active {
    background: transparent;
    color: #fff;
    text-decoration: none;
}

.sidebar-logo {
    height: 32px;
    width: 32px;
    flex-shrink: 0;
    object-fit: contain;
}

.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--sidebar-fg);
    cursor: pointer;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    color: var(--sidebar-fg-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 20px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

.sidebar.collapsed .nav-section-title {
    opacity: 0;
    height: 8px;
    padding: 4px 0 0;
}

.sidebar.collapsed .nav-section {
    border-top: 1px solid var(--sidebar-border);
    margin-top: 8px;
    padding-top: 4px;
}

.sidebar.collapsed .nav-section:first-child {
    border-top: none;
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 17px;
    color: var(--sidebar-fg);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
    border-left: 3px solid transparent;
    overflow: hidden;
}

.nav-item,
.nav-item:link,
.nav-item:visited {
    color: var(--sidebar-fg);
    text-decoration: none;
}

.nav-item i {
    font-size: 18px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    line-height: 1;
}

.nav-item:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-bg-active);
    color: #fff;
    border-left-color: var(--sidebar-accent);
}

.nav-item-label {
    transition: opacity 0.15s ease;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .nav-item-label {
    opacity: 0;
}

.sidebar.collapsed .nav-item {
    padding-left: 17px;
    padding-right: 17px;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 8px 0;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    color: var(--sidebar-fg);
    font-size: 14px;
    overflow: hidden;
}

.user-info i {
    font-size: 22px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.user-name {
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.sidebar.collapsed .user-name {
    opacity: 0;
}

.nav-item.logout {
    color: #e88a8a;
}

.nav-item.logout:hover {
    color: #ffb0b0;
    background: rgba(220, 80, 80, 0.12);
}

/* Main content */
.content {
    flex: 1;
    padding: 24px 28px;
    min-width: 0;
    min-height: 100vh;
    box-sizing: border-box;
}

/* RuStore badge */
.rustore-badge {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 1000;
}

.rustore-badge a:hover {
    background: transparent;
}

.rustore-badge img {
    height: 40px;
    display: block;
}

/* Scrim/backdrop behind mobile drawer */
.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-scrim.visible {
    display: block;
    opacity: 1;
}

/* Floating mobile menu button (phones only) */
.mobile-menu-button {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(19, 28, 43, 0.92);
    color: var(--sidebar-fg);
    border: 1px solid var(--sidebar-border);
    z-index: 180;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-button:hover,
.mobile-menu-button:active {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.mobile-menu-button:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 2px;
}

/* Tablet (601–1024px): icon-rail by default, expands to drawer overlay */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-width-collapsed);
    }
    .sidebar .sidebar-brand-text,
    .sidebar .nav-section-title,
    .sidebar .nav-item-label,
    .sidebar .user-name {
        opacity: 0;
    }
    .sidebar.expanded {
        width: var(--sidebar-width);
        position: fixed;
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }
    .sidebar.expanded .sidebar-brand-text,
    .sidebar.expanded .nav-section-title,
    .sidebar.expanded .nav-item-label,
    .sidebar.expanded .user-name {
        opacity: 1;
    }
    /* Touch-friendly target sizes */
    .nav-item {
        min-height: 44px;
        padding-top: 11px;
        padding-bottom: 11px;
    }
    .sidebar-toggle {
        min-width: 44px;
        min-height: 44px;
        font-size: 22px;
    }
    .user-info {
        min-height: 44px;
    }
}

/* Phone (≤600px): sidebar fully hidden off-screen, floating hamburger reveals drawer */
@media (max-width: 600px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        z-index: 200;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }
    .sidebar.expanded {
        transform: translateX(0);
        width: 280px;
        max-width: 85vw;
        position: fixed;
    }
    /* Full labels always shown in drawer mode */
    .sidebar .sidebar-brand-text,
    .sidebar .nav-section-title,
    .sidebar .nav-item-label,
    .sidebar .user-name {
        opacity: 1;
    }
    .mobile-menu-button {
        display: flex;
    }
    .content {
        padding: 68px 16px 16px;
    }
    .rustore-badge img {
        height: 32px;
    }
}
