/* ============================================================
   SIDEBAR NAVIGATION  -  desktop always-visible, mobile hidden
   ============================================================ */

/* ── Desktop: fixed sidebar, always visible ── */
.sidebar-drawer {
    position: fixed;
    top: 8px;
    left: 0;
    height: calc(100% - 16px);
    width: 260px;
    background: white;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.12);
    border-radius: 0 16px 16px 0;
    z-index: 9100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.no-sidebar {
    padding-left: 0;
}

/* Push page content right of the sidebar */
body {
    padding-left: 280px; /* 260px sidebar + 20px gap */
    transition: padding-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Overlay (mobile only) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9050;
    opacity: 0;
    pointer-events: none;
    /* НЕ используем backdrop-filter: он создаёт GPU-слой даже при opacity:0,
       что на iOS Safari/Chrome перехватывает touch-события через весь экран. */
    transition: opacity 0.3s;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Hide hamburger on desktop */
.sidebar-toggle-btn,
.hamburger-btn {
    display: none !important;
}

/* ── Collapsed state (desktop) ── */
body.sidebar-collapsed .sidebar-drawer {
    width: 64px;
}

body.sidebar-collapsed {
    padding-left: 84px; /* 64px sidebar + 20px gap */
}

body.sidebar-collapsed .sidebar-nav-label,
body.sidebar-collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 12px 8px;
    gap: 0;
}

/* In collapsed mode: hide logo, center the collapse button */
body.sidebar-collapsed .sidebar-logo {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 12px 16px;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
}

/* Suppress ALL transitions during page load to avoid expand→collapse flash */
body.sidebar-no-transition,
body.sidebar-no-transition * {
    transition: none !important;
}

/* Tooltip on collapsed items */
body.sidebar-collapsed .sidebar-nav-item {
    position: relative;
}

body.sidebar-collapsed .sidebar-nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9200;
}

body.sidebar-collapsed .sidebar-nav-item:hover::after {
    opacity: 1;
}

/* ── Sidebar header ── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
    gap: 8px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: justify-content 0.25s;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.3px;
    transition: opacity 0.2s, width 0.25s;
    overflow: hidden;
    white-space: nowrap;
}

/* Collapse toggle button - desktop only */
.sidebar-collapse-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.25s;
    line-height: 1;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Close button - mobile only */
.sidebar-close-btn {
    display: none;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Navigation ── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.18s, color 0.18s, transform 0.15s,
                padding 0.25s, gap 0.25s, justify-content 0.25s;
}

.sidebar-nav-item:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #f5f0ff 100%);
    color: #4f46e5;
    transform: translateX(3px);
}

.sidebar-nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.sidebar-nav-item.active:hover {
    transform: translateX(2px);
    color: white;
}

body.sidebar-collapsed .sidebar-nav-item:hover {
    transform: none;
}

.sidebar-nav-icon {
    font-size: 20px;
    width: 28px;
    flex-shrink: 0;
    text-align: center;
}

.sidebar-nav-label {
    white-space: normal;
    overflow: hidden;
    line-height: 1.25;
    transition: opacity 0.2s, width 0.25s;
}

/* ── Hide back-btn everywhere (replaced by hamburger) ── */
.back-btn {
    display: none !important;
}

/* ── Sidebar notification section (mobile-only bell) ── */

/* Hidden on desktop by default */
.sidebar-notify-section {
    display: none;
    flex-shrink: 0;
    padding: 0 10px 12px;
}

/* ── Mobile: sidebar as slide-in drawer ── */
@media (max-width: 768px) {
    /* Restore natural body padding - sidebar is overlaid, not static */
    body {
        padding-left: 8px !important;
        transition: none;
    }

    /* Sidebar slides in from the left */
    #sidebarDrawer {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: none;
    }

    #sidebarDrawer.open {
        transform: translateX(0);
        box-shadow: 6px 0 40px rgba(0, 0, 0, 0.25);
    }

    /* Overlay управляется через JS (openSidebar/closeSidebar),
       а не через постоянный display:block. Это предотвращает ситуацию,
       когда полноэкранный position:fixed элемент висит в DOM всегда
       и может перехватывать touch-события на iOS. */

    /* Show close button, hide collapse button */
    .sidebar-collapse-btn {
        display: none !important;
    }

    .sidebar-close-btn {
        display: flex !important;
    }

    /* Hamburger button visible on mobile */
    .hamburger-btn {
        display: flex !important;
    }

    /* Show sidebar notification section on mobile */
    .sidebar-notify-section {
        display: block;
    }
}

.sidebar-notify-divider {
    height: 1px;
    background: #e2e8f0;
    margin-bottom: 8px;
}

.sidebar-notify-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
}

.sidebar-notify-btn:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #f5f0ff 100%);
    color: #4f46e5;
}

.sidebar-notify-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Dark theme */
.dark-theme .sidebar-notify-divider { background: #334155; }
.dark-theme .sidebar-notify-btn { color: #cbd5e1; }
.dark-theme .sidebar-notify-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
}
