/*
 * File: header.css
 * Desc: Header component styles
 */

app-header {
    display: block;
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-green));
    color: var(--white);
    padding: 0 20px;
    box-shadow: var(--shadow);
    /* Sticky (not relative) so the Living Blossom indicator in the logo
       stays in the user's peripheral vision on long-scrolling pages like
       Processes. The sidebar is already position:fixed at top:70px, so
       this pins the header into the 70px strip the sidebar leaves clear. */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
    margin: 0 auto;
    position: relative;
}

/*
 *  flex: 0 0 auto;
 */
.logo-section {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    position: absolute;
    left: 0;
    z-index: 1;
    justify-self: flex-start;
    margin-right: auto;
    min-width: 60px; /* Ensures minimum space for logo */
}

.logo-icon {
    width: 40px;
    height: 52px;
    background: var(--bglogo);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Smooth glow transitions for the AI Activity indicator. */
    transition: box-shadow 0.4s ease;
}

/*
 * AI Activity Indicator — "Living Blossom"
 *
 * The .logo-icon wrapper gains .logo-icon--thinking while any AI work is in
 * flight (after a 400ms debounce in window.aiActivity). The tulip image
 * inside "breathes" — gently scaling up and gaining a bright white drop-shadow
 * glow that traces the petal shape. When the last AI task completes, the
 * wrapper briefly gets .logo-icon--bloomed (one-shot ~700ms "full bloom"
 * celebration) and then settles back to still.
 *
 * IMPORTANT: We use `filter: drop-shadow()` on the <img> rather than
 * `box-shadow` on the wrapper, because the wrapper sits on a purple gradient
 * header with a lavender background — a colored box-shadow gets lost in the
 * gradient. drop-shadow follows the alpha of the tulip itself, so the glow
 * hugs the petals and is unmistakably visible against any background.
 *
 * Reduced-motion users get a steady glow with no movement.
 */
.logo-icon--thinking {
    cursor: help;
}
.logo-icon--thinking img {
    animation: blossom-breathe 3s ease-in-out infinite;
    transform-origin: center 60%; /* Pivot near the bulb so the petals open visually */
    will-change: transform, filter;
}

.logo-icon--bloomed img {
    animation: blossom-full-bloom-img 700ms ease-out 1;
    transform-origin: center 60%;
    will-change: transform, filter;
}

@keyframes blossom-breathe {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.35));
    }
    50% {
        transform: scale(1.13);
        filter:
            drop-shadow(0 0 10px rgba(255, 255, 255, 0.95))
            drop-shadow(0 0 18px rgba(255, 220, 130, 0.55));
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.35));
    }
}

@keyframes blossom-full-bloom-img {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6));
    }
    40% {
        transform: scale(1.28);
        filter:
            drop-shadow(0 0 18px rgba(255, 255, 255, 1))
            drop-shadow(0 0 32px rgba(127, 176, 105, 0.85));
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
    }
}

/*
 * Hover tooltip — only rendered while .logo-icon--thinking is present, only
 * visible on :hover. Lives below the logo so it never covers the brand mark.
 */
.ai-activity-tooltip {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    max-width: 320px;
    padding: 10px 14px;
    background: rgba(33, 25, 54, 0.95);
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    font-size: 0.8125rem;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 1100;
}
.ai-activity-tooltip-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
    margin-bottom: 6px;
}
.ai-activity-tooltip-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ai-activity-tooltip-list li {
    padding: 2px 0;
}
.ai-activity-tooltip-list li::before {
    content: '🌱';
    margin-right: 6px;
    opacity: 0.85;
}
.logo-section:hover .ai-activity-tooltip {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .logo-icon--thinking img {
        animation: none;
        /* Steady white glow — no movement, but still clearly "alive". */
        filter:
            drop-shadow(0 0 6px rgba(255, 255, 255, 0.85))
            drop-shadow(0 0 14px rgba(255, 220, 130, 0.5));
    }
    .logo-icon--bloomed img {
        animation: none;
        filter: drop-shadow(0 0 10px rgba(127, 176, 105, 0.8));
        transition: filter 0.5s ease;
    }
}

.banner-section {
    flex: 1;
    text-align: center;
    padding: 0 80px;
}

.banner-text {
    font-size: 24px;
    font-weight: 300;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.menu-section {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Trial Badge */
.trial-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    cursor: help;
}

.trial-icon {
    font-size: 1rem;
}

.trial-text {
    white-space: nowrap;
}

/* User Menu */
.user-menu-container {
    position: relative;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--white);
    padding: 6px 10px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.user-menu-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--white);
    color: var(--primary-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}


.dropdown-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.user-menu-button:hover .dropdown-arrow {
    transform: translateY(2px);
}

/* User Menu Dropdown */
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 15px;
    background: linear-gradient(135deg, var(--primary-purple), var(--primary-green));
    color: var(--white);
    border-radius: 12px 12px 0 0;
}

.user-menu-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.user-menu-email {
    font-size: 0.875rem;
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-divider {
    height: 1px;
    background: var(--gray-medium);
    margin: 5px 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-menu-item:hover {
    background: var(--purple-xlight);
    color: var(--primary-purple);
}

.user-menu-item .menu-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.user-menu-item[data-action="logout"] {
    color: #ef4444;
}

.user-menu-item[data-action="logout"]:hover {
    background: #fee2e2;
}

.hamburger-menu {
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: none;
}

.hamburger-menu:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--white);
    margin: 5px 0;
    transition: var(--transition);
}

/* Laptop responsive - hide tagline, show logo only */
@media (max-width: 1200px) {
    .brand-tagline {
        display: none;
    }

    .banner-section {
        padding: 0 40px;
    }

    .banner-text {
        font-size: 22px;
    }

    .menu-section {
        gap: 10px;
    }
}

/* Tablet responsive */
@media (max-width: 1024px) {
    .banner-text {
        font-size: 20px;
    }

    /* Show hamburger when sidebar is hidden */
    .hamburger-menu {
        display: block;
    }

    /* Hide locale name, show flag only */
    locale-switcher .locale-name {
        display: none;
    }
}

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

    .banner-text {
        font-size: 18px;
    }

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

    .trial-badge {
        display: none; /* Hide on mobile, show in hamburger menu or user dropdown */
    }

    .dropdown-arrow {
        display: none;
    }

    .user-menu-button {
        padding: 6px;
        min-width: 32px;
    }
}

@media (max-width: 480px) {
    .banner-section {
        padding: 0 10px;
    }

    .banner-text {
        font-size: 16px;
    }

    .menu-section {
        gap: 8px;
    }
}
