/* GWIA — gwia.busiabr.com
   Identidade AlfabetizIA (navy #0a1730 + azul elétrico #2f6bff) com
   acabamento premium: tipografia Sora/Inter, superfícies em vidro,
   gradientes discretos, movimento suave. Ícones sempre SVG. */

:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef2fa;
  --text: #10203c;
  --text-dim: #5a6b8a;
  --line: rgba(16, 32, 60, .10);
  --accent: #2f6bff;
  --accent-2: #4f86ff;
  --accent-grad: linear-gradient(135deg, #4f86ff 0%, #2f6bff 100%);
  --bubble-user: linear-gradient(135deg, #4f86ff 0%, #2f6bff 100%);
  --bubble-user-text: #ffffff;
  --bubble-agent: #ffffff;
  --bubble-agent-text: #10203c;
  --ok: #12b76a;
  --alert: #ef3e46;
  --shadow: 0 12px 40px rgba(10, 23, 48, .10);
  --shadow-soft: 0 4px 18px rgba(10, 23, 48, .07);
}

[data-theme="dark"] {
  --bg: #0a1730;
  --bg-soft: #0d1f3f;
  --surface: #0f2244;
  --surface-2: #13284f;
  --text: #eaf0fb;
  --text-dim: #8fa3c8;
  --line: rgba(234, 240, 251, .09);
  --bubble-agent: #13284f;
  --bubble-agent-text: #eaf0fb;
  --shadow: 0 12px 40px rgba(0, 0, 0, .35);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, .25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .35s ease, color .35s ease;
  -webkit-font-smoothing: antialiased;
}
h1, h2, .brand-name, .agent-id strong { font-family: 'Sora', 'Inter', sans-serif; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.view { min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ══════════ LOGIN ══════════ */
#view-login { align-items: center; justify-content: center; position: relative; overflow: hidden; }

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a { width: 480px; height: 480px; background: #2f6bff; top: -160px; right: -120px; }
.orb-b { width: 420px; height: 420px; background: #4f86ff; bottom: -180px; left: -140px; animation-delay: -9s; opacity: .35; }
[data-theme="light"] .orb { opacity: .22; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-40px, 36px, 0) scale(1.12); }
}
.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
}

.login-card {
  position: relative; z-index: 1;
  width: min(420px, calc(100vw - 40px));
  padding: 44px 40px 32px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise .6s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.brand { text-align: center; margin-bottom: 30px; }
.brand-mark { width: 66px; height: 66px; filter: drop-shadow(0 10px 24px rgba(47, 107, 255, .45)); }
.brand-name { font-size: 34px; font-weight: 700; letter-spacing: .14em; margin-top: 14px; }
.brand-name span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag { color: var(--text-dim); font-size: 13.5px; margin-top: 6px; line-height: 1.5; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 7px;
}
.field input {
  width: 100%; padding: 13px 16px; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.btn-primary {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; margin-top: 8px;
  font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent-grad); border-radius: 12px;
  box-shadow: 0 10px 26px rgba(47, 107, 255, .38);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-primary svg { width: 18px; height: 18px; }

.login-error {
  color: var(--alert); font-size: 13.5px; margin: -4px 0 12px; text-align: center;
}
.login-foot {
  margin-top: 26px; text-align: center; font-size: 11.5px;
  color: var(--text-dim); letter-spacing: .04em;
}

/* ══════════ TOPBAR ══════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg-soft) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.mini-mark { width: 40px; height: 40px; border-radius: 12px; }
.agent-id { display: flex; flex-direction: column; line-height: 1.25; }
.agent-id strong { font-size: 16px; letter-spacing: .1em; }
.agent-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.agent-status em { font-style: normal; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--alert); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.off { background: #c7cede; }

.topbar-right { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 11px; color: var(--text-dim);
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
[data-theme="dark"] .ic-moon { display: none; }
[data-theme="light"] .ic-sun { display: none; }

/* ══════════ CHAT ══════════ */
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-list {
  max-width: 820px; margin: 0 auto; padding: 28px clamp(14px, 4vw, 24px) 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-hello { text-align: center; padding: 48px 20px 34px; color: var(--text-dim); }
.chat-hello svg { width: 58px; height: 58px; border-radius: 16px; }
.chat-hello h2 { color: var(--text); font-size: 21px; margin: 16px 0 8px; }
.chat-hello p { font-size: 14px; max-width: 440px; margin: 0 auto; line-height: 1.6; }

.msg { display: flex; animation: msgIn .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: min(78%, 620px);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: break-word;
  box-shadow: var(--shadow-soft);
}
.msg.user .bubble {
  background: var(--bubble-user); color: var(--bubble-user-text);
  border-bottom-right-radius: 6px;
}
.msg.agent .bubble {
  background: var(--bubble-agent); color: var(--bubble-agent-text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble .t {
  display: block; font-size: 10.5px; opacity: .62; margin-top: 6px; text-align: right;
}
.bubble code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 13px; padding: 1.5px 6px; border-radius: 6px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.bubble pre {
  margin: 8px 0; padding: 12px 14px; border-radius: 12px; overflow-x: auto;
  background: rgba(6, 14, 30, .92); color: #dbe6ff;
}
.bubble pre code { background: none; padding: 0; color: inherit; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.agent .bubble a { color: var(--accent-2); }

.typing {
  max-width: 820px; margin: 0 auto; padding: 4px clamp(14px, 4vw, 24px) 16px;
  display: flex; align-items: center; gap: 10px;
}
.typing-avatar {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; font-family: 'Sora'; font-weight: 700; font-size: 14px;
}
.typing-dots { display: flex; gap: 5px; padding: 12px 16px; background: var(--bubble-agent); border: 1px solid var(--line); border-radius: 16px; }
.typing-dots i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }

/* ══════════ COMPOSER ══════════ */
.composer-wrap {
  padding: 10px clamp(14px, 4vw, 24px) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.composer {
  max-width: 820px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 10px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.composer textarea {
  flex: 1; resize: none; border: none; outline: none; background: none;
  color: var(--text); font-family: inherit; font-size: 15px; line-height: 1.5;
  max-height: 160px; padding: 8px 0;
}
.composer textarea::placeholder { color: var(--text-dim); }
.send-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 14px; color: #fff;
  background: var(--accent-grad);
  box-shadow: 0 6px 16px rgba(47, 107, 255, .38);
  transition: transform .15s, filter .15s, opacity .15s;
}
.send-btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.send-btn:disabled { opacity: .45; transform: none; cursor: default; }
.send-btn svg { width: 19px; height: 19px; }
.composer-hint {
  max-width: 820px; margin: 8px auto 0; text-align: center;
  font-size: 11px; color: var(--text-dim); letter-spacing: .05em;
}

/* scrollbar discreta */
.chat-scroll::-webkit-scrollbar { width: 9px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

@media (max-width: 560px) {
  .bubble { max-width: 88%; }
  .login-card { padding: 36px 24px 26px; }
}
