/* ============================================================
   PICSELL — Mobile foundation
   Safe-areas, touch targets, hover-fix, sheets, bottom-nav,
   skeletons, native-feel utilities. Mobile-first.
   ============================================================ */

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --bottom-nav-h: 64px;
    --bottom-nav-total: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

/* PWA standalone — body padding pra notch */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: var(--safe-top);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
    }
}

/* Quando bottom-nav está presente, empurra conteúdo */
body.has-bottom-nav {
    padding-bottom: var(--bottom-nav-total) !important;
}

/* ============================================================
   TOUCH-FIRST: desativa hover em devices touch, evita "sticky hover"
   ============================================================ */
html.is-touch [class*="hover\\:"]:not(:active):not(:focus-visible) {
    /* deixa hover só em pointer fino (mouse). class is-touch é setada no JS */
}
@media (hover: none) and (pointer: coarse) {
    .hover-only-mouse { display: none !important; }
    /* Sem efeito hover em touch — evita aquela cor que "gruda" depois de tocar */
    a:hover, button:hover { transition: none !important; }
}

/* Touch targets mínimos 44px — Apple HIG / Material */
@media (hover: none) and (pointer: coarse) {
    button, a.btn-primary, a.btn-outline,
    .icon-btn, .nav-item, .ws-trigger,
    input[type="submit"], input[type="button"] {
        min-height: 44px;
    }
}

/* Desativa tap-highlight padrão (azul escuro feio) */
html { -webkit-tap-highlight-color: transparent; }
button, a, [role="button"] { -webkit-tap-highlight-color: rgba(0,0,0,.04); }

/* iOS overscroll bounce só na vertical */
html { overscroll-behavior-x: none; }
body { overscroll-behavior-y: contain; }

/* Sem zoom em input focus no iOS — exige font-size >= 16px */
@media (hover: none) and (pointer: coarse) {
    input[type="text"], input[type="email"], input[type="tel"],
    input[type="number"], input[type="password"], input[type="search"],
    input[type="url"], textarea, select {
        font-size: 16px !important;
    }
}

/* ============================================================
   BOTTOM NAVIGATION (estilo app nativo)
   ============================================================ */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid rgba(15,23,42,0.08);
    padding-bottom: var(--safe-bottom);
    display: flex;
    transition: transform .25s ease;
}
.bottom-nav.hide { transform: translateY(100%); }
.bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; padding: 8px 4px; height: var(--bottom-nav-h);
    font-size: 11px; font-weight: 500; color: #64748b;
    text-decoration: none; position: relative;
    transition: color .15s ease;
}
.bottom-nav-item svg { width: 22px; height: 22px; stroke-width: 1.8; }
.bottom-nav-item.active { color: #7c3aed; }
.bottom-nav-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 3px; border-radius: 0 0 3px 3px;
    background: #7c3aed;
}
.bottom-nav-item .badge {
    position: absolute; top: 4px; right: 22%;
    background: #7c3aed; color: #fff;
    font-size: 9px; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}

/* Esconde no desktop (md:768px+) */
@media (min-width: 768px) {
    .bottom-nav { display: none !important; }
    body.has-bottom-nav { padding-bottom: 0 !important; }
}

/* ============================================================
   SHEET MODAL (sobe de baixo, estilo iOS)
   ============================================================ */
.sheet-overlay {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(0,0,0,0); pointer-events: none;
    transition: background .25s ease;
}
.sheet-overlay.open {
    background: rgba(0,0,0,0.45);
    pointer-events: auto;
}
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 8px 0 calc(20px + var(--safe-bottom));
    max-height: 92vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    box-shadow: 0 -8px 32px rgba(0,0,0,.16);
    -webkit-overflow-scrolling: touch;
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
    width: 40px; height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: 8px auto 12px;
}
.sheet-title {
    padding: 0 20px 12px;
    font-size: 17px; font-weight: 600;
    border-bottom: 1px solid #f1f5f9;
}
.sheet-body { padding: 16px 20px; }

@media (min-width: 768px) {
    /* No desktop, sheets viram modais centralizados */
    .sheet {
        position: relative;
        left: auto; right: auto; bottom: auto;
        max-width: 480px;
        margin: 5vh auto;
        border-radius: 16px;
        transform: none;
        padding-bottom: 20px;
    }
    .sheet-handle { display: none; }
}

/* ============================================================
   SKELETONS — substitui spinners
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-text { height: 12px; margin: 4px 0; }
.skeleton-text.lg { height: 18px; }
.skeleton-text.sm { width: 60%; }
.skeleton-circle { border-radius: 50%; }

/* ============================================================
   PULL-TO-REFRESH indicator
   ============================================================ */
.ptr-indicator {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; justify-content: center; align-items: center;
    height: 56px;
    transform: translateY(-100%);
    transition: transform .2s ease;
    pointer-events: none;
    color: #7c3aed;
    font-size: 12px; font-weight: 600;
}
.ptr-indicator.visible { transform: translateY(0); }
.ptr-spinner {
    width: 20px; height: 20px;
    border: 2px solid #e9d5ff;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: ptr-spin .7s linear infinite;
    margin-right: 8px;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ============================================================
   SWIPE LIGHTBOX — animação de slide horizontal
   ============================================================ */
.lightbox-swipe-hint {
    position: absolute; bottom: 80px; left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.5);
    font-size: 11px; pointer-events: none;
    animation: hint-fade 4s ease-in-out forwards;
}
@keyframes hint-fade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* ============================================================
   HEADER COLAPSÁVEL — esconde ao scrollar pra baixo, mostra ao subir
   ============================================================ */
.site-header {
    transition: transform .25s ease;
    will-change: transform;
}
.site-header.hide-scroll { transform: translateY(-100%); }

/* ============================================================
   IMAGEM EDGE-TO-EDGE no mobile
   ============================================================ */
@media (max-width: 767px) {
    .mobile-edge { margin-left: -16px; margin-right: -16px; border-radius: 0; }
    .mobile-fullbleed { margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }
}

/* ============================================================
   TUTORIAL SPOTLIGHT (Fase 4 — usado no perfil público)
   ============================================================ */
.tour-overlay {
    position: fixed; inset: 0; z-index: 90;
    pointer-events: none;
    background: rgba(15,23,42,0);
    transition: background .3s ease;
}
.tour-overlay.active {
    pointer-events: auto;
    background: rgba(15,23,42,0.86);
}
.tour-spotlight {
    position: fixed; z-index: 91;
    box-shadow:
        0 0 0 9999px rgba(15,23,42,0.86),
        0 0 0 3px #ffffff,
        0 0 0 7px rgba(124,58,237,0.95),
        0 0 0 11px rgba(236,72,153,0.55),
        0 0 28px 4px rgba(124,58,237,0.75),
        0 0 56px 8px rgba(236,72,153,0.40);
    border-radius: 14px;
    pointer-events: none;
    transition: top .35s cubic-bezier(.32,.72,0,1),
                left .35s cubic-bezier(.32,.72,0,1),
                width .35s cubic-bezier(.32,.72,0,1),
                height .35s cubic-bezier(.32,.72,0,1);
    animation: tour-pulse 1.8s ease-in-out infinite;
}
@keyframes tour-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 9999px rgba(15,23,42,0.86),
            0 0 0 3px #ffffff,
            0 0 0 7px rgba(124,58,237,0.95),
            0 0 0 11px rgba(236,72,153,0.55),
            0 0 28px 4px rgba(124,58,237,0.75),
            0 0 56px 8px rgba(236,72,153,0.40);
    }
    50% {
        box-shadow:
            0 0 0 9999px rgba(15,23,42,0.86),
            0 0 0 3px #ffffff,
            0 0 0 9px rgba(124,58,237,1),
            0 0 0 16px rgba(236,72,153,0.70),
            0 0 36px 8px rgba(124,58,237,0.95),
            0 0 72px 14px rgba(6,182,212,0.50);
    }
}
@media (prefers-reduced-motion: reduce) {
    .tour-spotlight { animation: none; }
}
.tour-balloon {
    position: fixed; z-index: 92;
    max-width: 320px;
    background: #fff;
    border-radius: 14px;
    padding: 18px 18px 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,.32);
    transition: all .35s cubic-bezier(.32,.72,0,1);
    color: #0f172a;
}
.tour-balloon h4 {
    font-size: 15px; font-weight: 700; margin-bottom: 6px;
    color: #0f172a;
}
.tour-balloon p {
    font-size: 13.5px; line-height: 1.5; color: #475569; margin: 0;
}
.tour-balloon-controls {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 14px; padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}
.tour-step-counter { font-size: 11px; color: #94a3b8; font-weight: 500; }
.tour-buttons { display: flex; gap: 6px; }
.tour-btn {
    padding: 6px 12px; border-radius: 8px;
    font-size: 12.5px; font-weight: 600;
    border: none; cursor: pointer; transition: all .15s;
}
.tour-btn-skip { background: transparent; color: #64748b; }
.tour-btn-skip:hover { background: #f1f5f9; color: #0f172a; }
.tour-btn-next { background: #7c3aed; color: #fff; }
.tour-btn-next:hover { background: #6d28d9; }

.tour-arrow {
    position: fixed; z-index: 92;
    width: 0; height: 0;
    transition: all .35s cubic-bezier(.32,.72,0,1);
}
.tour-arrow.up    { border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 10px solid #fff; }
.tour-arrow.down  { border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 10px solid #fff; }
.tour-arrow.left  { border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-right: 10px solid #fff; }
.tour-arrow.right { border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 10px solid #fff; }

/* Botão flutuante "?" pra rever tutorial */
.tour-fab {
    position: fixed; right: 16px; bottom: calc(16px + var(--safe-bottom));
    width: 44px; height: 44px;
    background: #7c3aed; color: #fff;
    border-radius: 50%; border: none;
    box-shadow: 0 8px 24px rgba(124,58,237,.42);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 19px; font-weight: 700; font-family: inherit;
    cursor: pointer; z-index: 35;
    transition: transform .2s, box-shadow .2s;
}
.tour-fab:hover { transform: scale(1.06); }
.tour-fab.hidden { transform: scale(0); pointer-events: none; }
@media (min-width: 768px) {
    .tour-fab { right: 24px; bottom: 24px; }
}

/* ============================================================
   INSTALL PROMPT BANNER (PWA)
   ============================================================ */
.install-banner {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(var(--bottom-nav-total) + 12px);
    background: #0f172a; color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    display: none; align-items: center; gap: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,.18);
    z-index: 38;
    transform: translateY(120%);
    transition: transform .3s ease;
}
.install-banner.show { display: flex; transform: translateY(0); }
.install-banner-text { flex: 1; min-width: 0; }
.install-banner-title { font-size: 13px; font-weight: 600; }
.install-banner-sub { font-size: 11px; color: #94a3b8; margin-top: 1px; }
.install-banner-btn {
    background: #7c3aed; color: #fff;
    border: none; border-radius: 8px;
    padding: 8px 14px; font-size: 13px; font-weight: 600;
    cursor: pointer;
}
.install-banner-close {
    background: transparent; color: #94a3b8;
    border: none; padding: 4px 8px;
    font-size: 18px; cursor: pointer;
}

/* ============================================================
   PAINEL — topbar mobile + main padding + bottom-nav coexistência
   ============================================================ */
@media (max-width: 767px) {
    .painel-topbar {
        height: calc(56px + var(--safe-top, 0px)) !important;
        padding-top: var(--safe-top, 0px) !important;
    }
    .painel-main {
        padding-top: calc(56px + var(--safe-top, 0px)) !important;
        padding-bottom: var(--bottom-nav-total) !important;
    }
    /* Botão "Mais" do bottom-nav painel deve parecer link, não button */
    .painel-more-btn {
        background: transparent !important;
        border: none !important;
        font-family: inherit !important;
        cursor: pointer !important;
        width: auto !important;
    }

    /* H1 estilo iOS — grande, bold, sem padding lateral demais */
    .painel-main h1,
    .painel-main h2.section-title {
        font-size: 26px;
        line-height: 1.2;
        font-weight: 800;
        letter-spacing: -0.02em;
    }

    /* TABELAS → CARDS no mobile (truque CSS-only) */
    .painel-main table.mobile-cards {
        display: block;
        background: transparent;
    }
    .painel-main table.mobile-cards thead { display: none; }
    .painel-main table.mobile-cards tbody { display: block; }
    .painel-main table.mobile-cards tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 12px 14px;
        box-shadow: 0 1px 2px rgba(15,23,42,.04);
    }
    .painel-main table.mobile-cards td {
        display: block;
        border: none !important;
        padding: 4px 0 !important;
        text-align: left !important;
    }
    .painel-main table.mobile-cards td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #94a3b8;
        font-weight: 600;
        margin-bottom: 2px;
    }

    /* Cards arredondados estilo iOS */
    .painel-main .bg-white,
    .painel-main .rounded-xl,
    .painel-main .rounded-lg {
        border-radius: 14px !important;
    }
}

/* FAB — Floating Action Button (laranja, canto inferior direito) */
.fab {
    position: fixed !important;
    right: 16px !important;
    bottom: calc(var(--bottom-nav-total) + 16px) !important;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #ec4899, #6d28d9) !important;
    color: #fff !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 24px rgba(124,58,237,.42);
    z-index: 35;
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
    padding: 0;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }
.fab svg { width: 24px !important; height: 24px !important; flex-shrink: 0 !important; }
@media (min-width: 768px) {
    .fab { display: none !important; }
}

/* Garante SVGs do bottom-nav tamanho certo (Tailwind preflight pode estourar) */
.bottom-nav-item svg { width: 22px !important; height: 22px !important; flex-shrink: 0 !important; }

/* Active state do bottom-nav painel — variante laranja brand */
.painel-bottom-nav .bottom-nav-item.active { color: #7c3aed; }
.painel-bottom-nav .bottom-nav-item.active::before { background: #7c3aed; }

/* ============================================================
   OFFLINE BANNER
   ============================================================ */
.offline-banner {
    position: fixed; left: 0; right: 0; top: var(--safe-top); z-index: 100;
    background: #f59e0b; color: #fff;
    text-align: center;
    padding: 6px 12px;
    font-size: 12px; font-weight: 600;
    transform: translateY(-100%);
    transition: transform .25s ease;
}
.offline-banner.show { transform: translateY(0); }
