:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --dark-color: #0f172a;
    --border-color: #334155;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 1040;
}

.top-bar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.top-bar .navbar {
    padding: 0;
}

.top-bar .nav-wrapper {
    gap: 1rem;
}

.top-bar .mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    transition: all 0.2s ease;
}

.top-bar .mobile-menu-toggle:hover,
.top-bar .mobile-menu-toggle[aria-expanded="true"] {
    color: var(--primary-color);
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.08);
}

.top-bar .navbar-nav {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.top-bar .nav-item {
    position: relative;
}

.top-bar .nav-link {
    color: #e2e8f0;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar .nav-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.top-bar .nav-dropdown-caret {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.top-bar .nav-dropdown.open .nav-dropdown-caret,
.top-bar .nav-dropdown.active .nav-dropdown-caret {
    transform: rotate(180deg);
}

.top-bar .nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    min-width: 220px;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.35);
    flex-direction: column;
    gap: 0.25rem;
    z-index: 1050;
}

.top-bar .nav-dropdown.open .nav-dropdown-menu,
.top-bar .nav-dropdown:hover .nav-dropdown-menu {
    display: flex;
}

.top-bar .nav-dropdown-menu .nav-link {
    border: none;
    background: transparent;
    justify-content: flex-start;
    padding: 0.45rem 0.75rem;
}

.top-bar .nav-dropdown-menu .nav-link:hover,
.top-bar .nav-dropdown-menu .nav-link.active {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--primary-color);
    border-radius: 6px;
}

.top-bar .nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

.top-bar .nav-link.active {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
    font-weight: 600;
}

.top-bar .user-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-bar .theme-selector {
    position: relative;
}

.theme-selector:not(.theme-selector-dropdown) .theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.08);
    color: #e2e8f0;
    padding: 0.4rem 0.9rem;
    transition: all 0.2s ease;
}

.theme-selector:not(.theme-selector-dropdown) .theme-toggle:hover,
.theme-selector:not(.theme-selector-dropdown).open .theme-toggle {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.12);
}

.theme-selector .theme-toggle-caret {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.theme-selector:not(.theme-selector-dropdown).open .theme-toggle-caret {
    transform: rotate(180deg);
}

.theme-selector:not(.theme-selector-dropdown) .theme-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    width: 280px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.35);
    padding: 0.75rem;
    display: none;
    z-index: 1100;
}

.theme-selector:not(.theme-selector-dropdown).open .theme-menu {
    display: block;
}

.theme-selector-dropdown {
    position: relative;
    width: 100%;
}

.theme-selector-dropdown .theme-toggle {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
}

.theme-selector-dropdown .theme-toggle-left {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.theme-selector-dropdown .theme-current-label {
    flex: 1;
    font-size: 0.8rem;
    color: #cbd5f5;
    margin-left: auto;
    text-align: right;
}

.theme-selector-dropdown .theme-menu {
    position: absolute;
    left: calc(100% + 0.5rem);
    top: 0;
    width: 280px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.35);
    padding: 0.75rem;
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 1051;
}

.theme-selector-dropdown.open .theme-menu {
    display: flex;
}

.theme-selector-dropdown .theme-toggle-caret {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.theme-selector-dropdown.open .theme-toggle-caret {
    transform: rotate(90deg);
}

.theme-menu .theme-option {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 10px;
    padding: 0.6rem 0.65rem;
    color: #e2e8f0;
    text-align: left;
    transition: all 0.2s ease;
}

.theme-menu .theme-option + .theme-option {
    margin-top: 0.35rem;
}

.theme-menu .theme-option:hover {
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
}

.theme-menu .theme-option.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.12);
}

.theme-option-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.theme-option-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
}

.menu-beta-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    font-weight: 600;
    margin-left: auto;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.theme-option-description {
    font-size: 0.8rem;
    color: #cbd5f5;
    margin: 0.2rem 0 0.35rem;
}

.theme-option-preview {
    display: flex;
    gap: 0.35rem;
}

.theme-swatch {
    width: 28px;
    height: 10px;
    border-radius: 999px;
    background: var(--swatch-color, #fff);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.top-bar .notification-center {
    position: relative;
}

.top-bar .notification-toggle {
    position: relative;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.2s ease;
    padding: 0;
}

.top-bar .notification-toggle:hover,
.top-bar .notification-toggle[aria-expanded="true"] {
    color: var(--primary-color);
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.08);
}

.top-bar .notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    background: var(--danger-color);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    line-height: 16px;
    text-align: center;
    padding: 0 4px;
}

.top-bar .notification-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    width: min(340px, 90vw);
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.4);
    padding: 0.75rem;
    display: none;
    z-index: 1050;
}

.top-bar .notification-panel.active {
    display: block;
}

.notification-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.notification-panel-header span {
    font-weight: 600;
    color: #e2e8f0;
}

.notification-panel-header .btn-link {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0;
}

.notification-panel-header .btn-link:hover {
    text-decoration: underline;
}

.notification-panel-body {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification-item {
    padding: 0.65rem;
    border-radius: 10px;
    background: rgba(51, 65, 85, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
    transition: background 0.2s ease;
}

.notification-item.unread {
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.1);
}

.notification-item:hover {
    background: rgba(99, 102, 241, 0.15);
}

.notification-item h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    color: #f8fafc;
}

.notification-item p {
    margin: 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

.notification-time {
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: #64748b;
}

.notification-empty {
    padding: 1.25rem 0.5rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

.top-bar .text-muted {
    color: #94a3b8 !important;
}

.top-bar .btn-outline-danger {
    border-color: rgba(220, 38, 38, 0.4);
    color: #fca5a5;
}

.top-bar .btn-outline-danger:hover {
    background-color: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.6);
    color: #fecaca;
}

/* Dropdown menu divider */
.top-bar .nav-dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(148, 163, 184, 0.2),
        transparent);
    margin: 0.5rem 0;
}

/* Dropdown menu header */
.top-bar .nav-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(148, 163, 184, 0.9);
    margin-top: 0.25rem;
}

.top-bar .nav-dropdown-header i {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Nested subdropdown menu */
.top-bar .nav-subdropdown {
    position: relative;
}

.top-bar .nav-subdropdown-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-bar .nav-subdropdown-caret {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    margin-left: auto;
}

.top-bar .nav-subdropdown.open .nav-subdropdown-caret,
.top-bar .nav-subdropdown:hover .nav-subdropdown-caret {
    transform: rotate(90deg);
}

.top-bar .nav-subdropdown-menu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.35);
    flex-direction: column;
    gap: 0.25rem;
    z-index: 1051;
    margin-left: 0.5rem;
}

.top-bar .nav-subdropdown.open .nav-subdropdown-menu,
.top-bar .nav-subdropdown:hover .nav-subdropdown-menu {
    display: flex;
}

.top-bar .nav-subdropdown-menu .nav-link {
    padding: 0.45rem 0.75rem;
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .top-bar .nav-wrapper {
        width: 100%;
        justify-content: space-between;
    }

    .top-bar .mobile-menu-toggle {
        display: inline-flex;
    }

    .top-bar .navbar {
        width: 100%;
    }

    .top-bar .navbar-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        background: rgba(15, 23, 42, 0.9);
        border: 1px solid rgba(51, 65, 85, 0.7);
        border-radius: 12px;
    }

    .top-bar.mobile-menu-open .navbar-nav {
        display: flex;
    }

    .top-bar .nav-dropdown {
        width: 100%;
    }

    .top-bar .nav-link {
        width: 100%;
        justify-content: space-between;
    }

    .top-bar .nav-dropdown-menu {
        position: static;
        width: 100%;
        margin-top: 0.25rem;
        box-shadow: none;
        padding: 0.35rem 0.5rem;
        border-radius: 8px;
        border: 1px solid rgba(51, 65, 85, 0.6);
        background: rgba(30, 41, 59, 0.95);
    }

    .top-bar .user-actions {
        width: 100%;
        justify-content: space-between;
    }

    .top-bar .notification-panel {
        right: auto;
        left: 0;
        width: 100%;
        max-height: 70vh;
        overflow-y: auto;
    }

    .top-bar .notification-center {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        position: static;
    }

    .top-bar .notification-panel {
        position: fixed;
        top: 72px;
        right: 16px;
        left: 16px;
        margin: 0 auto;
        max-width: 420px;
        width: calc(100vw - 32px);
        border-radius: 16px;
        box-shadow: 0 18px 36px rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(12px);
        z-index: 1100;
    }

    .theme-selector-dropdown .theme-menu {
        position: static;
        width: 100%;
        margin-top: 0.35rem;
        box-shadow: none;
        padding: 0.5rem;
    }
}
