/* ==========================================================================
   Ibot — Design System
   Tema escuro + glassmorphism, compartilhado entre o chat e o painel de treino.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Syne:wght@600;700;800&display=swap');

:root {
  --bg:            #070a13;
  --bg-soft:       #0d1220;
  --surface:       rgba(255, 255, 255, 0.045);
  --surface-2:     rgba(255, 255, 255, 0.08);
  --border:        rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text:          #e8ecf6;
  --text-dim:      #9aa4bd;
  --text-mute:     #6b7590;
  --brand:         #6366f1;
  --brand-2:       #22d3ee;
  --accent:        #a855f7;
  --ok:            #22c55e;
  --err:           #ef4444;
  --radius:        20px;
  --radius-sm:     12px;
  --shadow:        0 24px 60px rgba(0, 0, 0, 0.55);
  --gradient:      linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  --font:          'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-display:  'Syne', var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Fundo animado com brilhos ------------------------------------------------ */
.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  animation: float 14s ease-in-out infinite;
}
.glow-1 { width: 480px; height: 480px; background: #4f46e5; top: -140px; left: -120px; }
.glow-2 { width: 460px; height: 460px; background: #0891b2; bottom: -160px; right: -120px; animation-delay: -7s; }

@keyframes float {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(30px) }
}

/* Cartões de vidro --------------------------------------------------------- */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

/* ==========================================================================
   CHAT
   ========================================================================== */
.chat-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 820px;
  height: min(88vh, 820px);
  height: min(88dvh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0));
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: contain;
  background: rgba(255,255,255,.06);
  padding: 6px;
  border: 1px solid var(--border);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: .3px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .74rem;
  color: var(--text-dim);
}
.status i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.header-actions { margin-left: auto; display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: .2s;
}
.icon-btn:hover { color: #fff; border-color: var(--border-strong); transform: translateY(-1px); }

/* Área de mensagens -------------------------------------------------------- */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }

.msg-row { display: flex; align-items: flex-end; gap: 10px; animation: rise .35s ease both; }
.msg-row.user { flex-direction: row-reverse; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.avatar {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.avatar.bot  { background: var(--gradient); color: #04121a; }
.avatar.user { background: var(--surface-2); color: var(--text-dim); }
.avatar-img  { width: 100%; height: 100%; object-fit: cover; display: block; }

.bubble-wrap { max-width: 72%; }

.bubble {
  padding: 13px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: .95rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bubble.bot {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  color: var(--text);
}
.bubble.user {
  background: var(--gradient);
  color: #04121a;
  font-weight: 500;
  border-bottom-right-radius: 5px;
  box-shadow: 0 10px 26px rgba(34, 211, 238, .22);
}
.bubble a { color: var(--brand-2); }
.bubble-img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-bottom: 8px;
}

/* Indicador "digitando" ---------------------------------------------------- */
.bubble.typing { display: inline-flex; gap: 5px; padding: 16px; }
.bubble.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-mute);
  animation: blink 1.3s infinite both;
}
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0) } 40% { opacity: 1; transform: translateY(-3px) } }

/* Sugestões rápidas -------------------------------------------------------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .8rem;
  cursor: pointer;
  transition: .2s;
  font-family: inherit;
}
.chip:hover { color: #fff; border-color: var(--border-strong); background: rgba(99,102,241,.18); }

/* Barra de entrada --------------------------------------------------------- */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, rgba(255,255,255,.05), rgba(255,255,255,0));
}

.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.25);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 15px;
  font: inherit;
  font-size: .95rem;
  line-height: 1.45;
  max-height: 140px;
  min-height: 48px;
  transition: border-color .2s;
}
.chat-input textarea::placeholder { color: var(--text-mute); }
.chat-input textarea:focus { outline: none; border-color: var(--brand); }

.send-btn {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--gradient);
  color: #04121a;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: .2s;
  box-shadow: 0 10px 26px rgba(99,102,241,.35);
}
.send-btn:hover { transform: translateY(-2px); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ==========================================================================
   PAINEL DE TREINO
   ========================================================================== */
.admin-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.admin-header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.admin-header img { width: 50px; height: 50px; object-fit: contain; }
.admin-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.admin-header p { margin: 2px 0 0; color: var(--text-dim); font-size: .82rem; }

.stat {
  margin-left: auto;
  text-align: right;
  line-height: 1.1;
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--brand-2); }
.stat span { font-size: .72rem; color: var(--text-mute); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.25);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: .92rem;
  transition: border-color .2s;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-mute); }
.field input:focus,
.field textarea:focus { outline: none; border-color: var(--brand); }

.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .field-grid { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: .2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.btn-primary { background: var(--gradient); color: #04121a; border: 0; box-shadow: 0 10px 26px rgba(99,102,241,.35); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* Toast -------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 30px);
  min-width: 260px;
  max-width: 90vw;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: .9rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: .3s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok  { border-color: rgba(34,197,94,.5);  box-shadow: 0 0 30px rgba(34,197,94,.25); }
.toast.err { border-color: rgba(239,68,68,.5);  box-shadow: 0 0 30px rgba(239,68,68,.25); }

/* Acessibilidade ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
