/* Header Styles - Premium Floating Design */
.floating-header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 95%;
    max-width: 1200px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Hidden State - DISABLED (Always Visible) */
.floating-header.header-hidden {
    transform: translateX(-50%);
    /* Keep centered, don't hide */
}

/* Focus Mode - Fade Header */
body.chat-focus-mode .floating-header {
    opacity: 0.4;
    pointer-events: none;
    /* Prevent clicks while focused on chat */
}

@keyframes headerSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px) translateX(-50%);
    }

    to {
        opacity: 1;
        transform: translateY(0) translateX(-50%);
    }
}

.header-top-row {
    padding: 12px 32px;
    height: auto;
    min-height: 72px;
    position: relative;
    z-index: 1000;
    /* Visual styles moved to .header-surface */
}

.header-surface {
    position: absolute;
    inset: 0;
    background: #FFFFFF;
    backdrop-filter: blur(20px);
    border-radius: 60px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.header-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-surface::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    pointer-events: none;
}

.header-surface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
}

@keyframes headerShimmer {

    0%,
    100% {
        transform: translateX(-100%);
    }

    50% {
        transform: translateX(100%);
    }
}

.search-bar {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 40px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 320px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 1;
}

.search-bar:focus-within {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
    border-color: rgba(0, 0, 0, 0.15);
}

.search-bar span {
    font-size: 18px;
    filter: grayscale(0.2);
    transition: all 0.3s ease;
}

.search-bar:focus-within span {
    filter: grayscale(0);
    transform: scale(1.1);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 15px;
    font-weight: 500;
    color: #111827;
}

.search-bar input::placeholder {
    color: #9CA3AF;
    font-weight: 400;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.app-logo:hover {
    transform: translateX(-50%) translateY(-2px);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(var(--color-primary-rgb), 0.35);
    transition: all 0.3s ease;
}

.app-logo:hover .logo-icon {
    transform: rotate(5deg) scale(1.05);
    box-shadow: 0 6px 24px rgba(var(--color-primary-rgb), 0.45);
}

.app-logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 36px;
    font-weight: 800;
    background: var(--color-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -1px;
    text-shadow: 0 2px 10px rgba(var(--color-primary-rgb), 0.1);
    cursor: pointer;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2;
}

/* Base style for all header action buttons - Ghost style */
.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.icon-btn:hover {
    background: rgba(17, 24, 39, 0.06);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Logout button - Ghost style with black color */
.logout-btn {
    color: #111827;
    gap: 6px;
    padding: 10px 12px;
}

.logout-btn:hover {
    background: rgba(17, 24, 39, 0.06);
}

.logout-btn svg {
    width: 16px;
    height: 16px;
}

.header-actions .settings-btn {
    padding: 10px !important;
    width: 38px !important;
    height: 38px !important;
    justify-content: center !important;
    color: #111827 !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    border-radius: 14px !important;
    margin: 0 !important;
}

.header-actions .settings-btn:hover {
    background: rgba(17, 24, 39, 0.06) !important;
}

.header-actions .settings-btn svg {
    width: 18px !important;
    height: 18px !important;
    transition: transform 0.3s ease;
    stroke: #111827 !important;
    fill: none !important;
    display: block !important;
}

.header-actions .settings-btn:hover svg {
    animation: spin 0.5s ease;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(180deg);
    }
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(17, 24, 39, 0.06);
    padding: 6px 12px 6px 6px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.user-profile:hover {
    background: rgba(17, 24, 39, 0.1);
    transform: scale(1.05);
}

.user-profile:active {
    transform: scale(0.98);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #4b5563;
    display: block;
    transition: all 0.2s ease;
    border: none;
    object-fit: cover;
    padding: 0;
}

.user-profile:hover .user-avatar {
    transform: scale(1.05);
}

.profile-text {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* Nav Pills - Modern Pill Design */
.nav-pills {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(249, 250, 251, 0.9) 100%);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    justify-content: center;
    gap: 6px;
    width: fit-content;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    /* Much lower than header-top-row */
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.6);
}

.nav-pill {
    background: transparent;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
    letter-spacing: -0.3px;
}

.nav-pill:hover {
    color: #374151;
    background: rgba(0, 0, 0, 0.03);
    transform: translateY(-1px);
}

.nav-pill.active {
    background: var(--color-primary);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.25), 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(0);
}

.nav-pill.active::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 50%);
    pointer-events: none;
}

.nav-pill:active {
    transform: scale(0.96);
}

/* Logout Modal */
.logout-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(12px) saturate(140%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1500;
    padding: 16px;
}

.logout-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.logout-modal {
    position: relative;
    background: linear-gradient(145deg, #ffffff 0%, var(--bg-section) 100%);
    border-radius: 24px;
    border: 1px solid rgba(var(--color-primary-rgb), 0.12);
    box-shadow: 0 16px 60px rgba(15, 23, 42, 0.2);
    padding: 26px 24px;
    max-width: 420px;
    width: min(420px, 100%);
    overflow: hidden;
}

.logout-modal__glow {
    position: absolute;
    top: -60px;
    right: -80px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(var(--color-primary-rgb), 0.2) 0%, rgba(var(--color-accent-rgb), 0.0) 60%);
    filter: blur(12px);
    pointer-events: none;
}

.logout-modal__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.15), rgba(var(--color-accent-rgb), 0.1));
    color: var(--text-primary);
    font-size: 24px;
    margin-bottom: 12px;
    box-shadow: 0 10px 30px rgba(var(--color-primary-rgb), 0.2);
}

.logout-modal__eyebrow {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 6px;
}

.logout-modal h3 {
    margin: 0 0 10px;
    font-size: 22px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logout-modal__copy {
    margin: 0 0 18px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
}

.logout-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.logout-btn--ghost,
.logout-btn--primary {
    border: none;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    font-size: 14px;
}

.logout-btn--ghost {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(var(--color-primary-rgb), 0.12);
}

.logout-btn--ghost:hover {
    background: rgba(var(--color-primary-rgb), 0.12);
    transform: translateY(-1px);
}

.logout-btn--primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 14px 28px rgba(var(--color-primary-rgb), 0.25);
}

.logout-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(var(--color-primary-rgb), 0.3);
}

.logout-modal__actions button:active {
    transform: translateY(0);
}

body.modal-open {
    overflow: hidden;
}

/* Mobile Spacer - for centering logo */
.mobile-spacer {
    display: none;
    width: 36px;
    height: 36px;
}

/* ============ USER MENU (Native HTML5 Details) ============ */

.user-menu {
    position: static;
}

/* Remove default marker/arrow */
.user-menu summary {
    list-style: none;
}

.user-menu summary::-webkit-details-marker {
    display: none;
}

.user-menu summary::marker {
    display: none;
}

/* The toggle button */
.user-menu-toggle {
    display: flex;
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.25);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
}

.user-menu-toggle:hover,
.user-menu-toggle:active,
.user-menu[open] .user-menu-toggle {
    background: var(--color-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.35);
}

.user-menu-toggle svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* Dropdown Menu */
.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 16px;
    margin-top: 8px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 8px;
    min-width: 180px;
    z-index: 99999;
    animation: menuSlideDown 0.2s ease;
}

@keyframes menuSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Menu items */
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.user-menu-item:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}

.user-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.user-menu-item.logout {
    color: #ef4444;
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Hide old header actions - we use the user-menu now */
.header-actions {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .floating-header {
        width: 95%;
        top: 12px;
        gap: 0;
        margin-bottom: 0;
        padding: 0;
    }

    .header-top-row {
        padding: 8px 12px;
        /* Compact padding */
        min-height: 56px;
        /* Reduced height */
    }

    .header-surface {
        border-radius: 24px;
        /* Slightly smaller radius for mobile */
        backdrop-filter: blur(12px) saturate(180%);
        /* Reduced blur */
    }

    /* Ensure proper spacing on mobile */
    .header-content {
        gap: 8px;
    }

    .header-content>* {
        flex-shrink: 0;
    }

    .app-logo h1 {
        font-size: 1.25rem;
        /* Smaller logo text */
    }

    /* Hide spacer - not needed with proper flex layout */
    .mobile-spacer {
        display: none;
    }

    /* Compact search bar on mobile - positioned on left */
    .search-bar {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
        min-width: 40px;
        flex-shrink: 0;
        order: 1;
        /* First item */
        border-radius: 12px;
    }

    .search-bar input {
        display: none;
    }

    .search-bar span {
        font-size: 18px;
        margin: 0;
    }

    .search-bar:focus-within {
        width: auto;
        right: 60px;
        padding: 8px 12px;
        justify-content: flex-start;
        position: absolute;
        left: 12px;
        z-index: 10;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .search-bar:focus-within input {
        display: block;
    }

    /* Center the logo - middle item */
    .app-logo {
        position: static;
        transform: none;
        flex: 1;
        display: flex;
        justify-content: center;
        order: 2;
        /* Middle item */
        pointer-events: none;
        /* Make the flex container non-clickable */
    }

    /* User menu - right item */
    .user-menu {
        order: 3;
        /* Last item */
        flex-shrink: 0;
    }

    .app-logo:hover {
        transform: none;
    }

    .app-logo h1 {
        font-size: 24px;
        font-weight: 700;
        pointer-events: auto;
        /* Only the text is clickable */
        cursor: pointer;
    }

    .logo-icon {
        width: 30px;
        height: 30px;
        font-size: 17px;
    }

    /* User menu - good size on mobile */
    .user-menu-toggle {
        width: 40px;
        height: 40px;
    }

    .user-menu-toggle svg {
        width: 18px;
        height: 18px;
    }

    .user-menu-dropdown {
        min-width: 160px;
        right: 8px;
    }

    .user-menu-item {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Nav pills - compact but attractive */
    .nav-pills {
        overflow-x: auto;
        width: 100%;
        justify-content: center;
        padding: 6px;
        gap: 5px;
        border-radius: 16px;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .nav-pills::-webkit-scrollbar {
        display: none;
    }

    .nav-pill {
        white-space: nowrap;
        padding: 10px 16px;
        font-size: 13px;
        font-weight: 600;
        border-radius: 11px;
        flex-shrink: 0;
        min-height: 40px;
        /* Good touch target */
    }

    .nav-pill.active {
        padding: 10px 18px;
        font-weight: 700;
    }
}

/* Even smaller screens */
@media (max-width: 480px) {
    .floating-header {
        width: 100%;
        top: 0;
        gap: 6px;
        margin-bottom: 12px;
        border-radius: 0;
    }

    .header-top-row {
        border-radius: 0 0 18px 18px;
        padding: 10px 12px;
    }

    .app-logo h1 {
        font-size: 22px;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .mobile-spacer {
        display: none;
    }

    .search-bar {
        width: 38px;
        height: 38px;
    }

    .search-bar span {
        font-size: 17px;
    }

    .user-menu-toggle {
        width: 38px;
        height: 38px;
    }

    .user-menu-toggle svg {
        width: 17px;
        height: 17px;
    }

    .user-menu-dropdown {
        min-width: 140px;
        right: 4px;
    }

    .user-menu-item {
        padding: 10px 12px;
        font-size: 13px;
        gap: 8px;
    }

    /* Even smaller search icon on tiny screens */
    .search-bar {
        width: 36px;
        height: 36px;
        order: 1;
        /* Keep on left */
    }

    .search-bar span {
        font-size: 16px;
    }

    .search-bar:focus-within {
        width: 180px;
    }

    /* Ensure logo stays centered */
    .app-logo {
        order: 2;
        pointer-events: none;
        /* Make the flex container non-clickable */
    }

    .app-logo h1 {
        pointer-events: auto;
        /* Only the text is clickable */
        cursor: pointer;
    }

    /* Menu stays on right */
    .user-menu {
        order: 3;
    }

    .nav-pills {
        padding: 5px;
        gap: 4px;
        border-radius: 14px;
    }

    .nav-pill {
        padding: 9px 14px;
        font-size: 12px;
        min-height: 38px;
    }

    .nav-pill.active {
        padding: 9px 16px;
    }
}