/*
---
name: global-area-header-style
description: Cabeçalho comum e estados informativos da confirmação da conta.
dependencies: [admin-visual-theme, global-area-header]
inputs: [data-global-header-access-source, data-prometeu-auth-state, data-prometeu-guest-locked]
entities: {document: account_state}
prohibitions: [public_navigation_readonly_cursor, unknown_as_login_control]
---
*/

@import url('/ui/static/css/admin-visual-theme.css?v=20260513_1');

.admin-global-header {
    --admin-global-brand-font-size: 0.94rem;
    --admin-global-context-scale: 1.72;
    position: sticky;
    top: 0;
    z-index: 60;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px;
    box-sizing: border-box;
    background: var(--prometeu-visual-brand, #2c3e50);
    border-bottom: 1px solid var(--prometeu-visual-shell-border, rgba(176, 190, 197, 0.18));
    box-shadow: none;
    backdrop-filter: none;
}

.admin-global-header__brand {
    min-width: 0;
    color: var(--prometeu-visual-brand-contrast, #ffffff);
    font-size: var(--admin-global-brand-font-size);
    line-height: 1.2;
    font-weight: 700;
    text-decoration: none;
}

.admin-global-header__brand-block {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-global-header__context {
    color: var(--prometeu-visual-brand-muted, #d5dee3);
    font-size: calc(var(--admin-global-brand-font-size) * var(--admin-global-context-scale));
    line-height: 0.98;
    font-weight: 700;
}

.admin-global-header__subtitle {
    color: var(--prometeu-visual-brand-muted, #d5dee3);
    font-size: 0.84rem;
    line-height: 1.3;
    font-weight: 500;
    max-width: min(72vw, 980px);
}

.admin-global-header__build {
    color: var(--prometeu-visual-brand-muted, #d5dee3);
    opacity: 0.72;
    font-size: 0.68rem;
    line-height: 1.2;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(72vw, 980px);
}

.admin-global-header--page .admin-global-header__context {
    max-width: min(72vw, 980px);
    font-size: clamp(1.16rem, 1rem + 0.42vw, 1.42rem);
    line-height: 1.12;
    font-weight: 650;
}

.admin-global-header--page .admin-global-header__subtitle {
    font-size: 0.92rem;
    line-height: 1.35;
}

body.admin-global-header-promoted-page header.admin-header[data-global-header-promoted="true"] {
    display: none;
}

.admin-global-header__secondary-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--prometeu-visual-surface, #ffffff);
    border-bottom: 1px solid var(--prometeu-visual-panel-border, rgba(55, 71, 79, 0.16));
}

.admin-global-header__secondary-link {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 5px 10px;
    border: 1px solid var(--prometeu-visual-panel-border, rgba(55, 71, 79, 0.16));
    background: var(--prometeu-visual-surface-muted, #f4f7f9);
    color: var(--prometeu-visual-text, #37474f);
    font-size: 0.78rem;
    line-height: 1.2;
    font-weight: 650;
    text-decoration: none;
}

.admin-global-header__secondary-link:hover,
.admin-global-header__secondary-link:focus-visible {
    border-color: var(--prometeu-visual-panel-border-strong, rgba(55, 71, 79, 0.24));
    background: #ffffff;
    outline: none;
}

.admin-global-header__account-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

/* Telas técnicas: a caixa do ícone é o próprio círculo (32/30px). Em 360px não sobra largura para um alvo de 44px sem
   empurrar a marca e crescer o cabeçalho (PLT-152 T7, achado M1); as homes têm botões textuais de 44px próprios. */
.admin-global-header__icon-link,
.admin-global-header__avatar {
    width: 32px;
    height: 32px;
    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    border-radius: 50%;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #ffffff;
    padding: 0;
}

.admin-global-header__icon-link::before,
.admin-global-header__avatar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1px solid rgba(176, 190, 197, 0.22);
    background: var(--prometeu-visual-brand-strong, #1f2d3a);
    pointer-events: none;
    z-index: -1;
}

.admin-global-header__icon-link {
    text-decoration: none;
    flex: 0 0 auto;
}

.admin-global-header__icon-link:hover::before,
.admin-global-header__icon-link:focus-visible::before {
    background: rgba(255, 255, 255, 0.1);
}

.admin-global-header__icon-link:focus-visible {
    outline: none;
}

.admin-global-header__account {
    position: relative;
    flex: 0 0 auto;
}

.admin-global-header__avatar {
    cursor: pointer;
}

.admin-global-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
}

.admin-global-header__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.admin-global-header__avatar:focus-visible {
    outline: 3px solid rgba(176, 190, 197, 0.32);
    outline-offset: 2px;
}

.admin-global-header__menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 172px;
    display: grid;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid rgba(176, 190, 197, 0.22);
    box-shadow: 0 18px 36px rgba(44, 62, 80, 0.16);
}

.admin-global-header__menu-header {
    display: grid;
    gap: 2px;
    padding: 4px 4px 8px;
}

.admin-global-header__menu-eyebrow {
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.admin-global-header__menu-name {
    color: var(--prometeu-visual-text, #37474f);
    font-size: 0.92rem;
    line-height: 1.2;
    font-weight: 700;
}

.admin-global-header__menu-email {
    color: #475569;
    font-size: 0.82rem;
    line-height: 1.25;
    word-break: break-word;
}

.admin-global-header__menu-tenant {
    display: grid;
    gap: 2px;
    margin-top: 6px;
}

.admin-global-header__tenant-select {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid rgba(176, 190, 197, 0.45);
    background: #fff;
    color: var(--prometeu-visual-text, #37474f);
    font-size: 0.82rem;
    line-height: 1.25;
}

.admin-global-header__menu-tenant-notice {
    display: block;
    margin-top: 6px;
    color: #9a3412;
    font-size: 0.78rem;
    line-height: 1.3;
}

.admin-global-header__tenant-badge {
    max-width: 220px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(176, 190, 197, 0.45);
    background: #fff;
    color: var(--prometeu-visual-text, #37474f);
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.admin-global-header__tenant-badge--pending {
    border-color: #f97316;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 700;
}

.admin-global-header__menu-divider {
    height: 1px;
    margin: 2px 0 4px;
    background: rgba(176, 190, 197, 0.24);
}

.admin-global-header__menu[hidden] {
    display: none;
}

.admin-global-header__menu button {
    width: 100%;
    min-height: 36px;
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    background: transparent;
    color: var(--prometeu-visual-text, #37474f);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.admin-global-header__menu button:hover:not(:disabled),
.admin-global-header__menu button:focus-visible:not(:disabled) {
    background: rgba(44, 62, 80, 0.08);
    outline: none;
}

.admin-global-header__menu button:disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

body.prometeu-auth-readonly [data-prometeu-guest-locked="true"] {
    cursor: not-allowed;
}

body.prometeu-auth-readonly [data-admin-workspace-content],
body.prometeu-auth-readonly .area-home-main,
body.prometeu-auth-readonly main {
    filter: saturate(0.92);
}

body.prometeu-auth-readonly:not(.area-home-page) [data-prometeu-guest-locked="true"] {
    opacity: 0.62;
}

body.prometeu-auth-readonly a[data-prometeu-guest-locked="true"] {
    text-decoration: none;
}

@media (max-width: 640px) {
    .admin-global-header {
        --admin-global-brand-font-size: 0.82rem;
        min-height: 44px;
        gap: 8px;
        padding: 5px 10px;
    }

    .admin-global-header__account-bar {
        gap: 8px;
    }

    .admin-global-header__icon-link,
    .admin-global-header__avatar {
        width: 30px;
        height: 30px;
    }

    .admin-global-header__icon-link::before,
    .admin-global-header__avatar::before {
        width: 30px;
        height: 30px;
    }

    .admin-global-header--page .admin-global-header__context {
        max-width: calc(100vw - 118px);
        font-size: clamp(0.96rem, 3vw, 1.08rem);
    }

    .admin-global-header__secondary-nav {
        padding: 7px 12px;
    }

}

/* A conta gerenciada usa texto; estados sem confirmação são informativos. */
[data-global-account-status] {
    color: var(--prometeu-visual-brand-contrast, #ffffff);
    font-size: 1rem;
    line-height: 1.5;
}
body[data-global-header-access-source="home-areas"] .admin-global-header__avatar {
    width: auto;
    min-width: 44px;
    min-height: 44px;
    padding-inline: 12px;
    font-size: 1rem;
    border: 1px solid rgba(176, 190, 197, 0.22);
    background: var(--prometeu-visual-brand-strong, #1f2d3a);
}
body[data-global-header-access-source="home-areas"] .admin-global-header__avatar::before {
    content: none;
}
@media (max-width: 640px) {
    body[data-global-header-access-source="home-areas"] .admin-global-header {
        flex-wrap: wrap;
    }
    body[data-global-header-access-source="home-areas"]:is([data-prometeu-auth-state="pending"], [data-prometeu-auth-state="unknown"]) .admin-global-header__account-bar {
        flex-basis: 100%;
        padding-top: 8px;
    }
}

/* Falha da troca de organização: fica na barra da conta, visível com o menu fechado. */
.admin-global-header__tenant-error {
    display: block;
    max-width: min(22rem, 100%);
    margin-top: 4px;
    color: var(--prometeu-visual-brand-contrast, #ffffff);
    font-size: 1rem;
    line-height: 1.5;
}

[data-global-user-avatar][hidden],
[data-global-login-action][hidden],
[data-global-tenant-error][hidden] {
    display: none;
}

/* Apresentação opt-in: dado e guard continuam pertencendo à fonte canônica. */
.admin-global-header[data-presentation="text"] { min-height: 56px; height: auto; padding: 6px max(24px, calc((100% - 1120px) / 2)); flex-wrap: wrap; gap: 12px; }
.admin-global-header[data-presentation="text"] .admin-global-header__account-bar,
.admin-global-header[data-presentation="text"] .admin-global-header__account { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; flex: 0 1 auto; min-width: 0; max-width: 100%; }
/* Conta sem nenhum controle visível (página de login) não ocupa lugar: o gap da barra empurraria o retorno para fora da borda da coluna. */
.admin-global-header[data-presentation="text"] .admin-global-header__account:not(:has(> :not([hidden]))) { display: none; }
.admin-global-header[data-presentation="text"] .admin-global-header__icon-link,
.admin-global-header[data-presentation="text"] .admin-global-header__avatar:not([hidden]),
.admin-global-header[data-presentation="text"] .admin-global-header__tenant-badge:not([hidden]) { box-sizing: border-box; width: auto; height: 44px; min-height: 44px; padding: 8px 12px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; opacity: 1; color: #fff; background: #1f2d3a; border: 1px solid #b0bec5; border-radius: 8px; }
.admin-global-header[data-presentation="text"] .admin-global-header__icon-link::before,
.admin-global-header[data-presentation="text"] .admin-global-header__avatar::before { display: none; content: none; }
.admin-global-header[data-presentation="text"] [data-global-account-status] { flex-basis: 100%; order: 3; background: none; border: 0; font-size: 16px; }
.admin-global-header[data-presentation="text"] a:focus-visible,
.admin-global-header[data-presentation="text"] button:focus-visible { outline: 3px solid #ffffff; outline-offset: 3px; }
@media (max-width: 640px) {
    .admin-global-header[data-presentation="text"] { position: static; padding-inline: 16px; }
    .admin-global-header[data-presentation="text"] .admin-global-header__brand-block { flex-basis: 100%; }
    body.area-home-page .admin-global-header[data-presentation="text"]:has([data-global-account-status]:not([hidden])) .admin-global-header__account-bar,
    body.area-home-page .admin-global-header[data-presentation="text"]:has([data-global-account-status]:not([hidden])) .admin-global-header__account { flex-basis: 100%; }
}


.admin-global-header[data-presentation="text"] .admin-global-header__menu button { min-height: 44px; font-size: 16px; }
.admin-global-header[data-presentation="text"] .admin-global-header__menu button:focus-visible { outline-color: #0b63e5; }

/* O menu fica acima do conteúdo mesmo com o cabeçalho mobile no fluxo normal. */
.admin-global-header[data-presentation="text"] .admin-global-header__account { z-index: 60; }

.admin-global-header[data-presentation="text"] .admin-global-header__tenant-badge--pending:not([hidden]) {
    border-color: #f97316;
    background: #fff7ed;
    color: #9a3412;
}
