/**
 * Material Design header menu (Top App Bar pattern)
 * Used by header_menu.php across authenticated pages.
 */

.md-header-bar {
    --md-header-on-primary: #ffffff;
    --md-header-on-primary-muted: rgba(255, 255, 255, 0.7);
    --md-header-state-hover: rgba(255, 255, 255, 0.08);
    --md-header-state-focus: rgba(255, 255, 255, 0.12);
    --md-header-state-pressed: rgba(255, 255, 255, 0.16);
    --md-header-shape-full: 9999px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    min-height: 40px;
    padding: 0 8px 0 12px;
    box-sizing: border-box;
    font-family: 'Roboto', 'open_sansregular', system-ui, -apple-system, sans-serif;
    color: var(--md-header-on-primary);
}

/* Same token surface for login language bar */
.login-lang-bar {
    --md-header-on-primary: #ffffff;
    --md-header-on-primary-muted: rgba(255, 255, 255, 0.7);
    --md-header-state-hover: rgba(255, 255, 255, 0.08);
    --md-header-state-focus: rgba(255, 255, 255, 0.12);
    --md-header-state-pressed: rgba(255, 255, 255, 0.16);
    --md-header-shape-full: 9999px;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    min-height: 40px;
    margin: 0 -32px 8px;
    padding: 0 12px;
    box-sizing: border-box;
    background-color: #D7383C;
    font-family: 'Roboto', 'open_sansregular', system-ui, -apple-system, sans-serif;
    color: var(--md-header-on-primary);
    border-radius: 28px 28px 0 0;
}

.md-header-bar__section {
    display: flex;
    align-items: center;
    min-width: 0;
}

.md-header-bar__section--end {
    flex-shrink: 0;
    margin-left: 12px;
}

/* User greeting — Material chip / avatar row */
.md-header-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    padding: 4px 12px 4px 4px;
    border-radius: var(--md-header-shape-full);
    color: var(--md-header-on-primary);
}

.md-header-user__avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: block;
    color: var(--md-header-on-primary);
}

.md-header-lang__icon,
.md-header-lang__caret {
    flex-shrink: 0;
    display: block;
    color: currentColor;
}

.md-header-lang__icon {
    width: 18px;
    height: 18px;
}

.md-header-lang__caret {
    width: 16px;
    height: 16px;
    margin-left: 2px;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.md-header-lang-select.is-open .md-header-lang__caret {
    transform: rotate(180deg);
}

.md-header-user__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 20px;
}

.md-header-user__greeting {
    font-weight: 400;
    color: var(--md-header-on-primary-muted);
    margin-right: 0.25em;
}

.md-header-user__name {
    font-weight: 500;
    color: var(--md-header-on-primary);
}

/* Language selector — Material menu button + dropdown */
.md-header-lang-select {
    position: relative;
}

.md-header-lang {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 0 8px 0 12px;
    border: none;
    border-radius: var(--md-header-shape-full);
    background: transparent;
    color: var(--md-header-on-primary) !important;
    text-decoration: none !important;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
    -webkit-tap-highlight-color: transparent;
}

.md-header-lang__label {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
}

.md-header-lang:hover,
.md-header-lang:focus {
    background-color: var(--md-header-state-hover);
    color: var(--md-header-on-primary) !important;
    text-decoration: none !important;
    outline: none;
}

.md-header-lang:focus-visible {
    background-color: var(--md-header-state-focus);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.md-header-lang:active,
.md-header-lang-select.is-open .md-header-lang {
    background-color: var(--md-header-state-pressed);
}

.md-header-lang-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1100;
    min-width: 140px;
    margin: 0;
    padding: 8px 0;
    list-style: none;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.16);
    font-family: 'Roboto', 'open_sansregular', system-ui, -apple-system, sans-serif;
}

.md-header-lang-menu[hidden] {
    display: none !important;
}

.md-header-lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px 0 12px;
    color: #212121 !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.1px;
    line-height: 20px;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.md-header-lang-option__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    color: #D7383C;
}

.md-header-lang-option:hover,
.md-header-lang-option:focus {
    background-color: rgba(0, 0, 0, 0.04);
    color: #212121 !important;
    text-decoration: none !important;
    outline: none;
}

.md-header-lang-option.is-selected {
    font-weight: 500;
    background-color: rgba(215, 56, 60, 0.08);
}

.md-header-lang-option.is-selected:hover,
.md-header-lang-option.is-selected:focus {
    background-color: rgba(215, 56, 60, 0.12);
}

/* Elevate fixed headers slightly (Material elevation level 2) */
.main-header.navbar-fixed-top:has(.md-header-bar) {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
    z-index: 1030;
}

@media (max-width: 480px) {
    .md-header-bar {
        padding: 0 4px 0 8px;
    }

    .md-header-user {
        padding-right: 8px;
    }

    .md-header-user__text {
        font-size: 13px;
    }

    .md-header-lang__label {
        font-size: 13px;
    }
}
