/* ============ IDENTIDADE WECARE ============ */
:root {
  --preto: #08080B;
  --grafite: #18181D;
  --grafite-2: #222229;
  --grafite-3: #2C2C34;
  --vermelho: #C91830;
  --vermelho-luz: #E52740;
  --branco: #FFFFFF;
  --cinza: #A8A8B3;
  --verde: #2FD27F;

  --app-h: 100vh;
  --pv-space: 0px;

  /* tamanho do aparelho no computador: 9 x 19,5 */
  --dev-w: min(410px, calc((var(--app-h) - 64px - var(--pv-space)) * 0.4615), calc(100vw - 32px));
  --dev-h: calc(var(--dev-w) * 2.1667);
  --r: calc(var(--dev-w) * 0.135);
  --metal: 3px;
  --bezel: calc(var(--dev-w) * 0.026);

  color-scheme: dark;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--preto);
  color: var(--branco);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
textarea { font: inherit; }

/* ============ FUNDO (estudio) ============ */
.stage {
  position: fixed; inset: 0;
  height: var(--app-h);
  display: flex; align-items: center; justify-content: center;
  padding-bottom: var(--pv-space);
  background:
    radial-gradient(120% 80% at 50% 0%, #1a1a20 0%, transparent 60%),
    linear-gradient(180deg, #0d0d11 0%, var(--preto) 55%, #050507 100%);
  overflow: hidden;
  perspective: 1600px;
}
.bg-glow {
  position: absolute; left: 50%; top: 46%;
  width: min(900px, 160vw); height: min(900px, 160vw);
  transform: translate(-50%, -50%);
  background:
    radial-gradient(closest-side, rgba(229, 39, 64, .26), rgba(201, 24, 48, .10) 45%, transparent 72%);
  filter: blur(8px);
  pointer-events: none;
  animation: breathe 9s ease-in-out infinite;
}
.bg-floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 38%;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255,255,255,.035), transparent 70%);
  pointer-events: none;
}
.bg-mark {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: min(26vw, 340px);
  letter-spacing: -.06em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255,255,255,.035);
  white-space: nowrap;
  user-select: none; pointer-events: none;
}
@keyframes breathe { 0%,100% { opacity: .85; } 50% { opacity: 1; } }

/* ============ APARELHO ============ */
.device-wrap {
  position: relative;
  transform-style: preserve-3d;
  animation: rise 1.1s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(28px) scale(.965) rotateX(6deg); }
  to   { opacity: 1; transform: none; }
}
.device {
  position: relative;
  width: var(--dev-w); height: var(--dev-h);
  border-radius: var(--r);
  padding: var(--metal);
  /* moldura em titanio grafite */
  background:
    linear-gradient(90deg, rgba(229,39,64,.35) 0%, transparent 9%, transparent 91%, rgba(255,255,255,.10) 100%),
    linear-gradient(160deg, #4a4a53 0%, #1b1b20 18%, #34343c 42%, #121216 64%, #3c3c45 86%, #1a1a1f 100%);
  box-shadow:
    0 0 0 1px rgba(0,0,0,.9),
    inset 0 0 0 1px rgba(255,255,255,.10),
    inset 0 1px 0 rgba(255,255,255,.18),
    0 50px 90px -30px rgba(0,0,0,.95),
    0 22px 40px -18px rgba(0,0,0,.8),
    -26px 0 70px -40px rgba(229,39,64,.55);
  transition: transform .5s var(--ease);
  will-change: transform;
}
.hw {
  position: absolute; right: calc(var(--metal) * -1 - 1px);
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, #26262c, #4b4b55 60%, #1c1c21);
  box-shadow: 1px 0 1px rgba(0,0,0,.6);
}
.hw-vol { top: 22%; height: 15%; }
.hw-power { top: 41%; height: 8%; }

.bezel {
  position: relative;
  width: 100%; height: 100%;
  border-radius: calc(var(--r) - var(--metal));
  padding: var(--bezel);
  background: #020203;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: calc(var(--r) - var(--metal) - var(--bezel) + 2px);
  overflow: hidden;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 50% at 50% 0%, rgba(201,24,48,.10), transparent 60%),
    linear-gradient(180deg, #0f0f13 0%, #0a0a0d 100%);
  isolation: isolate;
}
.glass {
  position: absolute; inset: var(--bezel);
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(118deg, rgba(255,255,255,.07) 0%, rgba(255,255,255,.02) 22%, transparent 38%);
  mix-blend-mode: screen;
  border-radius: calc(var(--r) - var(--metal) - var(--bezel) + 2px);
}
.device-shadow {
  position: absolute; left: 12%; right: 12%; bottom: -26px; height: 40px;
  background: radial-gradient(closest-side, rgba(0,0,0,.85), transparent);
  filter: blur(6px);
  z-index: -1;
}

/* ============ BARRA DE STATUS ============ */
.statusbar {
  position: relative; flex: none;
  height: 34px; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  color: rgba(255,255,255,.92);
}
.sb-camera {
  position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a2f45 0 18%, #07070a 30%, #000 100%);
  box-shadow: 0 0 0 1.5px #000, inset 0 0 0 1px rgba(255,255,255,.07);
}
.sb-icons { display: inline-flex; gap: 6px; align-items: center; fill: currentColor; }

/* ============ REGIAO A: CABECALHO ============ */
.agent {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent);
  position: relative; z-index: 2;
}
.avatar {
  position: relative; flex: none;
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
}
.avatar-ring {
  position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(from 210deg, #7a0f1d, var(--vermelho-luz), #ff8a98 18%, var(--vermelho) 35%, #5c0b16 60%, var(--vermelho-luz) 85%, #7a0f1d);
  box-shadow: 0 4px 14px -4px rgba(229,39,64,.7), inset 0 1px 1px rgba(255,255,255,.35);
}
.avatar-ring::after {
  content: ''; position: absolute; inset: 2.5px; border-radius: 50%;
  background: #0d0d10;
}
.avatar img, .avatar-initial {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
}
.avatar img { object-fit: cover; }
.avatar-initial {
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2a2a31, #18181d);
  font-weight: 700; font-size: 19px; color: #fff;
}
.agent-info { min-width: 0; }
.agent-name {
  margin: 0; font-size: 16.5px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent-sep { color: var(--vermelho-luz); margin: 0 6px; font-weight: 500; }
.agent-brand { font-weight: 800; }
.agent-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--cinza); }
.agent-status {
  margin: 4px 0 0; font-size: 11.5px; color: #cfcfd6;
  display: flex; align-items: center; gap: 6px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--verde);
  box-shadow: 0 0 0 0 rgba(47,210,127,.6);
  animation: ping 2.4s ease-out infinite;
}
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(47,210,127,.55); } 70%,100% { box-shadow: 0 0 0 6px rgba(47,210,127,0); } }

/* ============ REGIAO B: CONVERSA ============ */
.chat {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent;
}
.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }
.chat-inner {
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 14px 14px 10px;
}
.day-chip, .sys-chip {
  align-self: center;
  font-size: 11px; font-weight: 600; color: var(--cinza);
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.04);
  margin: 4px 0 12px;
}
.sys-chip {
  max-width: 86%; text-align: center; line-height: 1.45;
  border: 1px solid rgba(255,255,255,.06);
  animation: fadeIn .4s var(--ease) both;
  margin: 10px 0;
}

.msg {
  display: flex; flex-direction: column;
  max-width: 80%;
  margin-top: 3px;
  animation: msgIn .38s var(--ease) both;
}
.msg.first { margin-top: 12px; }
.msg.from-ia { align-self: flex-start; align-items: flex-start; }
.msg.from-cliente { align-self: flex-end; align-items: flex-end; animation-name: msgOut; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes msgOut { from { opacity: 0; transform: translate(10px, 12px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bubble {
  padding: 10px 14px;
  font-size: 14.5px; line-height: 1.45;
  border-radius: 20px;
  word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.from-ia .bubble {
  background: var(--grafite-2);
  border: 1px solid rgba(255,255,255,.05);
  border-bottom-left-radius: 6px;
}
.from-ia.cont .bubble { border-top-left-radius: 6px; }
.from-cliente .bubble {
  background: linear-gradient(160deg, var(--vermelho-luz), var(--vermelho) 70%);
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 16px -10px rgba(229,39,64,.9);
}
.from-cliente.cont .bubble { border-top-right-radius: 6px; }
.from-ia .row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.mini-av {
  flex: none; width: 26px; height: 26px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--grafite-3);
  box-shadow: 0 0 0 1.5px rgba(229,39,64,.55);
  visibility: hidden;
}
.mini-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.from-ia.last:not(.hide-av) .mini-av { visibility: visible; }
.msg.from-ia { max-width: calc(80% + 34px); }
.from-ia .meta { margin-left: 40px; }
.meta {
  font-size: 10.5px; color: rgba(168,168,179,.75);
  margin: 4px 6px 0;
}
.msg:not(.last) .meta { display: none; }

/* digitando */
.typing .bubble {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 13px 15px;
}
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--cinza);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* player de audio */
.audio {
  display: flex; align-items: center; gap: 10px;
  min-width: 210px; padding: 9px 14px 9px 9px !important;
  white-space: normal !important;
}
.audio-play {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12);
  transition: transform .15s;
}
.from-cliente .audio-play { background: rgba(255,255,255,.22); }
.audio-play:active { transform: scale(.92); }
.audio-bars {
  flex: 1; height: 28px;
  display: flex; align-items: center; gap: 2px; cursor: pointer;
}
.audio-bars span {
  flex: 1; min-width: 2px; border-radius: 2px;
  background: rgba(255,255,255,.28);
  transition: background .1s;
}
.audio-bars span.on { background: #fff; }
.audio-time { flex: none; font-size: 11.5px; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.75); min-width: 30px; text-align: right; }

/* cartao de pedido */
.order { padding: 14px 14px 12px !important; min-width: 230px; white-space: normal !important; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.order-title { font-weight: 700; font-size: 14px; }
.order-num { font-size: 11px; color: var(--cinza); }
.order-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 7px 0; border-top: 1px solid rgba(255,255,255,.06); }
.order-item small { display: block; color: var(--cinza); font-size: 11.5px; }
.order-total { display: flex; justify-content: space-between; font-weight: 700; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 2px; }
.order-total b { color: var(--vermelho-luz); }
.order-note { margin-top: 8px; font-size: 11px; color: var(--cinza); line-height: 1.4; }

/* aviso */
.toast {
  position: absolute; left: 14px; right: 14px; top: 112px; z-index: 5;
  padding: 10px 14px; border-radius: 14px;
  font-size: 12.5px; line-height: 1.4; text-align: center;
  background: rgba(30,30,36,.96);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.8);
  animation: msgIn .3s var(--ease) both;
}

/* ============ REGIAO D: CAMPO DE DIGITACAO ============ */
.composer {
  flex: none; position: relative; z-index: 2;
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(255,255,255,.05);
  background: linear-gradient(0deg, #0b0b0e, rgba(11,11,14,.92));
}
.compose-row, .rec-row { display: flex; align-items: flex-end; gap: 8px; }
.rec-row { align-items: center; }
.field {
  flex: 1; min-width: 0;
  display: flex; align-items: flex-end;
  background: var(--grafite);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 22px;
  padding: 3px 4px 3px 16px;
  transition: border-color .2s, box-shadow .2s;
}
.field:focus-within { border-color: rgba(229,39,64,.45); box-shadow: 0 0 0 3px rgba(229,39,64,.10); }
.field textarea {
  flex: 1; min-width: 0;
  resize: none; border: 0; outline: 0; background: transparent;
  color: #fff; font-size: 16px; line-height: 22px;
  padding: 8px 0; max-height: 96px;
}
.field textarea::placeholder { color: #75757f; }
.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; color: #d6d6dc;
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.icon-btn:active { transform: scale(.9); }
.send {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, var(--vermelho-luz), var(--vermelho));
  box-shadow: 0 6px 18px -6px rgba(229,39,64,.8), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .18s var(--ease), opacity .2s, filter .2s;
}
.send:disabled { opacity: .35; box-shadow: none; filter: grayscale(.4); cursor: default; }
.send:not(:disabled):active, .send.pop { transform: scale(.86); }
.send.fly svg { animation: fly .45s var(--ease); }
@keyframes fly { 0% { transform: none; } 45% { transform: translateY(-14px); opacity: 0; } 46% { transform: translateY(12px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* gravacao */
.composer.recording .compose-row { display: none; }
.composer.recording .rec-row { display: flex; }
.rec-row[hidden] { display: none; }
.rec-body {
  flex: 1; min-width: 0; height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; border-radius: 22px;
  background: var(--grafite);
  border: 1px solid rgba(229,39,64,.35);
  animation: fadeIn .25s both;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--vermelho-luz); animation: recPulse 1.1s infinite; }
@keyframes recPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
.rec-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 34px; }
.rec-wave { flex: 1; height: 24px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.rec-wave span { flex: 1; min-width: 2px; border-radius: 2px; background: rgba(229,39,64,.85); height: 3px; transition: height .08s linear; }
.rec-cancel { color: var(--cinza); }

/* rodape legal */
.legal { margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.04); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.legal-line { margin: 0; font-size: 10.5px; line-height: 1.35; color: #8a8a95; }
.link { color: #d9d9e0; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(255,255,255,.3); font-size: inherit; }
.company { margin: 0; font-size: 9.5px; color: #6e6e78; letter-spacing: .01em; }
body.kb .legal { display: none; }

/* folha de termos */
.sheet-backdrop { position: absolute; inset: 0; z-index: 8; background: rgba(0,0,0,.55); animation: fadeIn .25s both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  max-height: 82%; display: flex; flex-direction: column;
  background: #141418; border-top: 1px solid rgba(255,255,255,.08);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 40px -10px rgba(0,0,0,.7);
  animation: sheetUp .35s var(--ease) both;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 16px 10px 8px 20px; }
.sheet-grip { position: absolute; left: 50%; top: 7px; transform: translateX(-50%); width: 36px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.18); }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 22px; font-size: 13px; line-height: 1.55; color: #cfcfd6; }
.sheet-body h3 { font-size: 13.5px; color: #fff; margin: 14px 0 6px; }
.sheet-body p { margin: 0 0 8px; }
.sheet-body b { color: #fff; font-weight: 600; }
.sheet-company { margin-top: 16px !important; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11.5px; color: var(--cinza); }

.home-bar {
  flex: none; height: 16px; display: flex; justify-content: center; align-items: flex-start;
  background: #0b0b0e;
}
.home-bar::before { content: ''; width: 32%; height: 4px; border-radius: 4px; background: rgba(255,255,255,.32); }

/* ============ BARRA DE PREVIA ============ */
.preview {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  background: rgba(24,24,29,.85);
  border: 1px solid rgba(255,255,255,.07);
  backdrop-filter: blur(10px);
  font-size: 12px;
  max-width: calc(100vw - 16px);
}
.pv-label { color: var(--cinza); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; }
.pv-links { display: flex; gap: 2px; background: rgba(0,0,0,.35); border-radius: 999px; padding: 2px; }
.pv-links button { padding: 5px 10px; border-radius: 999px; color: var(--cinza); font-weight: 600; }
.pv-links button.on { background: var(--grafite-3); color: #fff; }
.pv-btn { padding: 6px 12px; border-radius: 999px; background: var(--vermelho); font-weight: 700; }
.pv-btn.ghost { background: transparent; color: var(--cinza); }
.pv-btn:hover { filter: brightness(1.1); }
.pv-short { display: none; }

/* ============ CELULAR DO CLIENTE ============ */
@media (max-width: 560px) {
  :root {
    --dev-w: calc(100vw - 14px);
    --dev-h: calc(var(--app-h) - 14px - var(--pv-space));
    --r: 34px;
    --metal: 2.5px;
    --bezel: 5px;
  }
  .stage { padding-top: 0; }
  .device-shadow, .bg-mark { display: none; }
  .hw { display: none; }
  .statusbar { height: 26px; padding: 0 18px; font-size: 12px; }
  .sb-camera { top: 7px; width: 10px; height: 10px; }
  .agent { padding: 4px 14px 11px; }
  .chat-inner { padding: 10px 10px 8px; }
  .msg { max-width: 84%; }
  .composer { padding: 7px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .home-bar { display: none; }
  .toast { top: 96px; }
  .preview { bottom: 6px; padding: 4px 4px 4px 10px; gap: 4px; }
  .pv-label { display: none; }
  .preview { flex-wrap: nowrap; white-space: nowrap; }
  .pv-long { display: none; }
  .pv-short { display: inline; }
  .pv-links button, .pv-btn { padding: 5px 9px; font-size: 11.5px; }
}
@media (max-width: 360px) {
  .agent-name { font-size: 15px; }
  .avatar { width: 44px; height: 44px; }
  .avatar img, .avatar-initial { width: 38px; height: 38px; }
  .bubble { font-size: 14px; }
}
/* teclado aberto em celular: esconde a barra de status falsa para ganhar espaco */
body.kb .statusbar { display: none; }

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