/* ============================================================
   layout.css — App shell, sidebar, mobile nav
   Loaded globally via base.html (every page).
   The :root theme variables stay inline in base.html because
   they use Django template variables for theming.
   ============================================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ----------------------------------------------------------
   Desktop Sidebar
   ---------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 1000;
    padding: 1.5rem 1rem;
    transition: all 0.3s ease;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.sidebar-brand {
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    flex-shrink: 0;
}

.sidebar-scroll {
    overflow-y: auto;
    flex: 1;
    margin: 0.5rem 0;
    padding-right: 4px;
}
.sidebar-scroll::-webkit-scrollbar { width: 14px; }
.sidebar-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(250,204,21,0.35); border-radius: 8px; border: 2px solid rgba(250,204,21,0.1); }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: rgba(250,204,21,0.65); }

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-links a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    border-left: none !important;
}
.sidebar-links a:hover {
    color: var(--accent-color);
    background: rgba(250,204,21,0.05);
    transform: translateX(4px);
}
.sidebar-links a.active {
    color: var(--accent-color) !important;
    background: rgba(250,204,21,0.08) !important;
    font-weight: 600;
    border-left: 3px solid var(--accent-color) !important;
    border-radius: 0 8px 8px 0 !important;
    padding-left: 0.6rem !important;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid rgba(255,255,255,0.03);
    padding-top: 1.25rem;
    width: 100%;
    flex-shrink: 0;
    position: relative;
}

.sidebar-nav-notification-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    border-left: none !important;
}
.sidebar-nav-notification-link:hover {
    color: var(--accent-color);
    background: rgba(250,204,21,0.05);
    transform: translateX(4px);
}
.sidebar-nav-notification-link .notification-badge {
    position: static;
    transform: none;
    margin-left: auto;
    flex-shrink: 0;
    width: 18px; height: 18px;
    font-size: 0.7rem;
    background: var(--accent-color);
    color: var(--button-text-color);
    border: none;
    box-shadow: 0 0 8px rgba(250,204,21,0.4);
}

.sidebar-user-widget {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.sidebar-user-widget:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(250,204,21,0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.sidebar-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
    flex-shrink: 0;
    transition: all 0.25s ease;
}
.sidebar-avatar-initials {
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    letter-spacing: 0.04em;
    user-select: none;
}
.sidebar-avatar-default {
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.sidebar-user-link:hover .sidebar-avatar {
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    line-height: 1.3;
}

.sidebar-username {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    transition: color 0.2s ease;
}
.sidebar-user-link:hover .sidebar-username { color: var(--accent-color); }

.sidebar-user-role {
    font-size: 0.72rem;
    color: var(--text-secondary);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.sidebar-bottom .nav-notification-widget { margin-right: 0; }
.sidebar-bottom .notification-dropdown {
    bottom: calc(100% + 12px);
    top: auto; left: 0; right: auto;
    transform: translateY(10px);
}
.sidebar-bottom .notification-dropdown.active { transform: translateY(0); }

.sidebar-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(239,68,68,0.05);
    border: 1px solid rgba(239,68,68,0.15);
    color: #fca5a5;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.sidebar-logout-btn:hover {
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}

.main-layout-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.3s ease;
    width: calc(100% - 260px);
}

/* ----------------------------------------------------------
   Mobile top header
   ---------------------------------------------------------- */
.mobile-user-row { display: none; }

.mobile-top-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.25rem;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
}

.mobile-header-left { display: flex; align-items: center; gap: 0.75rem; }

.menu-toggle-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.menu-toggle-btn:hover {
    background: rgba(250,204,21,0.08);
    color: var(--accent-color);
}

.mobile-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

.mobile-header-right { display: flex; align-items: center; gap: 1rem; }
.mobile-avatar-link { display: flex; align-items: center; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1050;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

.sidebar-close-btn { display: none; }

/* ----------------------------------------------------------
   Responsive: mobile breakpoint
   ---------------------------------------------------------- */
@media (max-width: 991px) {
    .mobile-top-header { display: flex; }
    .sidebar-overlay { display: block; }

    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 1.25rem;
        right: 1.25rem;
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0.35rem;
        border-radius: 6px;
        transition: all 0.2s ease;
        z-index: 1;
    }
    .sidebar-close-btn:hover {
        color: var(--accent-color);
        background: rgba(250,204,21,0.08);
    }

    .app-container { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
        z-index: 1100;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        padding: 1.5rem 1.25rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-top { flex-direction: column; gap: 1.5rem; width: 100%; flex: 1; min-height: 0; }
    .sidebar-brand { display: flex; align-items: center; justify-content: space-between; width: 100%; padding-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
    .sidebar-scroll { overflow-y: auto; flex: 1; margin: 0.5rem 0; padding-right: 4px; }
    .sidebar-links { flex-direction: column; gap: 0.35rem; overflow-x: visible; width: 100%; }
    .sidebar-links a { padding: 0.7rem 0.85rem; font-size: 0.92rem; }
    .sidebar-links a:hover { transform: translateX(4px); }
    .sidebar-links a.active {
        border-left: 3px solid var(--accent-color) !important;
        border-bottom: none !important;
        border-radius: 0 8px 8px 0 !important;
        padding-left: 0.7rem !important;
    }
    .sidebar-bottom { display: flex; flex-direction: column; gap: 1rem; border-top: 1px solid rgba(255,255,255,0.03); padding-top: 1.25rem; width: 100%; }
    .mobile-user-row { display: none; }
    .main-layout-wrapper { margin-left: 0; width: 100%; padding-top: 60px; }
}

/* ----------------------------------------------------------
   Unauthenticated pages (login, etc.)
   ---------------------------------------------------------- */
.unauth-app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.unauth-layout-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}
.unauth-main {
    padding: 2rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
    width: 100%;
}
.unauth-footer { margin-top: auto; padding: 2rem; text-align: center; }

/* ----------------------------------------------------------
   Light theme sidebar adjustments
   ---------------------------------------------------------- */
html[data-theme="light"] .sidebar-brand,
html[data-theme="light"] .sidebar-brand { border-bottom-color: rgba(0,0,0,0.08); }

html[data-theme="light"] .sidebar-bottom { border-top-color: rgba(0,0,0,0.08); }

html[data-theme="light"] .sidebar-nav-notification-link:hover { background: rgba(184,150,12,0.07); }

html[data-theme="light"] .sidebar-user-widget { background: rgba(0,0,0,0.03); }
html[data-theme="light"] .sidebar-user-widget:hover { background: rgba(184,150,12,0.05); box-shadow: 0 4px 20px rgba(0,0,0,0.08); }

html[data-theme="light"] .sidebar-links a:hover { background: rgba(184,150,12,0.07); }
html[data-theme="light"] .sidebar-links a.active { background: rgba(184,150,12,0.1) !important; }

html[data-theme="light"] .sidebar-logout-btn { background: rgba(239,68,68,0.04); color: #dc2626; }
html[data-theme="light"] .sidebar-logout-btn:hover { background: rgba(239,68,68,0.09); color: #dc2626; }

html[data-theme="light"] .menu-toggle-btn:hover { background: rgba(184,150,12,0.08); }

html[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); }
html[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(184,150,12,0.35); border-color: rgba(184,150,12,0.1); }
html[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb:hover { background: rgba(184,150,12,0.6); }

/* ----------------------------------------------------------
   Theme toggle button
   ---------------------------------------------------------- */
.theme-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font-family: inherit;
}
.theme-toggle-btn:hover {
    background: rgba(250,204,21,0.06);
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.theme-toggle-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
html[data-theme="light"] .theme-toggle-btn { background: rgba(0,0,0,0.03); }
html[data-theme="light"] .theme-toggle-btn:hover { background: rgba(184,150,12,0.06); }
