/* =========================================================
   header.css — Styles for the navigation bar and dropdown
   ========================================================= */

/* Glassmorphism Navbar */
nav {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.nav-brand span {
    color: var(--accent-color);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* Nav link */
.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        align-items: center;
    }
    
    .nav-brand {
        font-size: 1.35rem;
    }

    .nav-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
    }

    .nav-link {
        font-size: 0.9rem;
    }

    /* Compress buttons on mobile to prevent excessive wrapping */
    .btn-primary, .btn-secondary, .btn-admin {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .avatar-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .notif-bell-btn {
        width: 36px;
        height: 36px;
    }

    /* Break dropdowns out of their parent buttons to position relative to the navbar */
    .user-dropdown, .notif-wrapper {
        position: static !important;
    }

    .dropdown-menu, .notif-dropdown {
        position: absolute;
        top: calc(100% + 5px);
        left: 5%;
        right: 5%;
        width: 90%;
        max-width: none;
        transform: none;
        margin: 0;
    }
}

/* User Avatar & Dropdown */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    outline: none;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
    overflow: hidden;
    padding: 0;
}

.avatar-btn img.avatar-img-header {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-btn:hover {
    transform: scale(1.05);
    border-color: var(--accent-color);
    box-shadow: 0 0 12px var(--accent-glow);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 120%;
    min-width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    text-align: left;
}

.dropdown-header .user-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.dropdown-header .user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 0.75rem 0;
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    font-family: var(--font-family);
    transition: color 0.2s ease;
}

.dropdown-item:hover {
    color: var(--text-primary);
}

.username-update-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.username-update-form .form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.username-update-form .input-group {
    display: flex;
    gap: 0.5rem;
}

.username-update-form input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    outline: none;
    font-family: var(--font-family);
}

.username-update-form input:focus {
    border-color: var(--accent-color);
}

.btn-save-username {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.btn-save-username:hover {
    background: var(--accent-hover);
}

.btn-logout-direct {
    color: #ef4444;
    font-weight: 600;
}

.btn-logout-direct:hover {
    color: #f87171;
}

/* ── Notification Bell ── */
.notif-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notif-bell-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    transition: color 0.2s ease, background 0.2s ease;
    position: relative;
    outline: none;
}

.notif-bell-btn:hover {
    color: var(--text-primary);
    background: var(--glass-bg);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    display: none;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 0 0 2px var(--bg-primary, #0f0f19);
}

.notif-badge.show-badge {
    display: flex;
}

.notif-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 320px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.notif-dropdown.show {
    display: block;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.notif-mark-read, .notif-clear-all {
    background: transparent;
    border: none;
    font-size: 0.78rem;
    cursor: pointer;
    font-family: var(--font-family);
    padding: 0;
    transition: color 0.2s;
}

.notif-mark-read {
    color: var(--accent-color);
}

.notif-mark-read:hover {
    color: var(--accent-hover, #818cf8);
}

.notif-clear-all {
    color: #ef4444; /* red for clear/delete */
}

.notif-clear-all:hover {
    color: #f87171;
}

.notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 340px;
    overflow-y: auto;
}

.notif-empty {
    padding: 1.25rem 1rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    text-align: center;
}

.notif-item {
    border-bottom: 1px solid var(--glass-border);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item a {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1.4;
}

.notif-item a:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.notif-item.notif-unread {
    background: rgba(99, 102, 241, 0.06);
}

.notif-item.notif-unread a {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Drag Handle for item rows ── */
.drag-handle {
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0 0.4rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    user-select: none;
}

.drag-handle:hover {
    opacity: 1;
    color: var(--accent-color);
}

.item-row.dragging {
    opacity: 0.5;
    border: 2px dashed var(--accent-color);
    background: rgba(99, 102, 241, 0.05);
}

.btn-theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.btn-theme-toggle:hover {
    transform: scale(1.1);
}

/* Theme Toggle Icons */
html.theme-light .theme-icon-dark { display: none; }
html.theme-light .theme-icon-light { display: inline; }
html:not(.theme-light) .theme-icon-dark { display: inline; }
html:not(.theme-light) .theme-icon-light { display: none; }

/* ── Light Mode Header Overrides ── */
:root.theme-light .notif-bell-btn {
    color: var(--text-secondary);
}

:root.theme-light .notif-bell-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
}

:root.theme-light .btn-theme-toggle {
    color: var(--text-primary);
}

:root.theme-light .dropdown-item {
    color: var(--text-secondary);
}

:root.theme-light .dropdown-item:hover {
    color: var(--text-primary);
}

:root.theme-light .dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

:root.theme-light .notif-dropdown {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

:root.theme-light .notif-item a {
    color: var(--text-secondary);
}

:root.theme-light .notif-item.notif-unread a {
    color: var(--text-primary);
}

:root.theme-light .notif-empty {
    color: var(--text-secondary);
}

:root.theme-light .username-update-form input {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
}

