/*
 * OsFluxo — PWA: navegação inferior, avisos, central de notificações (16/10/2026).
 * Arquivo só de adições. Rollback: remover o include partials.pwa-head dos layouts.
 */

/*
 * Áreas seguras (17/10/2026): o painel usa viewport-fit=cover, como o FutGestor. O conteúdo
 * vai até as bordas e cada barra reserva o próprio espaço (topo, barra de gestos e, deitado,
 * as laterais do notch). A barra de status do iOS continua opaca (status-bar-style "default",
 * orientação da Apple desde o iOS 26.1), então o inset do topo costuma ser 0 em pé.
 * --ofx-app-h: altura visível medida pelo pwa-app.js. No app instalado o iOS 26+ calcula
 * 100vh com a altura da barra de status (WebKit 316008) e o rodapé e o fim do menu saíam da tela.
 * Login e cadastro seguem sem cover: lá o próprio sistema mantém o conteúdo na área segura.
 */
:root {
    --ofx-sat: env(safe-area-inset-top, 0px);
    --ofx-sar: env(safe-area-inset-right, 0px);
    --ofx-sab: env(safe-area-inset-bottom, 0px);
    --ofx-sal: env(safe-area-inset-left, 0px);
    --ofx-app-h: 100vh;
}
@supports (height: 100dvh) {
    :root { --ofx-app-h: 100dvh; }
}

/* Altura do menu e da área de conteúdo sem depender do 100vh (todas as larguras) */
.page-wrapper.compact-wrapper .page-body-wrapper .sidebar-wrapper { height: var(--ofx-app-h) !important; }
.page-wrapper.compact-wrapper .sidebar-wrapper .sidebar-main .sidebar-links { height: calc(var(--ofx-app-h) - 100px) !important; }
.page-wrapper.compact-wrapper .page-body-wrapper .page-body { min-height: calc(var(--ofx-app-h) - 80px); }
.login-card { min-height: var(--ofx-app-h); }

/* Topo fixo: reserva o notch e as laterais quando o aparelho está deitado */
.page-wrapper .page-header {
    padding-top: var(--ofx-sat);
    padding-left: var(--ofx-sal);
    padding-right: var(--ofx-sar);
}
/* No tema escuro o .page-header fica branco por baixo do .header-wrapper: o recuo mostraria faixas brancas */
body.dark-only .page-wrapper .page-header { background-color: #262932; }

/* App instalado: sem o "elástico" da página e sem zoom no toque duplo, como um app nativo */
@media (display-mode: standalone) {
    html { overscroll-behavior-y: none; }
    body { touch-action: manipulation; }
}

/* ---------- Navegação inferior ---------- */
.app-tabbar { display: none; }

@media (max-width: 1199.98px) {
    .app-tabbar {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        padding: 0 var(--ofx-sar) var(--ofx-sab) var(--ofx-sal);
        background: rgba(255, 255, 255, .96);
        -webkit-backdrop-filter: saturate(160%) blur(12px);
        backdrop-filter: saturate(160%) blur(12px);
        border-top: 1px solid #e6e8f0;
        box-shadow: 0 -6px 24px rgba(20, 24, 40, .06);
        transition: transform .18s ease;
    }
    .app-tabbar-grid {
        display: flex;
        align-items: flex-end;
        max-width: 640px;
        margin: 0 auto;
    }
    .app-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: 56px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 2px 7px;
        border: 0;
        background: none;
        color: #6b7285;
        font: inherit;
        font-size: 11px;
        font-weight: 500;
        line-height: 1;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .app-tab:active { transform: scale(.94); }
    .app-tab svg {
        width: 23px;
        height: 23px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    /* O tema aplica letter-spacing nos textos; aqui ele cortava "Orçamentos" em 320–360 px */
    .app-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; letter-spacing: 0; font-size: clamp(10px, 3.05vw, 11px); }
    .app-tab.is-active, .app-tab:hover { color: #7366ff; }
    .app-tab.is-active svg { stroke-width: 2.2; }
    .app-tab:focus-visible { outline: 2px solid #7366ff; outline-offset: -4px; border-radius: 10px; }
    .app-tab-fab {
        width: 50px;
        height: 50px;
        margin-top: -24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #7366ff;
        color: #fff;
        border: 4px solid #fff;
        box-shadow: 0 8px 20px rgba(115, 102, 255, .42);
    }
    .app-tab-primary { color: #7366ff; }
    .app-tab-fab svg { width: 24px; height: 24px; stroke-width: 2.4; }

    /*
     * O conteúdo e o rodapé não ficam escondidos atrás da barra. Coluna flexível da altura da
     * tela: em página curta o rodapé fica logo acima da barra (antes o min-height de 100vh do
     * tema o empurrava para fora da tela); em página longa ele vem depois do conteúdo.
     */
    .page-wrapper .page-body-wrapper {
        display: flex;
        flex-direction: column;
        min-height: var(--ofx-app-h);
        padding-top: var(--ofx-sat);
        padding-left: var(--ofx-sal);
        padding-right: var(--ofx-sar);
        padding-bottom: calc(68px + var(--ofx-sab));
    }
    .page-wrapper.compact-wrapper .page-body-wrapper .page-body { flex: 1 0 auto; min-height: 0; }
    .page-wrapper .page-body-wrapper > .footer { flex: 0 0 auto; }
    .tap-top { bottom: calc(84px + var(--ofx-sab)) !important; }

    /* Teclado aberto: a barra sai do caminho dos campos */
    html.kb-open .app-tabbar { transform: translateY(110%); }

    body.dark-only .app-tabbar { background: rgba(37, 40, 50, .96); border-top-color: #383b48; box-shadow: none; }
    body.dark-only .app-tab { color: #a3a6b5; }
    body.dark-only .app-tab.is-active, body.dark-only .app-tab-primary { color: #9d93ff; }
    body.dark-only .app-tab-fab { border-color: #252832; }
}

/* ---------- Avisos (toasts) ---------- */
.ofx-toasts {
    position: fixed;
    z-index: 1090;
    top: calc(76px + var(--ofx-sat));
    right: 16px;
    width: min(380px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.ofx-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid #eceef5;
    border-radius: 16px;
    background: #fff;
    color: #1f2433;
    box-shadow: 0 16px 40px rgba(20, 24, 40, .14);
    cursor: pointer;
    animation: ofx-in .28s ease both;
}
.ofx-toast.is-leaving { animation: ofx-out .2s ease both; }
.ofx-toast-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #7366ff;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(115, 102, 255, .16);
}
.ofx-toast-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ofx-toast[data-category="quotes"] .ofx-toast-icon { background: #16a34a; box-shadow: 0 0 0 4px rgba(22, 163, 74, .16); }
.ofx-toast[data-category="quote_views"] .ofx-toast-icon { background: #0ea5e9; box-shadow: 0 0 0 4px rgba(14, 165, 233, .16); }
.ofx-toast[data-category="announcements"] .ofx-toast-icon { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .18); }
.ofx-toast[data-tone="error"] .ofx-toast-icon { background: #dc3545; box-shadow: 0 0 0 4px rgba(220, 53, 69, .16); }
.ofx-toast[data-tone="success"] .ofx-toast-icon { background: #16a34a; box-shadow: 0 0 0 4px rgba(22, 163, 74, .16); }
.ofx-toast-body { flex: 1 1 auto; min-width: 0; padding-top: 1px; }
.ofx-toast-body strong { display: block; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.ofx-toast-body span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; font-size: 12.5px; line-height: 1.4; color: #6b7285; }
.ofx-toast-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin: -6px -6px 0 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: #9aa0b2;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.ofx-toast-close:hover { background: #f3f4f8; color: #4b5163; }
body.dark-only .ofx-toast { background: #2b2e3a; border-color: #3a3d4b; color: #e4e5e9; box-shadow: 0 16px 40px rgba(0, 0, 0, .4); }
body.dark-only .ofx-toast-body span { color: #a3a6b5; }
body.dark-only .ofx-toast-close:hover { background: #363a48; color: #e4e5e9; }
@keyframes ofx-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ofx-out { to { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .ofx-toast, .ofx-toast.is-leaving { animation: none; } }
@media (max-width: 575.98px) {
    .ofx-toasts { left: 12px; right: 12px; width: auto; top: calc(70px + var(--ofx-sat)); }
}

/* ---------- Faixas (instalar, atualização, sem conexão) ---------- */
/*
 * Centralizada por left/right + margin auto (e NÃO por transform): a animação de
 * entrada termina em "transform: none" e anulava o translateX(-50%), deixando a
 * faixa pela metade fora da tela no celular (corrigido em 16/10/2026).
 */
.ofx-banner {
    position: fixed;
    z-index: 1085;
    left: 12px;
    right: 12px;
    bottom: calc(16px + var(--ofx-sab));
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px 12px 16px;
    border-radius: 16px;
    background: #1f2433;
    color: #fff;
    box-shadow: 0 16px 40px rgba(20, 24, 40, .28);
    font-size: 13.5px;
    line-height: 1.4;
    animation: ofx-up .28s ease both;
}
.ofx-banner.is-leaving { animation: ofx-down .2s ease both; }
.ofx-banner[data-kind="offline"] { background: #b42318; }
/* flex-basis 0: o texto não ocupa a linha inteira e o × fica ao lado dele no celular */
.ofx-banner-text { flex: 1 1 0%; min-width: 0; overflow-wrap: anywhere; }
.ofx-banner-text strong { display: block; font-size: 14px; }
.ofx-banner-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.ofx-banner-actions button {
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.ofx-banner-actions button.is-primary { background: #7366ff; }
.ofx-banner-close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, .8);
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.ofx-banner-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.ofx-banner button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
body.dark-only .ofx-banner:not([data-kind="offline"]) { background: #33364a; border: 1px solid #4b4f63; box-shadow: 0 16px 40px rgba(0, 0, 0, .45); }
@keyframes ofx-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ofx-down { to { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { .ofx-banner, .ofx-banner.is-leaving { animation: none; } }
@media (max-width: 1199.98px) {
    .ofx-banner { bottom: calc(80px + var(--ofx-sab)); }
    html.kb-open .ofx-banner { bottom: calc(12px + var(--ofx-sab)); }
}
@media (max-width: 575.98px) {
    /* Linha 1: texto + fechar. Linha 2: botões na largura toda. */
    .ofx-banner { flex-wrap: wrap; align-items: flex-start; }
    .ofx-banner-close { order: 1; margin: -4px -2px 0 0; }
    .ofx-banner-actions { order: 2; width: 100%; }
    .ofx-banner-actions button { flex: 1 1 auto; min-height: 44px; }
}

/* ---------- Central de notificações ---------- */
.orca-workflow .notif-tabs .notif-tab-count:not(:empty) {
    display: inline-block;
    min-width: 20px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}
.orca-workflow .notif-center { padding: 0; overflow: hidden; }
.orca-workflow .notif-list { list-style: none; margin: 0; padding: 0; }
.orca-workflow .notif-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid #eef0f5;
}
.orca-workflow .notif-item:last-child { border-bottom: 0; }
.orca-workflow .notif-item.is-unread { background: #f7f6ff; }
.orca-workflow .notif-item.is-new { animation: ofx-in .32s ease both; }
.orca-workflow .notif-dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: transparent; }
.orca-workflow .notif-item.is-unread .notif-dot { background: #7366ff; }
.orca-workflow .notif-body { flex: 1 1 auto; min-width: 0; }
.orca-workflow .notif-title { display: block; font-size: 14.5px; overflow-wrap: anywhere; }
.orca-workflow .notif-item:not(.is-unread) .notif-title { font-weight: 500; }
.orca-workflow .notif-message { margin: 4px 0 0; color: #5d6377; white-space: pre-line; overflow-wrap: anywhere; }
.orca-workflow .notif-time { display: block; margin-top: 6px; font-size: 12px; color: #8a90a2; }
.orca-workflow .notif-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; }
.orca-workflow .notif-actions form { margin: 0; }
.orca-workflow .notif-push-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 20px 4px;
    padding: 12px 14px;
    border: 1px dashed #c9c4ff;
    border-radius: 12px;
    background: #f7f6ff;
}
.orca-workflow .notif-push-cta > div { flex: 1 1 auto; min-width: 0; }
.orca-workflow .notif-push-cta strong { display: block; }
.orca-workflow .notif-push-cta span { font-size: 12.5px; color: #6b7285; }
.orca-workflow .notif-center .pagination:empty { display: none; }
.orca-workflow .notif-center .pagination { padding: 0 20px 16px; }
body.dark-only .orca-workflow .notif-item { border-bottom-color: #383b48; }
body.dark-only .orca-workflow .notif-item.is-unread { background: #2b2e3a; }
body.dark-only .orca-workflow .notif-message { color: #b8bac6; }
body.dark-only .orca-workflow .notif-push-cta { background: #2b2e3a; border-color: #4b4f63; }
body.dark-only .orca-workflow .notif-push-cta span { color: #a3a6b5; }
@media (max-width: 575.98px) {
    .orca-workflow .notif-item { flex-wrap: wrap; padding: 14px 16px; }
    .orca-workflow .notif-actions { width: 100%; padding-left: 23px; }
    .orca-workflow .notif-actions .btn { min-height: 40px; }
    .orca-workflow .notif-push-cta { flex-wrap: wrap; margin: 12px 12px 4px; }
}

/* ---------- Configurações: dispositivo e instalação ---------- */
.orca-workflow .pwa-settings { display: grid; gap: 14px; }
.orca-workflow .pwa-device,
.orca-workflow .pwa-install {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid #eceef5;
    border-radius: 14px;
}
.orca-workflow .pwa-device-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f0fe;
    color: #7366ff;
}
.orca-workflow .pwa-device-copy { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.orca-workflow .pwa-device-copy span { color: #5d6377; overflow-wrap: anywhere; }
.orca-workflow .pwa-device-copy small { overflow-wrap: anywhere; line-height: 1.45; }
.orca-workflow .pwa-device-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.orca-workflow .pwa-device[data-state="on"] .pwa-device-icon { background: #e7f7ee; color: #16a34a; }
.orca-workflow .pwa-device[data-state="denied"] .pwa-device-icon,
.orca-workflow .pwa-device[data-state="unsupported"] .pwa-device-icon { background: #fdecec; color: #dc3545; }
.orca-workflow .pwa-categories-title { margin: 0 0 4px; }
body.dark-only .orca-workflow .pwa-device,
body.dark-only .orca-workflow .pwa-install { border-color: #383b48; }
body.dark-only .orca-workflow .pwa-device-icon { background: #33364a; color: #9d93ff; }
body.dark-only .orca-workflow .pwa-device-copy span { color: #b8bac6; }
@media (max-width: 575.98px) {
    .orca-workflow .pwa-device,
    .orca-workflow .pwa-install { flex-wrap: wrap; }
    .orca-workflow .pwa-device-actions { width: 100%; justify-content: stretch; }
    .orca-workflow .pwa-device-actions .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
}

/* Envio em andamento: evita toque duplo e mostra que algo está acontecendo */
form[data-submitting="1"] button[type="submit"],
form[data-submitting="1"] button:not([type]) { opacity: .7; cursor: progress; }

/*
 * Gaveta "Mais" no celular: toda a altura, ACIMA da barra inferior e com fundo escurecido,
 * como no FutGestor. O seletor anterior perdia para o z-index 9 do tema e a barra cobria o
 * fim do menu (corrigido em 17/10/2026). A lista termina antes da barra de gestos do iPhone.
 */
@media (max-width: 1199.98px) {
    /* left: 0 explícito: com o recuo lateral do conteúdo (deitado), a posição estática deslocaria a gaveta */
    .page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper {
        left: 0;
        padding-top: var(--ofx-sat);
        padding-left: var(--ofx-sal);
    }
    .page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper:not(.close_icon) { z-index: 1040; }
    /* A rolagem do menu (simplebar) vai do topo da gaveta (+70px/+100px do tema) até o fim dela */
    .page-wrapper .sidebar-wrapper .sidebar-links .simplebar-mask { top: calc(100px + var(--ofx-sat)); left: var(--ofx-sal); }
    .page-wrapper .sidebar-wrapper .sidebar-links .simplebar-content-wrapper { padding-bottom: calc(30px + var(--ofx-sab)); }
    /* O tema cria este fundo ao abrir a gaveta, mas sem estilo no layout compacto: ficava invisível */
    .bg-overlay.active {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1035;
        background: rgba(15, 23, 42, .45);
        -webkit-tap-highlight-color: transparent;
        animation: ofx-fade .2s ease both;
    }
}
@media (max-width: 991.98px) {
    .page-wrapper .sidebar-wrapper .sidebar-links .simplebar-mask { top: calc(70px + var(--ofx-sat)); }
}
@keyframes ofx-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bg-overlay.active { animation: none; } }

/* Contador de não lidas no item "Notificações" do menu lateral */
.sidebar-wrapper .sidebar-unread { margin-left: auto; padding: 3px 7px; font-size: 11px; line-height: 1; }
.sidebar-wrapper .sidebar-unread:empty { display: none; }
