/* ============================================================
   pharus-modal.css — Compat shim do padrao canonico de modais
   ------------------------------------------------------------
   Padroniza o header dos modais legados `article.modal > .headModal`
   para replicar o visual canonico de `.points-modal__header`
   (ver mobile-view/dist/style/points.css:108-138).

   HTML legado preservado (sem reescrever). Apenas CSS vence
   regras concorrentes de:
     - mobile-view/dist/style/main.css:1105   (.headModal base 140px com overlay)
     - mobile-view/dist/style/main.css:1214   (.modal-close-btn absoluto direita)
     - mobile-view/dist/style/style.css:1183  (.headModal .modal-close-btn z-index)
     - web-panel/functions/assets.php:172     (background-image inline !important)

   Enqueue: assets.php linha 67 (carrega APOS main.css/style.css).
   ============================================================ */

/* ── Scroll-lock quando qualquer modal esta aberto ─────────
   v4.77.41: os selectors :has() foram REMOVIDOS. Estavam caros
   (4 :has() globais re-avaliados a cada mutacao do subtree do body)
   e criavam loop combinado com o MutationObserver subtree:true do
   pharus-modal.js (tambem removido em v4.77.41). Agora depende so
   de body.modal-open, que ja e setada pelo pharusModalOpen (linha 47)
   e pelo atualizarOverflow() legado (access-control/logged-in/main.js)
   para cobrir modais abertos via jQuery. */
body.modal-open {
    overflow: hidden !important;
    overscroll-behavior: contain;
}

/* ── Container flex vertical: permite body scrollavel ────── */
article.modal.open {
    flex-direction: column !important;
}

/* ── Padrão B: modal cola no head__app (sem gap visual) ────
   head__app tem height=56px fixed top:0. O modal deve começar
   em EXATAMENTE 56px para encostar sem deixar faixa. Também
   garante que nav.atalhosApp (57px bottom) continue visível. */
.page-template-page-offer article.modal.open,
body article.modal.open {
    top: var(--header-height, 56px) !important;
    height: calc(100vh - var(--header-height, 56px) - var(--bottom-nav-height, 57px)) !important;
    height: calc(100dvh - var(--header-height, 56px) - var(--bottom-nav-height, 57px)) !important;
    margin: 0 !important;
    border-top: 0 !important;
}

/* Exceções: modais fullscreen (padrão A) ignoram o clamp acima.
   v4.77.48 — #modalProduto REMOVIDO da exceção: usuário pediu header
   do app + nav bottom visíveis (Padrão B). O footer do produto fica
   sticky dentro do .contentModal scrollável. */
article.modal.pharus-modal--fullscreen.open {
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
}

article.modal .container-fluid {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
}

article.modal .container-fluid > .box {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
}

/* ── Header canonico (espelha .points-modal__header) ───────── */
article.modal .headModal {
    position: sticky;
    top: 0;
    z-index: 10;
    /* Fundo COR DA MARCA — vence `background-image` inline do assets.php */
    background: var(--main-color, var(--color-brand, #3B82F6)) !important;
    background-image: none !important;
    color: #fff;
    padding: var(--space-4, 16px) var(--page-padding, 16px);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3, 12px);
    /* Reset do layout antigo de 140px com overlay */
    height: auto;
    min-height: var(--touch-target, 44px);
    width: 100%;
    box-sizing: border-box;
    text-align: left;
}

/* Remove o overlay escuro (::after) do layout antigo (linha 1118 main.css
   e linha 1203 style.css) — o fundo ja e a cor da marca solida. */
article.modal .headModal::after {
    content: none !important;
    background: transparent !important;
    display: none !important;
}

/* ── Botao voltar/fechar (espelha .points-modal__back) ─────── */
article.modal .headModal .modal-close-btn {
    /* Vence o `.modal-close-btn` absoluto em main.css:1214 */
    position: static !important;
    transform: none !important;
    top: auto !important;
    right: auto !important;
    order: 1;
    width: var(--touch-target, 44px);
    height: var(--touch-target, 44px);
    min-width: var(--touch-target, 44px);
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    color: #fff !important;
    font-size: 20px;
    cursor: pointer;
    margin: 0 0 0 -8px !important; /* compensa padding esquerdo */
    padding: 0 !important;
    z-index: 3;
}

article.modal .headModal .modal-close-btn:active {
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: var(--radius-full, 9999px) !important;
}

article.modal .headModal .modal-close-btn i {
    color: #fff !important;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* ── Titulo (espelha .points-modal__title) ─────────────────── */
article.modal .headModal h3 {
    order: 2;
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0;
    color: #fff;
    font-size: var(--font-lg, 17px);
    font-weight: var(--weight-semibold, 600);
    line-height: 1.3;
    text-align: left;
    text-shadow: none;
    /* Vence .modal h3 de main.css:1019 (color var(--text-primary)) */
    position: relative;
    z-index: 2;
    width: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subtitulo opcional (algumas views tem <p> no header) */
article.modal .headModal p {
    order: 3;
    margin: 0;
    padding: 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--font-sm, 13px);
    font-weight: var(--weight-regular, 400);
    line-height: 1.3;
    text-align: right;
    text-shadow: none;
    position: relative;
    z-index: 2;
    width: auto;
    max-width: 50%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Caso .myAccount apareca dentro do .headModal (modal-change-password etc.)
   mantem o layout antigo tipo "hero card" — NAO aplicar o compat shim. */
article.modal .headModal:has(.myAccount) {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    text-align: center;
}
article.modal .headModal:has(.myAccount) h3 {
    text-align: center;
    white-space: normal;
    overflow: visible;
}
article.modal .headModal:has(.myAccount) .modal-close-btn {
    position: absolute !important;
    top: 50%;
    right: var(--page-padding, 16px) !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
}

/* ── Body scrollavel (espelha .points-modal__body) ─────────── */
article.modal .contentModal {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* v4.77.48 — contain local: scroll interno funciona normalmente
       mas pull-to-refresh/bounce não vaza pro body. Antes o body tinha
       overscroll-behavior-y: none GLOBAL que em alguns devices iOS
       interferia no scroll do modal. Agora: body.overscroll none pro
       PWA (reverted pra auto) + contentModal.overscroll contain. */
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    /* Neutraliza o "margin-top: -16px" do layout antigo (main.css:1155)
       que existia para sobrepor o header hero de 140px. */
    margin-top: 0;
    border-radius: 0;
    /* Preserva o padding e o background do layout atual */
    background-color: var(--bg-primary, #fff);
    max-height: none;
}

/* ============================================================
   .pharus-tabs — tabs canônicas (espelha .points-tabs)
   Usado em modais de conteúdo multi-seção. Referência visual:
   mobile-view/dist/style/points.css:177-212
   ============================================================ */
.pharus-tabs-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

ul.pharus-tabs {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border-light, #f4f4f5);
    position: sticky;
    top: 0;
    z-index: 5;
}

.pharus-tab {
    flex: 1;
    padding: var(--space-3, 12px) var(--space-2, 8px);
    text-align: center;
    font-size: var(--font-sm, 13px);
    font-weight: var(--weight-semibold, 600);
    color: var(--text-muted, #71717a);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pharus-tab:hover {
    color: var(--text-primary, #1a1a1a);
}

.pharus-tab.active {
    color: var(--main-color, #3B82F6);
    border-bottom-color: var(--main-color, #3B82F6);
}

.pharus-tab-panels {
    flex: 1;
}

.pharus-tab-content {
    display: none;
    padding: var(--space-4, 16px) var(--page-padding, 16px);
}

.pharus-tab-content.active {
    display: block;
}

/* .contentModal quando tem tabs: zera padding próprio para o header de tabs
   ficar colado no topo (sticky) e o padding interno vir do .pharus-tab-content. */
article.modal .contentModal.has-tabs {
    padding: 0 !important;
}

/* ============================================================
   Action Sheet (iOS-style) — substitui Swal.fire para confirmações
   Uso via JS: pharusConfirm({ title, message, confirmText, cancelText, destructive })
   ============================================================ */
.pharus-action-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999999998;
    opacity: 0;
    transition: opacity .2s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: var(--space-3, 12px);
    padding-bottom: calc(var(--space-3, 12px) + env(safe-area-inset-bottom, 0px));
}

.pharus-action-sheet-backdrop.open {
    opacity: 1;
}

.pharus-action-sheet {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
    transform: translateY(24px);
    opacity: 0;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
}

.pharus-action-sheet-backdrop.open .pharus-action-sheet {
    transform: translateY(0);
    opacity: 1;
}

.pharus-action-sheet__card {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
}

.pharus-action-sheet__header {
    padding: var(--space-4, 16px) var(--space-5, 20px);
    text-align: center;
    border-bottom: 1px solid rgba(60, 60, 67, 0.15);
}

.pharus-action-sheet__title {
    margin: 0;
    font-size: var(--font-md, 15px);
    font-weight: var(--weight-semibold, 600);
    color: var(--text-primary, #18181b);
    letter-spacing: -0.01em;
}

.pharus-action-sheet__message {
    margin: var(--space-1, 4px) 0 0;
    font-size: var(--font-xs, 13px);
    color: var(--text-muted, #71717a);
    line-height: var(--leading-normal, 1.35);
}

.pharus-action-sheet__btn {
    width: 100%;
    padding: var(--space-4, 16px) var(--space-4, 16px);
    background: transparent;
    border: none;
    border-top: 1px solid rgba(60, 60, 67, 0.15);
    font-size: 17px;
    font-weight: var(--weight-regular, 400);
    color: var(--main-color, #007AFF);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s ease;
}

.pharus-action-sheet__btn:first-of-type {
    border-top: none;
}

.pharus-action-sheet__btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.pharus-action-sheet__btn--destructive {
    color: #FF3B30;
    font-weight: var(--weight-semibold, 600);
}

.pharus-action-sheet__btn--cancel {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg, 14px);
    border: none;
    font-weight: var(--weight-semibold, 600);
    color: var(--main-color, #007AFF);
    margin-top: var(--space-2, 8px);
}

/* ============================================================
   Logout overlay — transição de saída (v4.77.69 redesign Apple-style)
   Princípios: tipografia contida (18/13), respiro generoso, halo
   sutil (não pulsa agressivo), gradient limpo sem glare. Permanece
   opaque até redirect.
   ============================================================ */
.pharus-logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 32px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--main-color, #3B82F6) 94%, #fff) 0%,
        var(--main-color, #3B82F6) 55%,
        color-mix(in srgb, var(--main-color, #3B82F6) 82%, #000) 100%
    );
    color: #fff;
    opacity: 0;
    transition: opacity .24s ease-out;
    pointer-events: all;
    text-align: center;
    overscroll-behavior: contain;
    isolation: isolate;
    /* Tipografia Apple-like: system stack quando disponível */
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.pharus-logout-overlay.is-visible {
    opacity: 1;
}

.pharus-logout-overlay__logo-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    margin-bottom: 12px;
    opacity: 0;
    transform: scale(0.94);
    animation: pharusLogoutLogoIn .55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pharus-logout-overlay__logo-wrap::before {
    /* Halo estático muito sutil — sem pulso agressivo */
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255,255,255,0.12) 0%,
        rgba(255,255,255,0) 70%
    );
    z-index: -1;
}

.pharus-logout-overlay__logo {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: #fff;
    object-fit: contain;
    padding: 8px;
    box-shadow:
        0 8px 24px rgba(0,0,0,0.22),
        0 1px 0 rgba(255,255,255,0.25) inset;
}

.pharus-logout-overlay__logo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: var(--main-color, #3B82F6);
    padding: 0;
}

.pharus-logout-overlay__title {
    margin: 0;
    /* Apple-like: título contido, weight 600, tracking negativo suave */
    font-size: 22px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: #fff;
    opacity: 0;
    transform: translateY(6px);
    animation: pharusLogoutFadeUp .45s cubic-bezier(0.16, 1, 0.3, 1) .12s forwards;
}

.pharus-logout-overlay__text {
    margin: 0;
    max-width: 280px;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 400;
    letter-spacing: -0.005em;
    color: rgba(255,255,255,0.75);
    opacity: 0;
    transform: translateY(6px);
    animation: pharusLogoutFadeUp .45s cubic-bezier(0.16, 1, 0.3, 1) .2s forwards;
}

.pharus-logout-overlay__dots {
    display: inline-flex;
    gap: 5px;
    margin-top: 14px;
    opacity: 0;
    animation: pharusLogoutFadeUp .5s cubic-bezier(0.16, 1, 0.3, 1) .32s forwards;
}

.pharus-logout-overlay__dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    animation: pharusLogoutDot 1.4s ease-in-out infinite;
}
.pharus-logout-overlay__dots span:nth-child(2) { animation-delay: 0.16s; }
.pharus-logout-overlay__dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes pharusLogoutLogoIn {
    to { opacity: 1; transform: scale(1); }
}

@keyframes pharusLogoutDot {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.15); }
}

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