:root {
  --accent: #0ea5a4;
  --accent-deep: #0b7a78;
  --accent-soft: #d6f5f1;
  --ink: #0f1f2e;
  --ink-soft: #5b6b78;
  --surface: #ffffff;
  --bg: #eef4f5;
  --bot-bubble: #ffffff;
  --user-bubble: #0f1f2e;
  --line: #e3eaec;
  --radius: 20px;
  --shadow: 0 24px 60px -20px rgba(11, 31, 41, 0.35);
}

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

html, body {
  height: 100%;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: transparent;
  -webkit-font-smoothing: antialiased;
}

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(14, 165, 164, 0.10), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(15, 31, 46, 0.06), transparent 55%),
    var(--bg);
  overflow: hidden;
}

/* ---------- Header ---------- */
.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--ink) 0%, #16364a 100%);
  color: #fff;
  position: relative;
  z-index: 3;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.chat__header.is-dragging { cursor: grabbing; }
.chat__header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 120% at 90% -20%, rgba(14, 165, 164, 0.45), transparent 60%);
  pointer-events: none;
}
.chat__avatar {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 20px -6px rgba(14, 165, 164, 0.7);
  flex: none;
}
.chat__avatar-glyph {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
}
.chat__status-dot {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--ink);
}
.chat__id { display: flex; flex-direction: column; line-height: 1.2; z-index: 1; }
.chat__name {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
}
.chat__role { font-size: 12px; color: rgba(255,255,255,0.7); }
.chat__close {
  margin-left: auto; z-index: 1;
  background: rgba(255,255,255,0.1);
  border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
  transition: background .2s;
}
.chat__close:hover { background: rgba(255,255,255,0.22); }

/* ---------- Stream ---------- */
.chat__stream {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat__stream::-webkit-scrollbar { width: 7px; }
.chat__stream::-webkit-scrollbar-thumb { background: #cfd9db; border-radius: 10px; }
.chat__stream.is-dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: var(--accent-soft);
}

.msg {
  max-width: 82%;
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.5;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .32s cubic-bezier(.2,.9,.3,1.2) both;
}
.msg--bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 6px 16px -10px rgba(15,31,46,0.25);
}
.msg--user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 6px;
}

/* Anexos enviados pelo usuário */
.msg.attach { padding: 6px; max-width: 70%; }
.attach__img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
}
.msg.attach--file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  font-size: 14px;
}
.attach__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 14px 16px;
  background: var(--bot-bubble);
  border: 1px solid var(--line);
  border-radius: 18px; border-bottom-left-radius: 6px;
  animation: pop .25s ease both;
}
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-soft); opacity: .4;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

/* ---------- Options (buttons) ---------- */
.chat__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 18px 12px;
}
.chat__options:empty { display: none; }
.opt {
  text-align: left;
  font-family: inherit;
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 15px;
  cursor: pointer;
  position: relative;
  transition: transform .15s, border-color .2s, box-shadow .2s, background .2s;
  animation: rise .3s ease both;
}
.opt::after {
  content: "→";
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%) translateX(-4px);
  opacity: 0; color: var(--accent-deep);
  transition: opacity .2s, transform .2s;
}
.opt:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 10px 22px -14px rgba(14,165,164,0.9);
  transform: translateY(-1px);
}
.opt:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
.opt:active { transform: translateY(0) scale(.99); }

/* ---------- Composer ---------- */
.chat__composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.chat__attach {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 12px; border: none;
  display: grid; place-items: center;
  color: var(--ink-soft); cursor: pointer;
  background: var(--bg);
  transition: color .2s, background .2s, transform .15s;
}
.chat__attach:hover:not(:disabled) {
  color: var(--accent-deep);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.chat__attach:disabled { opacity: .4; cursor: not-allowed; }

.chat__input {
  flex: 1;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.chat__input:focus { border-color: var(--accent); background: #fff; }
.chat__input:disabled { opacity: .5; cursor: not-allowed; }
.chat__send {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 14px; border: none;
  display: grid; place-items: center;
  color: #fff; cursor: pointer;
  background: linear-gradient(140deg, var(--accent), var(--accent-deep));
  box-shadow: 0 10px 22px -10px rgba(14,165,164,0.9);
  transition: transform .15s, opacity .2s;
}
.chat__send svg { transform: rotate(0deg); margin-left: -1px; }
.chat__send:hover:not(:disabled) { transform: translateY(-1px) scale(1.04); }
.chat__send:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }

.chat__footer {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 6px 0 10px;
  background: var(--surface);
  letter-spacing: .02em;
}
.chat__footer strong { color: var(--accent-deep); }

/* ---------- Animations ---------- */
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
