/* ============================================
   7 Dayz - Professional Header (Desktop + Mobile)
   ============================================ */

/* Header bar */
.header {
    background: var(--card-bg, #fff);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.header .container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 64px;
}

/* Logo */
.logo-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}

.header .logo {
    height: 52px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* Main nav - desktop */
.header .nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.header .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    color: var(--text-secondary, #6b7280);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.header .nav-link i {
    font-size: 1.1rem;
    opacity: 0.9;
}

.header .nav-link:hover {
    color: var(--accent-primary, #6366f1);
    background: rgba(99, 102, 241, 0.08);
}

/* Right block: theme, user, bell, menu */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Theme button */
.header-actions .theme-toggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-primary, #111);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.header-actions .theme-toggle:hover {
    background: var(--bg-tertiary, #f3f4f6);
    border-color: var(--border-color, #e5e7eb);
}

.header-actions .theme-toggle i {
    font-size: 1.1rem;
}

/* Username */
.header-actions .user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary, #111);
    padding: 0 4px;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 40px;
}

/* Logout button in header */
.header-actions .btn-outline {
    height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color, #e5e7eb);
    background: transparent;
    color: var(--text-primary, #111);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.header-actions .btn-outline:hover {
    background: var(--bg-secondary, #f9fafb);
    border-color: var(--text-secondary, #6b7280);
}

/* Notification bell */
.header-notification-wrap {
    position: relative;
    flex-shrink: 0;
    overflow: visible;
}

/* Pop-up tooltip below the bell - "Hey there, you've got some news" */
.notification-popup {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, 6px);
    margin-top: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    white-space: nowrap;
    z-index: 10003;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.notification-popup::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: #4f46e5;
}

.notification-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 10px);
}

/* Mobile: keep text horizontal - 1 or 2 rows, not stacked vertically */
@media (max-width: 768px) {
    .notification-popup {
        white-space: normal;
        max-width: 260px;
        min-width: 200px;
        text-align: center;
        word-wrap: break-word;
        line-height: 1.4;
    }
}

.notification-bell {
    position: relative;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #facc15, #eab308);
    color: #1c1917;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(234, 179, 8, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.notification-bell:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
}

.notification-bell i {
    font-size: 1.15rem;
}

/* WhatsApp-style badge: red circle, top-right of bell */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border: 2px solid var(--card-bg, #fff);
    z-index: 2;
    pointer-events: none;
}

/* Dropdown */
.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 380px;
    max-height: 70vh;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border-color, #e5e7eb);
    z-index: 10002;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.notification-dropdown.open {
    display: flex;
}

.notification-dropdown-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary, #111);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: var(--card-bg, #fff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.notification-dropdown-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1;
}

.notification-dropdown-close:hover {
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-primary, #111);
}

.notification-dropdown-body {
    padding: 16px;
    overflow-y: auto;
    max-height: 60vh;
    background: var(--card-bg, #fff);
}

.notification-loading,
.notification-empty {
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
    text-align: center;
    padding: 24px;
    margin: 0;
}

.notification-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

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

.notification-item-text {
    margin: 6px 0 4px;
    font-size: 0.9rem;
    color: var(--text-primary, #111);
    line-height: 1.45;
}

.notification-item-date {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

.notification-media {
    max-width: 100%;
    max-height: 240px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin-bottom: 8px;
    background: var(--bg-secondary, #f3f4f6);
}

.notification-item video.notification-media {
    min-height: 120px;
}

.notification-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary, #6366f1);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.notification-download-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary, #6366f1);
}

body.dark-theme .notification-media {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .notification-download-btn {
    color: #818cf8;
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.4);
}

body.dark-theme .notification-download-btn:hover {
    background: rgba(129, 140, 248, 0.25);
    border-color: #818cf8;
}

/* Mobile menu button - hidden on desktop */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-primary, #111);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* ========== Mobile ========== */
@media (max-width: 768px) {
    .header .container {
        padding: 0 16px;
    }

    .header-content {
        min-height: 56px;
        gap: 12px;
    }

    .header .logo {
        height: 42px;
    }

    /* Nav: slide-in panel from right (hamburger icon position) - same on all pages */
    .header .nav {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        width: min(320px, 85vw);
        height: 100%;
        max-height: 100vh;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 24px 20px;
        padding-top: calc(60px + env(safe-area-inset-top));
        background: var(--card-bg, #ffffff);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
        z-index: 10001;
        transform: translateX(100%);
        transition: transform 0.25s ease, visibility 0.25s ease;
        overflow-y: auto;
        border-radius: 12px 0 0 12px;
        border: 1px solid var(--border-color, #e5e7eb);
        border-right: none;
        visibility: visible;
    }

    .header .nav.active {
        transform: translateX(0);
        pointer-events: auto;
    }

    /* Ensure nav links only clickable when nav is visible */
    .header .nav:not(.active) {
        pointer-events: none;
        visibility: hidden;
    }

    .header .nav-link {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 14px 16px;
        font-size: 1rem;
        border-radius: 10px;
        margin-bottom: 4px;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    .header .nav-link i {
        font-size: 1.2rem;
    }

    .header .nav-link.mobile-logout-link {
        margin-top: auto;
        padding-top: 20px;
        border-top: 1px solid var(--border-color, #e5e7eb);
        color: #dc2626;
    }

    .header .nav-link.mobile-logout-link:hover {
        background: rgba(220, 38, 38, 0.08);
        color: #b91c1c;
    }

    /* Backdrop when mobile menu is open - must sit below header/nav */
    body.menu-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9998;
        pointer-events: auto;
    }

    /* Raise header above backdrop when menu open so hamburger + nav links are clickable */
    body.menu-open .header {
        z-index: 10002;
    }

    body.menu-open {
        overflow: hidden;
    }

    /* Logout only in menu on mobile - hide from header */
    .header-actions .btn-outline {
        display: none !important;
    }

    .header-actions {
        gap: 8px;
    }

    .header-actions .theme-toggle,
    .notification-bell {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
    }

    .header-actions .user-name {
        max-width: 90px;
        font-size: 0.85rem;
        line-height: 38px;
    }

    .mobile-menu-toggle {
        display: flex;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Hamburger to X when open */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }

    /* Notification dropdown: full-width bottom sheet on mobile */
    .notification-dropdown {
        display: none !important;
        right: 0;
        left: 0;
        width: 100%;
        margin: 0;
        border-radius: 0;
        position: fixed;
        top: auto;
        bottom: 0;
        height: 82vh;
        max-height: 82vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
        border: none;
        border-top: 1px solid var(--border-color, #e5e7eb);
        background: var(--card-bg, #ffffff);
        z-index: 10003;
    }

    .notification-dropdown.open {
        display: flex !important;
    }

    .notification-dropdown-header {
        padding: 18px 20px;
        border-radius: 20px 20px 0 0;
    }

    .notification-dropdown-body {
        flex: 1;
        min-height: 0;
        overflow-y: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* Backdrop when dropdown open on mobile - lighter overlay to match site brightness */
.notification-dropdown-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 10002;
    opacity: 0;
    transition: opacity 0.2s;
}

.notification-dropdown-backdrop.open {
    display: block;
    opacity: 1;
}

body.notification-dropdown-open {
    overflow: hidden;
}

/* ========== Dark theme – header ========== */
body.dark-theme .header {
    background: var(--card-bg);
    border-bottom-color: var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark-theme .header-actions .theme-toggle {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-theme .header-actions .theme-toggle:hover {
    background: var(--bg-tertiary);
}

body.dark-theme .header-actions .user-name {
    color: var(--text-primary);
}

body.dark-theme .header .nav-link {
    color: var(--text-secondary);
}

body.dark-theme .header .nav-link:hover {
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
}

body.dark-theme .mobile-menu-toggle {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

body.dark-theme .notification-bell {
    background: #fbbf24;
    color: #1f2937;
}

body.dark-theme .notification-bell:hover {
    background: #f59e0b;
    color: #111827;
}

body.dark-theme .notification-badge {
    border-color: var(--card-bg);
}

/* Mobile menu panel in dark theme – solid, no transparency */
@media (max-width: 768px) {
    body.dark-theme .header .nav {
        background: #1f2937;
        border-color: #374151;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    }

    body.dark-theme .header .nav-link.mobile-logout-link {
        border-top-color: #374151;
        color: #f87171;
    }

    body.dark-theme .header .nav-link.mobile-logout-link:hover {
        background: rgba(248, 113, 113, 0.15);
        color: #fca5a5;
    }
}
