/* Relatórios PLN — tela inicial com o chat do iahub no centro. */

:root {
    --bg: #f5f6fb;
    --text: #111733;
    --muted: #5a6280;
    --surface: rgba(255, 255, 255, .7);
    --border: rgba(17, 23, 51, .09);
    --accent: #5146e5;
    --accent-2: #0ea59a;
    --accent-3: #e8618c;
    --blob-1: rgba(99, 92, 241, .30);
    --blob-2: rgba(20, 184, 166, .24);
    --blob-3: rgba(236, 104, 150, .18);
    --grid: rgba(17, 23, 51, .045);
    --deco: rgba(81, 70, 229, .22);
    --deco-2: rgba(14, 165, 154, .24);
    --deco-track: rgba(17, 23, 51, .07);
    --card-shadow: 0 40px 90px -40px rgba(32, 40, 110, .45), 0 2px 6px rgba(17, 23, 51, .05);
    --chip-bg: rgba(255, 255, 255, .75);
    --chip-hover: #fff;
    --radius: 22px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1020;
        --text: #e8ebf7;
        --muted: #98a0bd;
        --surface: rgba(22, 28, 52, .6);
        --border: rgba(255, 255, 255, .09);
        --accent: #8b84ff;
        --accent-2: #34d1c2;
        --accent-3: #f07aa3;
        --blob-1: rgba(99, 92, 241, .32);
        --blob-2: rgba(20, 184, 166, .20);
        --blob-3: rgba(236, 104, 150, .16);
        --grid: rgba(255, 255, 255, .04);
        --deco: rgba(139, 132, 255, .28);
        --deco-2: rgba(52, 209, 194, .26);
        --deco-track: rgba(255, 255, 255, .07);
        --card-shadow: 0 40px 90px -40px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .3);
        --chip-bg: rgba(22, 28, 52, .7);
        --chip-hover: rgba(34, 42, 76, .95);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---------- Fundo animado ---------- */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 46vmax;
    height: 46vmax;
    border-radius: 50%;
    filter: blur(70px);
    will-change: transform;
}
.blob-1 { background: var(--blob-1); top: -18vmax; left: -12vmax; animation: drift-1 22s ease-in-out infinite alternate; }
.blob-2 { background: var(--blob-2); bottom: -22vmax; right: -14vmax; animation: drift-2 26s ease-in-out infinite alternate; }
.blob-3 { background: var(--blob-3); top: 30%; left: 55%; width: 30vmax; height: 30vmax; animation: drift-3 30s ease-in-out infinite alternate; }

@keyframes drift-1 { to { transform: translate(14vmax, 10vmax) scale(1.12); } }
@keyframes drift-2 { to { transform: translate(-12vmax, -8vmax) scale(1.08); } }
@keyframes drift-3 { to { transform: translate(-22vmax, 6vmax) scale(.9); } }

.grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

/* Mini-gráficos decorativos nas laterais (somem em telas estreitas) */
.deco { position: absolute; width: 150px; opacity: 0; animation: deco-in 1.2s ease-out .6s forwards; }
.deco-bars    { top: 16%;  left: 5%; }
.deco-donut   { top: 14%;  right: 6%; width: 130px; }
.deco-pie     { bottom: 12%; left: 7%; width: 120px; }
.deco-bubbles { bottom: 14%; right: 5%; }

@keyframes deco-in { to { opacity: 1; } }

.bar {
    fill: var(--deco);
    transform-box: fill-box;
    transform-origin: bottom;
    animation: bar-grow 3.2s ease-in-out var(--d) infinite alternate;
}
@keyframes bar-grow {
    0%   { transform: scaleY(.25); }
    100% { transform: scaleY(1); }
}

.ring-track { fill: none; stroke: var(--deco-track); stroke-width: 12; }
.ring {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transform-origin: 50% 50%;
}
.ring-a { stroke: var(--deco); stroke-dasharray: 46 54; animation: spin 14s linear infinite; }
.ring-b { stroke: var(--deco-2); stroke-dasharray: 22 78; stroke-dashoffset: -52; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pie-base  { fill: var(--deco-track); }
.pie-slice { fill: var(--deco-2); transform-origin: 50% 50%; animation: pie-tilt 9s ease-in-out infinite alternate; }
@keyframes pie-tilt { from { transform: rotate(-20deg); } to { transform: rotate(40deg); } }

.bubble {
    fill: var(--deco);
    transform-box: fill-box;
    transform-origin: center;
    animation: float 6s ease-in-out var(--d) infinite alternate;
}
.bubble:nth-child(2) { fill: var(--deco-2); }
@keyframes float {
    from { transform: translateY(6px) scale(.94); }
    to   { transform: translateY(-8px) scale(1.04); }
}

@media (max-width: 1100px) { .deco { display: none; } }

/* ---------- Topo ---------- */

.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px clamp(16px, 4vw, 40px);
    animation: fade-down .7s ease-out both;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; fill: var(--accent); }
.brand-mark rect:nth-child(2) { fill: var(--accent-2); }
.brand-mark rect:nth-child(3) { fill: var(--accent-3); }
.brand-name { font-size: 1.05rem; letter-spacing: -.01em; }
.brand-name strong { font-weight: 700; }

.tag {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
}

/* ---------- Centro ---------- */

.stage {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 4px 16px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.intro { text-align: center; max-width: 640px; animation: fade-up .8s ease-out .1s both; }

.intro h1 {
    margin: 0 0 8px;
    font-size: clamp(1.45rem, 3.2vw, 2.15rem);
    line-height: 1.15;
    letter-spacing: -.025em;
    font-weight: 750;
}

.grad {
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 8s linear infinite;
}
@keyframes shimmer { to { background-position: 300% 0; } }

.intro p { margin: 0; color: var(--muted); font-size: clamp(.92rem, 1.6vw, 1rem); line-height: 1.55; }

/* Cartão do chat — borda em gradiente girando devagar */
.chat-card {
    position: relative;
    width: 100%;
    max-width: 880px;
    border-radius: var(--radius);
    padding: 1.5px;
    background: var(--border);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    isolation: isolate;
    animation: card-in .9s cubic-bezier(.2, .8, .2, 1) .2s both;
}
.chat-card::before {
    content: "";
    position: absolute;
    inset: -50%;
    z-index: -1;
    background: conic-gradient(from 0deg, transparent 0 55%, var(--accent) 70%, var(--accent-2) 82%, var(--accent-3) 92%, transparent 100%);
    animation: spin 7s linear infinite;
}

.chat-frame {
    position: relative;
    height: min(68dvh, 680px);
    min-height: 420px;
    border-radius: calc(var(--radius) - 1.5px);
    background: #f8f9fa; /* mesmo fundo da página do chat do iahub, sem "piscar" ao carregar */
    overflow: hidden;
}

.chat-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    opacity: 0;
    transition: opacity .5s ease;
}
.chat-frame.is-loaded iframe { opacity: 1; }

/* Espaço reservado enquanto o iframe não foi configurado / está carregando */
.placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: clamp(20px, 5vw, 56px);
    color: #5a6280;
    transition: opacity .4s ease;
}
.chat-frame.is-loaded .placeholder { opacity: 0; pointer-events: none; }

.ph-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: .95rem;
    line-height: 1.4;
    animation: fade-up .6s ease-out both;
}
.ph-out { align-self: flex-end; background: #5146e5; color: #fff; border-bottom-right-radius: 6px; animation-delay: .7s; }
.ph-in  { align-self: flex-start; background: #fff; border: 1px solid #e7e9f2; border-bottom-left-radius: 6px; animation-delay: 1s; }

.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i {
    width: 7px; height: 7px; border-radius: 50%;
    background: #9aa1bb;
    animation: typing 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

.ph-chart {
    align-self: flex-start;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 110px;
    width: min(280px, 70%);
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e7e9f2;
    border-radius: 16px;
    animation: fade-up .6s ease-out 1.3s both;
}
.ph-chart span {
    flex: 1;
    height: var(--h);
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, #7c74ff, #5146e5);
    transform-origin: bottom;
    animation: bar-rise 1s cubic-bezier(.2, .8, .2, 1) both;
}
.ph-chart span:nth-child(1) { animation-delay: 1.5s; }
.ph-chart span:nth-child(2) { animation-delay: 1.6s; background: linear-gradient(180deg, #3fd4c6, #0ea59a); }
.ph-chart span:nth-child(3) { animation-delay: 1.7s; }
.ph-chart span:nth-child(4) { animation-delay: 1.8s; background: linear-gradient(180deg, #f59ab9, #e8618c); }
.ph-chart span:nth-child(5) { animation-delay: 1.9s; }
@keyframes bar-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.ph-note {
    margin: 6px 0 0;
    text-align: center;
    font-size: .85rem;
    color: #8a90a8;
    animation: fade-up .6s ease-out 2.1s both;
}

/* Exemplos */
.examples {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: fade-up .8s ease-out .45s both;
}
.examples-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.examples ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.chip {
    font: inherit;
    font-size: .88rem;
    color: var(--text);
    background: var(--chip-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.chip:hover { transform: translateY(-2px); background: var(--chip-hover); border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Aviso de "copiado" */
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10;
    transform: translate(-50%, 20px);
    opacity: 0;
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font-size: .88rem;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Entradas */
@keyframes fade-up   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes card-in   { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }

/* Celular: o chat ocupa quase toda a altura */
@media (max-width: 640px) {
    .topbar { padding: 14px 16px; }
    .stage { gap: 14px; padding-bottom: 20px; }
    .intro p { display: none; }
    .chat-frame { height: calc(100dvh - 190px); min-height: 380px; }
    .ph-bubble { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .chat-card::before { animation: none; }
}
