:root {
    /* Brighter, Premium Light Theme Palette */
    --bg-body: #f3f6fc;
    /* Very light cool grey/blue */
    --bg-sidebar: #ffffff;

    /* Vibrant Brighter Accents */
    --primary: #4f46e5;
    /* Indigo 600 - Vivid */
    --primary-hover: #4338ca;
    --secondary: #ec4899;
    /* Pink 500 */

    /* Text Colors - High Contrast for Brightness */
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */

    /* Glassmorphism / Panel Variables */
    --glass-bg: rgba(255, 255, 255, 0.85);
    /* Bright White Glass */
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    /* Soft, elegant shadow */
    --panel-border: rgba(226, 232, 240, 0.8);
    /* Light grey border */

    /* Functional Colors - Brighter */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Spacing & Radius */
    --radius-sm: 10px;
    --radius-md: 20px;
    --radius-lg: 30px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Hide Scrollbar Globally but allow scrolling */
html,
body,
.sidebar,
.main-content {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
    width: 0;
    height: 0;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    /* Subtle bright gradient in background */
    background-image:
        radial-gradient(circle at 0% 0%, rgba(79, 70, 229, 0.05), transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(236, 72, 153, 0.05), transparent 40%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    /* Allow grow */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    overflow-y: auto;
    /* Native Scroll */
}

/* --- Auth Page --- */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem;
}

/* --- Layout --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    /* Allow grow */
    height: auto;
}

/* --- Sidebar --- */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid #e2e8f0;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    z-index: 20;
    position: sticky;
    /* Sticky Sidebar */
    top: 0;
    height: 100vh;
    /* Full Height of Viewport */
    overflow-y: auto;
}

.brand-section {
    margin-bottom: 3rem;
    padding-left: 0.5rem;
}

.brand-logo {
    font-size: 1.8rem;
    font-weight: 800;
    /* Gradient Text for Logo */
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar nav,
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.2rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
    transform: translateX(2px);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-link.active:hover {
    color: white;
    /* Keep white on hover if active */
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    margin-top: 1rem;
}

/* --- Main Content --- */
.main-content {
    padding: 2rem 3rem;
    /* overflow-y: auto; REMOVED to use body scroll */
    position: relative;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    position: sticky;
    top: 0;
    /* Glassy Header */
    background: rgba(243, 246, 252, 0.85);
    padding-bottom: 1rem;
    padding-top: 1rem;
    z-index: 10;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid transparent;
}

.header.scrolled {
    border-bottom: 1px solid #e2e8f0;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
    margin-bottom: 0.3rem;
    letter-spacing: -0.8px;
}

/* --- Components --- */

/* Glass Panel / Cards */
.glass-panel {
    background: var(--bg-sidebar);
    /* Solid white/off-white for cards, clearer */
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.08);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.4);
}

.btn-block {
    display: flex;
    width: 100%;
}

.text-white {
    color: white !important;
}

/* Grid System */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    /* Darker label */
    font-size: 0.9rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: #ffffff;
    /* White input */
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Chat Specific Corrections for Light Mode */
.chat-container {
    background: #ffffff !important;
    border: 1px solid var(--panel-border);
}

.contacts-list {
    border-right: 1px solid #f1f5f9;
}

.contact-item:hover,
.contact-item.active {
    background: #f8fafc;
}

.contact-item.active {
    border: 1px solid var(--primary);
    background: rgba(79, 70, 229, 0.02);
}

.msg-left {
    background: #f1f5f9;
    /* Light grey bubble */
    color: var(--text-main);
}

.msg-right {
    background: var(--primary);
    color: white;
}

.input-area {
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

/* Badges */
.badge {
    padding: 0.35em 0.8em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

main>* {
    animation: fadeIn 0.4s ease-out forwards;
}

/* --- PREMIUM MOBILE RESPONSIVENESS (APP-LIKE) --- */
.mobile-header-actions {
    display: none !important;
}

/* Hidden on Desktop Forcefully */
.mobile-menu-toggle {
    display: none;
}

@media (max-width: 991px) {

    /* Show Header Actions (Bell + Toggle) */
    .mobile-header-actions {
        display: flex !important;
        align-items: center;
        gap: 15px;
    }

    /* Hide redundant Notification Button in Page Header */
    .main-content .header a[href*="notifications"] {
        display: none !important;
    }

    .main-content .header a[href*="messages"] {
        /* Optional: Hide messages button too if it exists */
    }

    /* 1. Layout Reset */
    .dashboard-layout {
        display: block;
        /* Stack vertically */
    }

    body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
        background: #f8fafc;
        /* Clean background */
    }

    /* 2. Top Header Bar (Sidebar transforms into Sticky Header) */
    .sidebar {
        width: 100%;
        height: 70px;
        padding: 0 1.5rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 1000;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        background: #ffffff;
        /* Solid bg to avoid issues */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
        overflow: visible !important;
        /* Allow Drawer to spill out */
        backdrop-filter: none !important;
        /* PREVENT CONTAINING BLOCK */
        -webkit-backdrop-filter: none !important;
    }

    /* 3. Branding Adjustments */
    /* Target the header wrapper div in sidebar */
    .sidebar>div:first-child {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 0 !important;
        /* Remove desktop padding */
    }

    .brand-section {
        margin: 0;
        padding: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .brand-logo {
        font-size: 1.4rem;
    }

    /* Hide company text description to keep header clean */
    .sidebar div[style*="font-size: 0.8rem"] {
        display: none !important;
    }

    /* 4. Hamburger Toggle Button */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(236, 72, 153, 0.1));
        color: var(--primary);
        border-radius: 12px;
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.92);
        background: rgba(79, 70, 229, 0.15);
    }

    /* Active State (Open Menu) - Show Close Icon */
    .sidebar.active .mobile-menu-toggle i::before {
        content: "\f00d";
        /* fa-times */
    }

    .sidebar.active .mobile-menu-toggle {
        background: rgba(239, 68, 68, 0.1);
        color: var(--danger);
        transform: rotate(90deg);
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    }

    /* 5. Mobile Drawer (Navigation) */
    /* 5. Mobile Drawer (Navigation) - SIMPLIFIED */
    .sidebar nav {
        display: none !important;
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        background: #ffffff;
        padding: 1.5rem;
        padding-bottom: 120px;
        flex-direction: column;
        gap: 0.8rem;
        overflow-y: auto;
        z-index: 9999;
    }

    /* 6. Active State (Open Drawer) - FORCE VISIBLE */
    .sidebar.active nav {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100vw !important;
        height: calc(100vh - 70px) !important;
        top: 70px !important;
        left: 0 !important;
        transform: none !important;
        background: #fff !important;
        z-index: 9999 !important;
    }

    /* 7. Enhanced Mobile Links */
    .nav-link {
        background: #f8fafc;
        padding: 1rem 1.2rem;
        border: 1px solid #f1f5f9;
        border-radius: 14px;
        font-size: 1.05rem;
        color: var(--text-main);
    }

    .nav-link:hover {
        background: #fff;
        border-color: var(--primary);
        transform: translateX(4px);
    }

    .nav-link.active {
        background: var(--primary);
        color: white !important;
        border-color: var(--primary);
        box-shadow: 0 8px 20px -5px rgba(79, 70, 229, 0.4);
    }

    .nav-link i {
        font-size: 1.2rem;
        width: 25px;
    }

    /* 8. Mobile Footer (Profile/Logout) */
    .sidebar>div:last-child {
        display: none !important;
    }

    .sidebar.active>div:last-child {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        padding: 1.5rem;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        z-index: 10000;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    }

    /* 9. Main Content Adjustment */
    .main-content {
        padding: 1.5rem;
        padding-top: 1rem;
    }

    .header {
        position: relative;
        background: transparent;
        backdrop-filter: none;
        border: none;
        margin-bottom: 1.5rem;
        padding: 0;
        flex-direction: column;
        align-items: flex-start;
    }

    h1 {
        font-size: 1.75rem;
        letter-spacing: -1px;
    }

    /* 10. Card Improvements */
    .glass-panel {
        padding: 1.2rem;
        border-radius: 16px;
    }

    .grid-cards {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}