/* ============================================================
   FluxoDev — motion.css
   Paleta dark + keyframes da identidade visual.
   ============================================================ */

:root {
    --bg:           #0a0a0f;
    --surface:      #13131a;
    --surface-2:    #1a1a24;
    --surface-3:    #20202c;
    --border:       rgba(255, 255, 255, 0.06);
    --border-strong:rgba(255, 255, 255, 0.12);
    --text:         #f4f4f5;
    --text-muted:   #a1a1aa;
    --text-dim:     #71717a;

    --status-rascunho:               #71717a;
    --status-aguardando_analise:     #f59e0b;
    --status-aguardando_esclarecimento: #a855f7;
    --status-aceita:                 #06b6d4;
    --status-em_desenvolvimento:     #06b6d4;
    --status-concluida:              #3b82f6;
    --status-em_revisao:             #3b82f6;
    --status-ajustes_solicitados:    #f97316;
    --status-aprovada:               #10b981;

    --accent-from: #06b6d4;
    --accent-via:  #3b82f6;
    --accent-to:   #8b5cf6;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    min-height: 100vh;
}

/* PWA fullscreen/standalone — só safe-area, sem mexer em overflow (scroll precisa fluir) */
@media all and (display-mode: standalone), all and (display-mode: fullscreen) {
    /* Navbar superior: respeita status bar/notch (somente padding, sem alterar height) */
    nav.fixed.top-0,
    header.fixed.top-0 {
        padding-top: env(safe-area-inset-top, 0);
    }
    /* Empurra o main mais abaixo pra acomodar a navbar com safe-area-inset extra */
    main {
        padding-top: calc(56px + env(safe-area-inset-top, 0)) !important;
    }
    @media (min-width: 640px) {
        main {
            padding-top: calc(64px + env(safe-area-inset-top, 0)) !important;
        }
    }
    /* Bottom-nav: respeita home indicator (j\u00e1 tem env() inline mas refor\u00e7a aqui) */
    #bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* Fundo com glow ambiente — extends edge-to-edge, inclui faixa do status bar */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    /* Sobe além do topo do viewport pro glow alcançar a área da status bar (PWA fullscreen + iOS notch) */
    top: calc(-1 * env(safe-area-inset-top, 0));
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 15% 10%, rgba(6, 182, 212, 0.12), transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.12), transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(59, 130, 246, 0.06), transparent 50%);
}

/* Scrollbars escuros */
::-webkit-scrollbar             { width: 10px; height: 10px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: rgba(255,255,255,0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ---------- Cards (vidro escuro) ---------- */
.card-glass {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.005));
    border: 1px solid var(--border);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
@media (min-width: 640px) {
    .card-glass { border-radius: 16px; }
}
.card-glass:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}
@media (max-width: 1023px) {
    .card-glass:hover { transform: none; } /* sem hover-lift no mobile */
}

/* ---------- Status helpers (cor + glow) ---------- */
.status-rascunho               { --c: var(--status-rascunho); }
.status-aguardando_analise     { --c: var(--status-aguardando_analise); }
.status-aguardando_esclarecimento { --c: var(--status-aguardando_esclarecimento); }
.status-aceita                 { --c: var(--status-aceita); }
.status-em_desenvolvimento     { --c: var(--status-em_desenvolvimento); }
.status-concluida              { --c: var(--status-concluida); }
.status-em_revisao             { --c: var(--status-em_revisao); }
.status-ajustes_solicitados    { --c: var(--status-ajustes_solicitados); }
.status-aprovada               { --c: var(--status-aprovada); }

.dot-status {
    width: 10px; height: 10px; border-radius: 999px;
    background: var(--c);
    box-shadow: 0 0 12px var(--c);
}

.bar-status {
    height: 3px; border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--c), transparent);
    background-size: 200% 100%;
    animation: bar-flow 2.4s linear infinite;
}

@keyframes bar-flow {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Pulse para card recém-chegado ---------- */
.pulse-incoming {
    position: relative;
    animation: pulse-incoming 1.6s ease-in-out infinite;
}
@keyframes pulse-incoming {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent), 0 8px 32px rgba(0,0,0,0.35); }
    50%      { box-shadow: 0 0 0 14px color-mix(in srgb, var(--c) 0%, transparent), 0 8px 32px rgba(0,0,0,0.55); }
}

/* ---------- Slide-in stagger ---------- */
@keyframes slide-in-card {
    from { opacity: 0; transform: translateY(12px) scale(.98); filter: blur(4px); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   filter: blur(0); }
}
.slide-in       { animation: slide-in-card .55s cubic-bezier(.2,.8,.2,1) both; }
.stagger-1 { animation-delay: 60ms; }
.stagger-2 { animation-delay: 120ms; }
.stagger-3 { animation-delay: 180ms; }
.stagger-4 { animation-delay: 240ms; }
.stagger-5 { animation-delay: 300ms; }
.stagger-6 { animation-delay: 360ms; }

/* ---------- Glow breath (botões/CTA primário) ---------- */
.glow-breath {
    background: linear-gradient(120deg, var(--accent-from), var(--accent-via), var(--accent-to));
    background-size: 200% 200%;
    animation: glow-breath 5s ease-in-out infinite;
    box-shadow: 0 0 24px rgba(6, 182, 212, 0.35), 0 8px 24px rgba(0,0,0,.35);
}
@keyframes glow-breath {
    0%,100% { background-position: 0% 50%; }
    50%     { background-position: 100% 50%; }
}

/* ---------- Particle burst (após aceitar/concluir) ---------- */
.particle-burst {
    position: absolute; inset: 0; pointer-events: none; overflow: visible;
}
.particle-burst span {
    position: absolute; left: 50%; top: 50%;
    width: 6px; height: 6px; border-radius: 999px;
    background: var(--c, #10b981);
    box-shadow: 0 0 12px var(--c, #10b981);
    animation: particle-fly .8s ease-out forwards;
}
@keyframes particle-fly {
    0%   { transform: translate(-50%,-50%) scale(.6); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(0); opacity: 0; }
}

/* ---------- Badge animado da topbar ---------- */
.notif-ring {
    position: relative;
}
.notif-ring::after {
    content: '';
    position: absolute; inset: -4px;
    border-radius: 999px;
    border: 2px solid color-mix(in srgb, var(--accent-from) 80%, transparent);
    animation: notif-ring 1.6s ease-out infinite;
}
@keyframes notif-ring {
    0%   { transform: scale(.8); opacity: .9; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ---------- Pulse engine SVG overlay ---------- */
#pulse-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 90;
    overflow: visible;
}
.pulse-trail {
    fill: none;
    stroke: url(#pulse-grad);
    stroke-width: 2;
    stroke-linecap: round;
    filter: drop-shadow(0 0 8px rgba(6,182,212,.7));
    stroke-dasharray: 8 14;
    animation: pulse-dash .9s linear forwards;
}
@keyframes pulse-dash {
    from { stroke-dashoffset: 220; opacity: 1; }
    to   { stroke-dashoffset: 0;   opacity: 0; }
}
.pulse-particle {
    fill: #67e8f9;
    filter: drop-shadow(0 0 14px #06b6d4) drop-shadow(0 0 22px #8b5cf6);
}

/* ---------- Wizard progress ---------- */
.wizard-progress-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--accent-from), var(--accent-via), var(--accent-to));
    background-size: 200% 100%;
    animation: glow-breath 4s ease-in-out infinite;
    transition: width .4s cubic-bezier(.2,.8,.2,1);
    border-radius: 999px;
}

/* ---------- Inputs escuros ---------- */
.input-dark, textarea.input-dark, select.input-dark {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 16px; /* ≥16px previne zoom no iOS */
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
@media (min-width: 640px) {
    .input-dark, textarea.input-dark, select.input-dark { font-size: 14px; }
}
.input-dark:focus, textarea.input-dark:focus, select.input-dark:focus {
    outline: none;
    border-color: var(--accent-from);
    box-shadow: 0 0 0 3px rgba(6,182,212,0.18);
    background: var(--surface-3);
}
.input-dark::placeholder, textarea.input-dark::placeholder { color: var(--text-dim); }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px;
    font-weight: 600; font-size: 14px; line-height: 1;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: transform .15s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.btn:hover    { transform: translateY(-1px); background: var(--surface-3); border-color: var(--border-strong); }
.btn:active   { transform: translateY(0); }
.btn-primary  { background: linear-gradient(120deg, var(--accent-from), var(--accent-via), var(--accent-to)); background-size: 200% 200%; border: none; color: #fff; box-shadow: 0 0 24px rgba(6,182,212,.30); animation: glow-breath 6s ease-in-out infinite; }
.btn-primary:hover { box-shadow: 0 0 28px rgba(139,92,246,.45); }
.btn-ghost    { background: transparent; }
.btn-danger   { background: linear-gradient(120deg, #ef4444, #f97316); border: none; color: #fff; }

/* ---------- Avatar ---------- */
.avatar {
    width: 36px; height: 36px; border-radius: 999px;
    background: linear-gradient(135deg, var(--accent-from), var(--accent-to));
    color: #fff; font-weight: 700; font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 0 12px rgba(6,182,212,.3);
}

/* ---------- Chip ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    line-height: 1.4;
    white-space: nowrap;
    background: color-mix(in srgb, var(--c, #71717a) 18%, transparent);
    color: var(--c, var(--text));
    border: 1px solid color-mix(in srgb, var(--c, #71717a) 35%, transparent);
}

/* ---------- Navbar (horizontal) ---------- */
.navbar-link {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 10px;
    color: var(--text-muted); font-size: 13px; font-weight: 600;
    transition: background .2s ease, color .2s ease;
    text-decoration: none;
}
.navbar-link:hover { background: rgba(255,255,255,.04); color: var(--text); }
.navbar-link.active {
    background: linear-gradient(120deg, rgba(6,182,212,.18), rgba(139,92,246,.18));
    color: var(--text);
    border: 1px solid rgba(6,182,212,.35);
}

/* ---------- Bottom nav (mobile) ---------- */
/* Esconde a barra inferior quando teclado abre (qualquer input/textarea com foco no mobile) */
body.keyboard-open #bottom-nav,
body.keyboard-open #fab-captura-bottom {
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}
#bottom-nav, #fab-captura-bottom {
    transition: transform .25s ease, opacity .25s ease;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: color .2s ease, transform .15s ease;
    position: relative;
}
.bottom-nav-item i { font-size: 18px; line-height: 1; }
.bottom-nav-item:active { transform: scale(.95); }
.bottom-nav-item.active {
    color: #f4f4f5;
}
.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px; height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #06b6d4, #8b5cf6);
    box-shadow: 0 0 12px rgba(6,182,212,.6);
}
.bottom-nav-item.active i {
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Espaçador onde o FAB central se encaixa */
.bottom-nav-spacer { flex: 1; }

/* FAB destacado no centro do bottom-nav */
.bottom-nav-fab {
    position: absolute;
    left: 50%;
    top: -22px;
    transform: translateX(-50%);
    width: 64px; height: 64px;
    border-radius: 9999px;
    border: 4px solid var(--bg);
    background: linear-gradient(135deg, #06b6d4, #3b82f6, #8b5cf6);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 32px rgba(6,182,212,.55), 0 12px 28px rgba(0,0,0,.5);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .25s ease;
    z-index: 2;
}
.bottom-nav-fab i { font-size: 26px; }
.bottom-nav-fab:active { transform: translateX(-50%) scale(.92); }
.bottom-nav-fab:hover { box-shadow: 0 0 40px rgba(139,92,246,.7), 0 12px 32px rgba(0,0,0,.5); }
.bottom-nav-fab::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 9999px;
    border: 2px solid rgba(6,182,212,.35);
    animation: notif-ring 2.2s ease-out infinite;
    pointer-events: none;
}

/* ---------- User-menu dropdown links ---------- */
.user-menu-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--text-muted); font-size: 13px; font-weight: 500;
    transition: background .2s ease, color .2s ease;
    text-decoration: none;
}
.user-menu-link:hover { background: rgba(255,255,255,.05); color: var(--text); }
.user-menu-link.active {
    background: linear-gradient(120deg, rgba(6,182,212,.18), rgba(139,92,246,.18));
    color: var(--text);
}

/* ---------- Timeline vertical ---------- */
.timeline-item {
    position: relative; padding-left: 28px;
    animation: slide-in-card .5s cubic-bezier(.2,.8,.2,1) both;
}
.timeline-item::before {
    content: ''; position: absolute; left: 6px; top: 8px; bottom: -16px;
    width: 2px; background: linear-gradient(to bottom, var(--c, var(--border-strong)), transparent);
}
.timeline-item .tl-dot {
    position: absolute; left: 0; top: 4px; width: 14px; height: 14px;
    border-radius: 999px; background: var(--c, var(--border-strong));
    box-shadow: 0 0 10px var(--c, transparent);
}
.timeline-item:last-child::before { display: none; }

/* ---------- Splash / loading ---------- */
.splash {
    position: fixed; inset: 0; display: grid; place-items: center;
    background: var(--bg); z-index: 9999;
}
.splash .logo {
    height: 96px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 32px rgba(6,182,212,.5));
    animation: glow-breath 3s ease-in-out infinite;
}
