/* ==========================================================================
   TINA Live — chamada de voz imersiva (Desktop + Mobile/PWA)
   ========================================================================== */
:root {
    --bg: #05060f;
    --bg-2: #0b0d22;
    --text: #eef0ff;
    --muted: rgba(226, 230, 255, .62);
    --glass: rgba(255, 255, 255, .06);
    --glass-brd: rgba(255, 255, 255, .12);
    --violet: hsl(258 90% 66%);
    --cyan: hsl(186 95% 58%);
    --magenta: hsl(318 88% 64%);
    --green: hsl(152 70% 50%);
    --red: hsl(356 85% 56%);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    height: 100dvh;
    font-family: 'Outfit', system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(120% 80% at 50% 0%, #131638 0%, transparent 60%),
        radial-gradient(90% 70% at 50% 110%, #1a0b2e 0%, transparent 60%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    display: flex;
    flex-direction: column;
}

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.orb-canvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}
.vignette {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(3, 3, 10, .75) 100%);
}

/* ---------- Header ---------- */
.live-header {
    position: relative; z-index: 5;
    display: flex; align-items: center; gap: 14px;
    padding: calc(14px + var(--safe-t)) 20px 10px;
}
.glass-btn {
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: 14px;
    background: var(--glass); border: 1px solid var(--glass-brd);
    color: var(--text); text-decoration: none;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    transition: background .2s, transform .2s;
}
.glass-btn:hover { background: rgba(255,255,255,.12); transform: translateX(-2px); }
.glass-btn svg { width: 20px; height: 20px; }
.brand h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: .02em; }
.brand h1 span {
    background: linear-gradient(90deg, var(--cyan), var(--magenta));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand p { font-size: .8rem; color: var(--muted); }
.call-timer {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-size: .85rem; color: var(--muted);
    padding: 6px 12px; border-radius: 999px;
    background: var(--glass); border: 1px solid var(--glass-brd);
}

/* ---------- Tela inicial ---------- */
.start-screen {
    position: relative; z-index: 3;
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    text-align: center;
    padding: 0 24px calc(48px + var(--safe-b));
    gap: 14px;
    animation: rise .8s cubic-bezier(.2,.8,.2,1) both;
}
.eyebrow { text-transform: uppercase; letter-spacing: .28em; font-size: .72rem; color: var(--cyan); }
.start-screen h2 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 600; line-height: 1.1; }
.start-screen h2 span { color: var(--muted); font-weight: 300; }
.lead { max-width: 440px; color: var(--muted); font-size: .98rem; line-height: 1.5; }
.start-btn {
    position: relative; margin-top: 14px;
    display: inline-flex; align-items: center; gap: 12px;
    padding: 18px 34px; border: 0; border-radius: 999px;
    font: 600 1.05rem 'Outfit', sans-serif; color: #04121a;
    background: linear-gradient(120deg, var(--cyan), hsl(160 85% 55%));
    box-shadow: 0 10px 40px -8px hsla(186, 95%, 58%, .55);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.start-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 16px 50px -8px hsla(186, 95%, 58%, .7); }
.start-btn:active { transform: scale(.97); }
.start-btn:disabled { opacity: .6; cursor: progress; }
.start-ring {
    position: absolute; inset: -6px; border-radius: inherit;
    border: 2px solid hsla(186, 95%, 58%, .45);
    animation: pulseRing 2.2s ease-out infinite;
}
.start-error { min-height: 1.2em; color: hsl(356 90% 72%); font-size: .88rem; }

/* ---------- Tela da chamada ---------- */
.call-screen {
    position: relative; z-index: 3;
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
}
.orb-spacer { flex: 1.15; }
.captions {
    flex: 1;
    display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
    gap: 10px;
    padding: 0 24px 12px;
    text-align: center;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, #000 75%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
}
.caption { max-width: 640px; line-height: 1.45; transition: opacity .4s; }
.caption.user { font-size: .9rem; color: var(--muted); font-style: italic; min-height: 1.3em; }
.caption.ai { font-size: clamp(1.05rem, 2.6vw, 1.35rem); font-weight: 400; }
.caption.fading { opacity: .25; }
.caption .w {
    display: inline-block;
    opacity: 0; filter: blur(6px); transform: translateY(6px);
    animation: wordIn .45s cubic-bezier(.2,.8,.2,1) forwards;
}

/* ---------- Barra de chamada ---------- */
.call-bar {
    position: relative; z-index: 5;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 auto calc(16px + var(--safe-b));
    width: min(520px, calc(100% - 28px));
    padding: 12px 14px;
    border-radius: 28px;
    background: rgba(14, 16, 36, .55);
    border: 1px solid var(--glass-brd);
    backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow: 0 20px 60px -20px rgba(0,0,0,.7);
    animation: rise .6s cubic-bezier(.2,.8,.2,1) both;
}
.bar-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    width: 64px; height: 64px; justify-content: center;
    border: 0; border-radius: 50%;
    color: var(--text); background: rgba(255,255,255,.09);
    cursor: pointer;
    transition: background .2s, transform .15s, color .2s;
}
.bar-btn:hover { background: rgba(255,255,255,.16); }
.bar-btn:active { transform: scale(.92); }
.bar-btn svg { width: 22px; height: 22px; }
.bar-label { font-size: .62rem; letter-spacing: .04em; opacity: .8; }
.bar-btn .ic-mic-off { display: none; }
.bar-btn[aria-pressed="true"] { background: var(--text); color: #0b0d22; }
.bar-btn[aria-pressed="true"] .ic-mic { display: none; }
.bar-btn[aria-pressed="true"] .ic-mic-off { display: block; }
.bar-btn.end { background: var(--red); box-shadow: 0 8px 30px -6px hsla(356, 85%, 56%, .6); }
.bar-btn.end:hover { background: hsl(356 85% 62%); }
.bar-btn.end svg { fill: currentColor; stroke: none; }

.status-pill {
    flex: 1; min-width: 0;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 14px; border-radius: 999px;
    background: rgba(255,255,255,.05);
    font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-pill[data-state="connected"] .status-dot { background: var(--green); }
.status-pill[data-state="listening"] .status-dot { background: var(--cyan); animation: blink 1s ease-in-out infinite; }
.status-pill[data-state="thinking"] .status-dot { background: var(--violet); animation: blink .6s ease-in-out infinite; }
.status-pill[data-state="speaking"] .status-dot { background: var(--magenta); animation: blink .8s ease-in-out infinite; }
.status-pill[data-state="muted"] .status-dot,
.status-pill[data-state="error"] .status-dot { background: var(--red); }
.status-pill[data-state="connecting"] .status-dot { background: #f5c451; animation: blink 1.2s infinite; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; z-index: 20;
    top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%);
    width: min(440px, calc(100% - 24px));
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; gap: 14px; align-items: center;
    padding: 14px 16px; border-radius: 20px;
    background: rgba(16, 20, 44, .82);
    border: 1px solid hsla(152, 70%, 50%, .35);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 18px 50px -12px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.03) inset;
    animation: toastIn .55s cubic-bezier(.2,1.2,.3,1) both;
}
.toast.out { animation: toastOut .4s ease-in forwards; }
.toast.error { border-color: hsla(356, 85%, 56%, .4); }
.toast-icon {
    flex: none; display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 14px;
    background: linear-gradient(135deg, hsl(152 70% 45%), hsl(186 90% 50%));
    color: #031510;
}
.toast.error .toast-icon { background: linear-gradient(135deg, var(--red), var(--magenta)); color: #fff; }
.toast-body { min-width: 0; }
.toast-title { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.toast-protocol { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.toast-desc { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Animações ---------- */
@keyframes wordIn { to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes pulseRing { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-120%) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-120%) scale(.95); } }

@media (min-width: 900px) {
    .live-header { padding: 22px 32px; }
    .bar-btn { width: 70px; height: 70px; }
}
@media (max-height: 560px) {
    .orb-spacer { flex: .9; }
    .start-screen { gap: 8px; padding-bottom: calc(20px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
[hidden] { display: none !important; }
