/* header.css - Professional header: brand left, unified search center, nav/user right. */

.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-menu);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-1);
    /* Safe area for browsers with address bar at top (iOS Safari, etc.) */
    padding-top: env(safe-area-inset-top, 0);
}

.site-header__inner {
    max-width: var(--max-page);
    margin: 0 auto;
    min-height: var(--header-h);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex: 0 0 auto;
    z-index: 1001;
}
.menu-toggle__bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    margin: 5px 0;
    transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Brand */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-primary);
    text-decoration: none !important;
    letter-spacing: -0.01em;
    flex: 0 0 auto;
}
.brand__mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 900;
    flex: 0 0 auto;
}
.brand__accent {
    color: var(--brand);
}

/* Unified Search Bar (Keyword + Location + Experience + Search + Reset) */
.site-search {
    flex: 1 1 280px;
    max-width: 720px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.site-search__field {
    display: flex;
    align-items: center;
    position: relative;
}
.site-search__field--keyword {
    flex: 1 1 200px;
    min-width: 160px;
}
.site-search__field--location,
.site-search__field--experience {
    flex: 0 0 140px;
}
.site-search__icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.site-search__input {
    width: 100%;
    font: inherit;
    font-size: 0.92rem;
    color: var(--text-primary);
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.55rem 1rem 0.55rem 2.6rem;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
    min-height: var(--touch-target);
}
.site-search__input::placeholder {
    color: var(--text-muted);
}
.site-search__input:focus {
    outline: none;
    background: var(--bg-card);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.site-search__select {
    width: 100%;
    font: inherit;
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.55rem 2.2rem 0.55rem 0.85rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23747c84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 16px;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
    min-height: var(--touch-target);
}
.site-search__select:focus {
    outline: none;
    background: var(--bg-card);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.site-search__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: var(--brand);
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
    box-shadow: 0 2px 8px rgba(255, 69, 0, 0.25);
}
.site-search__btn:hover {
    background: var(--brand-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 69, 0, 0.35);
}
.site-search__btn:active {
    transform: scale(0.98);
}
.site-search__reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.site-search__reset:hover {
    background: var(--bg-soft);
    border-color: var(--brand);
    color: var(--brand);
}

/* Navigation */
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    margin-left: auto;
    flex-wrap: wrap;
}
.site-nav__link {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    text-decoration: none !important;
    min-height: var(--touch-target);
}
.site-nav__link:hover {
    background: var(--bg-soft);
    color: var(--text-primary);
    text-decoration: none;
}
.site-nav__link.is-active {
    color: var(--brand);
    background: var(--brand-soft);
}

.header-auth {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Profile dropdown ---------- */
.profile {
    position: relative;
}

.profile__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    max-width: 220px;
    min-height: var(--touch-target-sm);
}
.profile__btn:hover {
    background: var(--bg-soft);
}
.profile__btn[aria-expanded="true"] {
    background: var(--bg-soft);
    border-color: var(--border);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.profile__name {
    font-weight: 700;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}
.profile__caret {
    color: var(--text-muted);
    font-size: 0.65rem;
}

.profile__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: 0.4rem;
    z-index: var(--z-menu);
}
.profile__head {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.35rem;
}
.profile__email {
    display: block;
    font-weight: 700;
    font-size: 0.88rem;
    word-break: break-all;
}
.profile__role {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.profile__item {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    text-decoration: none !important;
    min-height: var(--touch-target);
}
.profile__item:hover {
    background: var(--bg-soft);
}
.profile__item--danger {
    color: var(--danger);
}
.profile__form {
    margin: 0;
}

/* ---------- Mobile menu overlay ---------- */
.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
}
.mobile-menu[data-mobile-menu]:not([hidden]) {
    display: flex;
}
.mobile-menu__inner {
    background: var(--bg-card);
    width: 100%;
    max-width: 320px;
    height: 100%;
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-3);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
}
.mobile-menu[data-mobile-menu]:not([hidden]) .mobile-menu__inner {
    transform: translateX(0);
}
.mobile-menu__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    margin: 1rem;
}
.mobile-menu__nav {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
}
.mobile-menu__link {
    display: block;
    padding: 1rem 1rem;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none !important;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    min-height: var(--touch-target);
}
.mobile-menu__link:hover {
    background: var(--bg-soft);
    color: var(--brand);
}
.mobile-menu__link.is-active {
    background: var(--brand-soft);
    color: var(--brand);
}
.mobile-menu__link--danger {
    color: var(--danger);
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}
.mobile-menu__logout {
    margin: 0;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
}

/* Mobile search toggle */
.mobile-search-toggle {
    display: none;
}

/* ---------- Mobile responsive ---------- */
@media (max-width: 640px) {
    .menu-toggle {
        display: inline-flex;
    }
    .mobile-search-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text-primary);
        cursor: pointer;
        margin-left: auto;
    }
    .mobile-search-toggle[aria-expanded="true"] {
        background: var(--brand-soft);
        border-color: var(--brand);
        color: var(--brand);
    }
    .site-header__inner {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        min-height: 56px;
    }
    .site-search {
        display: none;
        order: 10;
        flex-basis: 100%;
        max-width: 100%;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
        gap: 0.4rem;
        animation: hp-slideDown 0.25s var(--ease);
    }
    .site-search.is-open,
    .site-search.is-active {
        display: flex;
    }
    .site-search__field--keyword {
        flex: 1 1 100%;
        order: 1;
    }
    .site-search__field--location,
    .site-search__field--experience {
        flex: 1 1 calc(50% - 0.2rem);
        min-width: 120px;
        order: 2;
    }
    .site-search__btn,
    .site-search__reset {
        order: 3;
    }
    .site-search__reset {
        margin-left: auto;
    }
    .site-nav {
        display: none; /* hidden on mobile, use mobile menu */
    }
    .header-auth {
        display: none; /* hidden on mobile, use mobile menu */
    }
    .profile__name {
        display: none;
    }
}

@media (min-width: 641px) {
    .mobile-menu {
        display: none !important;
    }
}

@media (max-width: 420px) {
    .site-header__inner {
        padding: 0.5rem;
    }
    .brand {
        font-size: 1.05rem;
    }
    .brand__mark {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    .site-search {
        gap: 0.35rem;
    }
    .site-search__field--keyword {
        flex: 1 1 100%;
        order: 1;
    }
    .site-search__field--location,
    .site-search__field--experience {
        flex: 1 1 calc(50% - 0.175rem);
        min-width: 100px;
        order: 2;
    }
    .site-search__btn {
        width: 100%;
        height: 48px;
        border-radius: var(--radius);
        order: 4;
    }
    .site-search__reset {
        width: 100%;
        height: 44px;
        border-radius: var(--radius);
        order: 5;
    }
    .site-search__select {
        font-size: 0.85rem;
        padding: 0.5rem 2rem 0.5rem 0.8rem;
    }
}

@media (max-width: 360px) {
    .site-header__inner {
        padding: 0.4rem;
    }
    .brand {
        font-size: 0.95rem;
    }
    .brand__mark {
        width: 22px;
        height: 22px;
        font-size: 0.8rem;
    }
    .site-search {
        gap: 0.3rem;
    }
    .site-search__field--location,
    .site-search__field--experience {
        flex: 1 1 100%;
        min-width: 0;
    }
    .site-search__input {
        font-size: 0.85rem;
        padding: 0.5rem 0.85rem 0.5rem 2.2rem;
    }
    .site-search__icon {
        left: 0.6rem;
        width: 16px;
        height: 16px;
    }
    .site-search__select {
        font-size: 0.82rem;
        padding: 0.5rem 1.8rem 0.5rem 0.7rem;
    }
    .site-search__btn,
    .site-search__reset {
        height: 44px;
    }
}