:root {
    /* --- LIGHT MODE (Teal + White) --- */
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-glass: none;
    /* No blur in light mode */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #0891b2;
    /* Teal */
    --primary-rgb: 8, 145, 178;
    --primary-dark: #0e7490;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Status Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;

    /* Sidebar Background */
    --sidebar-bg: #ffffff;
    --input-bg: #f8fafc;

    /* Legacy/Alias support */
    --gold: var(--primary);
}

[data-theme="dark"] {
    /* --- DARK MODE (Gold + Dark Blue + Glass) --- */
    --bg: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-glass: blur(12px);
    /* Restore Glass Effect */
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --primary: #d4af37;
    /* Original Gold */
    --primary-rgb: 212, 175, 55;
    --primary-dark: #b4942b;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.3);

    /* Sidebar Background */
    --sidebar-bg: rgba(15, 23, 42, 0.95);
    --input-bg: rgba(0, 0, 0, 0.3);
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    margin: 0;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Global Reset for better layout control */
* {
    box-sizing: border-box;
}

/* Glass Card / Panel */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: var(--card-glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* 3D / Primary Button */
.btn-3d {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    /* Always white text on primary button */
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px -1px rgba(var(--primary-rgb), 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-3d:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(var(--primary-rgb), 0.4);
}

.btn-3d:active {
    transform: translateY(0);
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    max-width: 290px;
    width: 290px;
    min-width: 290px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px;
    position: fixed;
    height: 100%;
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
    z-index: 1000;
    /* Higher than Top Bar (100) */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Sidebar Styling */
.sidebar-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    position: relative;
    /* Context for close icon */
}

.sidebar-close {
    display: none;
    /* Hidden on desktop */
    position: absolute;
    top: 5px;
    right: 0;
    width: 30px;
    height: 30px;
    background: var(--input-bg);
    border-radius: 6px;
    color: var(--text-muted);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: 0.2s;
}

.sidebar-close:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.nav-item:hover {
    background: var(--input-bg);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.2);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    font-weight: 500;
}

.theme-toggle:hover {
    background: var(--border);
    color: var(--text-main);
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--danger);
    padding: 12px;
    text-decoration: none;
    font-weight: 500;
    border-radius: 12px;
    transition: background 0.2s;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.main {
    flex: 1;
    margin-left: 290px;
    padding: 30px;
    margin-top: 70px;
    /* Accounts for Top Bar */
    max-width: calc(100vw - 290px);
}

/* Mobile */
.hamburger {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 101;
    font-size: 24px;
    background: var(--primary);
    color: white;
    padding: 5px 12px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        backdrop-filter: blur(10px);
    }

    .main {
        max-width: 100vw;
        margin-left: 0;
        padding: 15px;
    }

    .hamburger {
        display: block;
    }
}

input {
    width: calc(100% - 24px);
    margin-top: 6px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: border-color 0.2s, background 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin-bottom: 25px;
    padding-bottom: 5px;
    scrollbar-width: none;
    /* Firefox */
}

.settings-tabs::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.tab-link {
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-link:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.tab-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Password Strength Meter */
.password-strength-meter {
    height: 4px;
    background: #e2e8f0;
    margin-top: 8px;
    border-radius: 2px;
    overflow: hidden;
    transition: all 0.3s;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    background: var(--danger);
    transition: all 0.3s;
}

.password-requirements {
    display: none;
    /* Hidden by default */
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 8px;
    font-size: 11px;
    /* Smaller font */
    color: var(--text-muted);
}

.password-requirements.active {
    display: grid;
}

.requirement-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.requirement-item i {
    font-size: 10px;
    color: #cbd5e1;
    transition: color 0.3s;
}

.requirement-item.valid {
    color: var(--success);
    /* Text becomes green */
}

.requirement-item.valid i {
    color: var(--success);
    /* Icon becomes green */
}

/* Form Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Form Group & Password Toggle */
.form-group {
    /* Removing position relative from here as we use wrapper now for password */
    margin-bottom: 10px;
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    /* Center vertically relative to input wrapper only */
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 10;
    font-size: 0.9em;
    padding: 5px;
    /* Increase click area */
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--primary);
}

/* Adjust input padding to prevent text overlap with icon */
input[type="password"],
input[type="text"] {
    padding-right: 40px !important;
}

/* --- GLOBAL UI REDESIGN (TOP BAR) --- */
.top-bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 290px;
    /* Matches Sidebar width */
    height: 70px;
    background: var(--card-bg);
    /* Glass effect from variable */
    backdrop-filter: var(--card-glass);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
    transition: left 0.3s ease;
}

[data-theme="light"] .top-bar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search Bar */
.search-wrapper {
    position: relative;
    width: 300px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.top-search {
    width: 100%;
    padding: 10px 10px 10px 40px;
    /* Space for icon */
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    margin: 0;
}

.top-search::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.top-search:focus {
    box-shadow: none;
    border-bottom: 1px solid var(--primary);
    border-radius: 0;
}

/* Icons & Actions */
.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
    border-radius: 8px;
    transition: 0.2s;
}

.icon-btn:hover {
    background: var(--input-bg);
    color: var(--primary);
}

.badge-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 1px solid var(--bg);
}

/* User Dropdown */
.user-profile-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 30px;
    transition: background 0.2s;
}

.user-profile-trigger:hover {
    background: var(--input-bg);
}

.top-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.top-username {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.user-profile-trigger i {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-dropdown-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 120%;
    right: 0;
    width: 240px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    /* Hidden by default */
    flex-direction: column;
}

[data-theme="light"] .dropdown-menu {
    background: #ffffff;
}

.dropdown-menu.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-header {
    padding: 10px 15px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.dd-name {
    margin: 0;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
}

.dd-role {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    padding: 10px 15px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.dropdown-item:hover {
    background: var(--input-bg);
    color: var(--primary);
}

.dropdown-item.text-danger:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RESPONSIVE ADJUSTMENTS */
@media (max-width: 992px) {
    .search-wrapper {
        width: 200px;
    }

    .top-username {
        display: none;
        /* Hide name on tablets */
    }
}

@media (max-width: 768px) {

    .user-profile-trigger i {
        display: none;
    }

    .top-bar {
        left: 0;
        padding: 0 20px;
    }

    .hamburger {
        display: block !important;
        position: static !important;
        background: none !important;
        color: var(--text-main) !important;
        padding: 0 !important;
        font-size: 1.2rem;
    }

    .main {
        margin-left: 0;
        max-width: 100%;
        margin-top: 70px;
    }

    .search-wrapper {
        display: none;
        /* Hide search on mobile */
    }

    .mobile-logo {
        display: block !important;
        margin-right: auto;
        margin-left: 8px;
        /* Spacing from hamburger */
    }

    .sidebar-close {
        display: flex;
        /* Show on mobile */
    }
}

/* Default Mobile Logo State */
.mobile-logo {
    display: none;
}