/* Portal de atendimento GET — mesmo visual dos mockups (canvas "Portal ChatGET"). */
:root {
  --accent: #0F4C5C;
  --accent-dark: #0A3540;
  --accent-soft: #DCEAEE;
  --on-accent-muted: #D7E8EC;
  --ink: #10232B;
  --muted: #4A5A62;
  --meta: #5B6770;
  --ground: #F4F2EE;
  --surface: #FFFFFF;
  --surface-2: #F1F4F5;
  --line: #D3D8DB;
  --wall: #E9E5DD;
  --bubble-in: #FFFFFF;
  --bubble-out: #D3EAF1;
  --tick: #1F7FB8;
  --author: #8A5A00;
  --warn-bg: #FFF6DB;
  --warn-ink: #4D3600;
  --warn-btn: #7A5300;
  --danger: #B3261E;
  --shadow: 0 12px 32px rgba(0, 0, 0, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0F4C5C;
    --accent-dark: #0A3540;
    --accent-soft: #17343C;
    --on-accent-muted: #B9D3DA;
    --ink: #E6EDEF;
    --muted: #A9B6BC;
    --meta: #98A6AC;
    --ground: #0D1518;
    --surface: #18242A;
    --surface-2: #22313A;
    --line: #2B3A42;
    --wall: #0F1A1E;
    --bubble-in: #1D2B32;
    --bubble-out: #144552;
    --tick: #5AB4E8;
    --author: #F2C98A;
    --warn-bg: #3A2E10;
    --warn-ink: #F6E3B0;
    --warn-btn: #C99A2E;
    --danger: #F2867E;
    --shadow: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--tick); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--tick); outline-offset: 2px; }

#app { height: 100dvh; }
.view { height: 100dvh; }

/* ── carregando ── */
.view-loading { display: flex; align-items: center; justify-content: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── telas de acesso ── */
.view-auth { display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; background: var(--ground); overflow-y: auto; }
.auth-hero { background: var(--accent); color: #fff; padding: calc(56px + env(safe-area-inset-top)) 28px 40px; display: flex; flex-direction: column; gap: 16px; border-radius: 0 0 28px 28px; }
.auth-hero h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; }
.auth-hero p { margin: 0; font-size: 16px; line-height: 1.45; color: var(--on-accent-muted); }
.logo { width: 64px; height: 64px; border-radius: 20px; background: #fff; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.logo .ic { width: 36px; height: 36px; }
.logo-soft { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.logo-soft .ic { width: 28px; height: 28px; }
@media (prefers-color-scheme: dark) { .logo-soft { color: #8FD0E0; } }
.logo-sm { width: 36px; height: 36px; border-radius: 12px; }
.logo-sm .ic { width: 20px; height: 20px; }
.topbar { height: 64px; padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; flex: none; }
.auth-head { padding: 16px 28px 0; display: flex; flex-direction: column; gap: 12px; }
.auth-head h1 { margin: 0; font-size: 28px; line-height: 1.2; }
.auth-head p { margin: 0; font-size: 16px; line-height: 1.45; color: var(--muted); }
.auth-head strong { color: var(--ink); }
.auth-form { padding: 28px 28px 0; display: flex; flex-direction: column; gap: 14px; }
.auth-form > label { font-size: 15px; font-weight: 600; }
.phone-field { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; background: var(--surface); border: 2px solid var(--accent); border-radius: 14px; }
@media (prefers-color-scheme: dark) { .phone-field { border-color: #3E8597; } }
.phone-field .ddi { font-size: 17px; font-weight: 600; color: var(--muted); }
.phone-field .sep { width: 1px; height: 26px; background: var(--line); }
.phone-field input { flex: 1; min-width: 0; border: 0; outline: none; font-size: 18px; background: transparent; }
.hint { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.form-error { margin: 0; min-height: 0; font-size: 14px; font-weight: 600; color: var(--danger); }
.form-error:empty { display: none; }
.btn-primary { margin-top: 6px; height: 54px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary:not(:disabled):hover { background: var(--accent-dark); }
.link-btn { border: 0; background: none; padding: 0; color: var(--tick); font-weight: 700; text-decoration: underline; }
.link-btn:disabled { color: var(--meta); text-decoration: none; cursor: default; }
.auth-note { margin: auto 28px calc(28px + env(safe-area-inset-bottom)); padding: 16px; background: var(--surface); border-radius: 14px; display: flex; gap: 12px; align-items: flex-start; color: var(--accent); }
@media (prefers-color-scheme: dark) { .auth-note { color: #8FD0E0; } }
.auth-note p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.auth-foot { margin: auto 28px calc(28px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); }
.auth-foot .ic { width: 18px; height: 18px; }
.auth-foot p { margin: 0; font-size: 13px; }
.otp { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp input { height: 60px; min-width: 0; text-align: center; font-size: 26px; font-weight: 700; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; outline: none; }
.otp input:focus { border-color: var(--accent); }
@media (prefers-color-scheme: dark) { .otp input:focus { border-color: #3E8597; } }

/* ── conversa ── */
.view-chat { display: flex; }
.side { display: none; }
.chat { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--wall); height: 100dvh; }
.chat-head { flex: none; min-height: 64px; padding: env(safe-area-inset-top) 6px 0 12px; background: var(--accent); color: #fff; display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #fff; color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; }
.avatar.human { background: #F2C98A; color: #4D3600; }
.head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.head-title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 13px; color: var(--on-accent-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub.typing-now { font-style: italic; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { background: rgba(127, 127, 127, .12); }
.icon-btn.on-accent { color: #fff; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 4px; top: 48px; z-index: 30; min-width: 200px; padding: 6px; background: var(--surface); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu button { height: 44px; padding: 0 12px; border: 0; background: none; border-radius: 8px; display: flex; align-items: center; gap: 12px; text-align: left; font-size: 15px; }
.menu button:hover { background: var(--surface-2); }
.menu .ic { width: 20px; height: 20px; color: var(--muted); }

.banner { flex: none; margin: 10px 10px 0; padding: 8px 6px 8px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.35; }
.banner > .ic { width: 20px; height: 20px; }
.banner span { flex: 1; }
.banner-btn { height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--warn-btn); color: #fff; font-size: 13px; font-weight: 700; flex: none; }
@media (prefers-color-scheme: dark) { .banner-btn { color: #1B1404; } }
.banner-close { width: 36px; height: 36px; color: var(--warn-ink); }
.banner-close .ic { width: 18px; height: 18px; }

.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.msgs::before { content: ''; margin-top: auto; }
.empty { display: flex; justify-content: center; padding: 24px 8px; }
.empty-card { max-width: 360px; padding: 14px 16px; background: var(--bubble-in); border-radius: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.45; color: var(--muted); text-align: center; }
.empty-card strong { color: var(--ink); font-size: 16px; }
.chip { align-self: center; margin: 8px 0 4px; padding: 5px 12px; max-width: 86%; background: var(--surface); border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.chip.sys { background: var(--accent-soft); color: var(--accent-dark); font-weight: 500; font-size: 13px; }
@media (prefers-color-scheme: dark) { .chip.sys { color: #CFE6EC; } }

.row { display: flex; }
.row.mine { justify-content: flex-end; }
.row + .row.gap, .chip + .row { margin-top: 6px; }
.bubble { max-width: min(80%, 560px); padding: 7px 10px 5px; background: var(--bubble-in); border-radius: 4px 14px 14px 14px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); overflow-wrap: anywhere; }
.row.mine .bubble { background: var(--bubble-out); border-radius: 14px 4px 14px 14px; }
.row.cont .bubble { border-radius: 14px; }
.author { font-size: 13px; font-weight: 700; color: var(--author); }
.text { font-size: 15px; line-height: 1.42; white-space: pre-wrap; }
.meta { align-self: flex-end; display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--meta); margin-top: -1px; }
.tick { width: 16px; height: 11px; fill: none; stroke: var(--meta); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tick.read { stroke: var(--tick); }
.meta .ic { width: 12px; height: 12px; }
.row.failed .meta { color: var(--danger); font-weight: 600; }
.retry { border: 0; background: none; padding: 0; color: var(--danger); font-size: 11px; font-weight: 700; text-decoration: underline; }

.att-img { display: block; border-radius: 10px; overflow: hidden; margin: -3px -6px 2px; background: var(--surface-2); }
.att-img img { display: block; max-width: 100%; width: 280px; max-height: 320px; object-fit: cover; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 10px; margin: -2px -4px 2px; min-width: 220px; background: var(--surface-2); border-radius: 10px; text-decoration: none; color: inherit; }
.row.mine .att-file { background: rgba(255, 255, 255, .55); }
@media (prefers-color-scheme: dark) { .row.mine .att-file { background: rgba(0, 0, 0, .2); } }
.ext { width: 40px; height: 46px; flex: none; border-radius: 6px; background: #3D5A80; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.ext.pdf { background: #B3261E; }
.ext.xml { background: #3D5A80; }
.ext.xls, .ext.xlsx, .ext.csv { background: #2D6A4F; }
.ext.zip, .ext.rar { background: #6A4C93; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--muted); }
.att-file .ic { width: 20px; height: 20px; color: var(--accent); }
@media (prefers-color-scheme: dark) { .att-file .ic { color: #8FD0E0; } }
.att-audio { width: 260px; max-width: 100%; height: 40px; margin: 2px 0; }
.att-video { width: 280px; max-width: 100%; border-radius: 10px; margin: -3px -6px 2px; }
.progress { height: 4px; border-radius: 2px; background: rgba(127, 127, 127, .25); overflow: hidden; margin: 2px 0; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.typing-row { flex: none; padding: 0 12px 6px; }
.typing { display: inline-flex; gap: 5px; padding: 12px 14px; background: var(--bubble-in); border-radius: 4px 14px 14px 14px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--meta); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.composer, .recorder { flex: none; padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 6px; }
.input-pill { flex: 1; min-width: 0; min-height: 48px; padding: 0 4px; background: var(--surface); border-radius: 24px; display: flex; align-items: flex-end; gap: 2px; }
.input-pill .icon-btn { width: 44px; height: 48px; }
.input-pill textarea { flex: 1; min-width: 0; max-height: 140px; padding: 13px 4px; border: 0; outline: none; resize: none; background: transparent; font-size: 16px; line-height: 1.35; }
.round-btn { width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.round-btn:hover { background: var(--accent-dark); }
.recorder { align-items: center; background: var(--wall); }
.recorder .icon-btn { color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #D93025; animation: blink 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-label { flex: 1; color: var(--muted); font-size: 14px; }

.drop { position: absolute; inset: 64px 0 0; z-index: 25; background: rgba(15, 76, 92, .82); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; border: 3px dashed rgba(255, 255, 255, .7); border-radius: 12px; }

.sheet-backdrop { position: absolute; inset: 0; z-index: 40; background: rgba(11, 26, 31, .45); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 41; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; gap: 16px; }
.sheet-grip { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; }
.sheet-grid button { border: 0; background: none; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 14px; }
.sheet-ic { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.sheet-ic .ic { width: 26px; height: 26px; }
.sheet-hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); padding: 10px 16px; background: #2B2F31; color: #fff; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); }

/* ── computador ── */
@media (min-width: 960px) {
  body { background: #DCE0DE; }
  .view-chat { max-width: 1400px; margin: 0 auto; box-shadow: var(--shadow); }
  .side { display: flex; flex-direction: column; width: 320px; flex: none; background: var(--surface); border-right: 1px solid var(--line); }
  .side-brand { height: 64px; padding: 0 20px; background: var(--accent); color: #fff; display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; }
  .side-body { padding: 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
  .side-label { margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
  .side-phone { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
  .side-actions { display: flex; flex-direction: column; gap: 10px; }
  .side-hint { margin: auto 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
  .btn-outline { height: 44px; border: 1.5px solid var(--accent); border-radius: 12px; background: transparent; color: var(--accent); font-weight: 700; }
  .btn-ghost { height: 44px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-weight: 600; }
  @media (prefers-color-scheme: dark) { .btn-outline { border-color: #3E8597; color: #8FD0E0; } }
  .msgs { padding: 20px 6%; }
  .chat-head .menu-wrap { display: none; }
  .composer { padding: 10px 20px; }
  .sheet { left: 50%; right: auto; bottom: 90px; width: 380px; transform: translateX(-50%); border-radius: 18px; box-shadow: var(--shadow); }
  .sheet-grip { display: none; }
  .sheet-backdrop { background: transparent; }
}
@media (prefers-color-scheme: dark) and (min-width: 960px) { body { background: #070C0E; } }
