/* ══════════════════════════════════════════════════════════════════
   MIT — Widget do Assistente Tributário (chat IA)
   Compartilhado entre os projetos Interno e Externo.
   Autossuficiente: não depende das classes do app, só de algumas vars
   de tema com fallback. Tudo prefixado com .mitc- para evitar colisão.
   ══════════════════════════════════════════════════════════════════ */
:root {
  --mitc-accent: #6d5efc;
  --mitc-accent-2: #00d4ff;
  --mitc-bg: rgba(18, 20, 33, 0.92);
  --mitc-panel: rgba(28, 31, 48, 0.92);
  --mitc-text: #eef0f8;
  --mitc-muted: #9aa0b8;
  --mitc-bubble-user: linear-gradient(135deg, #6d5efc, #00d4ff);
  --mitc-bubble-bot: rgba(255, 255, 255, 0.06);
  --mitc-border: rgba(255, 255, 255, 0.10);
}
[data-theme="light"] {
  --mitc-bg: rgba(255, 255, 255, 0.96);
  --mitc-panel: rgba(248, 249, 253, 0.98);
  --mitc-text: #1a1d2b;
  --mitc-muted: #5a607a;
  --mitc-bubble-bot: rgba(20, 22, 40, 0.05);
  --mitc-border: rgba(20, 22, 40, 0.10);
}

/* ─── Botão flutuante ─────────────────────────────────────────────── */
.mitc-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--mitc-accent), var(--mitc-accent-2));
  box-shadow: 0 10px 30px rgba(109, 94, 252, 0.45);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.mitc-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(109, 94, 252, 0.55); }
.mitc-fab:active { transform: translateY(0); }
.mitc-fab svg { width: 20px; height: 20px; }
.mitc-fab.mitc-hidden { opacity: 0; pointer-events: none; transform: scale(.85); }

/* ─── Painel ──────────────────────────────────────────────────────── */
.mitc-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--mitc-border);
  border-radius: 18px;
  overflow: hidden;
  background: var(--mitc-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  color: var(--mitc-text);
  opacity: 0;
  transform: translateY(16px) scale(.98);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.mitc-panel.mitc-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.mitc-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--mitc-border);
  background: linear-gradient(135deg, rgba(109, 94, 252, .18), rgba(0, 212, 255, .10));
}
.mitc-head-badge {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--mitc-accent), var(--mitc-accent-2));
  color: #fff; font-weight: 800; font-size: 13px;
}
.mitc-head-titles { flex: 1; min-width: 0; }
.mitc-head-title { font: 700 14px/1.2 system-ui, sans-serif; }
.mitc-head-sub { font: 500 11px/1.3 system-ui, sans-serif; color: var(--mitc-muted); margin-top: 2px; }
.mitc-head-close {
  border: none; background: transparent; color: var(--mitc-muted);
  cursor: pointer; font-size: 22px; line-height: 1; padding: 4px 6px; border-radius: 8px;
}
.mitc-head-close:hover { background: var(--mitc-border); color: var(--mitc-text); }

/* ─── Mensagens ───────────────────────────────────────────────────── */
.mitc-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.mitc-msgs::-webkit-scrollbar { width: 8px; }
.mitc-msgs::-webkit-scrollbar-thumb { background: var(--mitc-border); border-radius: 8px; }

.mitc-row { display: flex; }
.mitc-row.mitc-user { justify-content: flex-end; }
.mitc-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font: 400 13.5px/1.5 system-ui, sans-serif;
  word-wrap: break-word;
  white-space: normal;
}
.mitc-user .mitc-bubble { background: var(--mitc-bubble-user); color: #fff; border-bottom-right-radius: 4px; }
.mitc-bot .mitc-bubble { background: var(--mitc-bubble-bot); color: var(--mitc-text); border-bottom-left-radius: 4px; }
.mitc-bubble p { margin: 0 0 8px; } .mitc-bubble p:last-child { margin-bottom: 0; }
.mitc-bubble ul { margin: 6px 0; padding-left: 18px; } .mitc-bubble li { margin: 2px 0; }
.mitc-bubble strong { font-weight: 700; }
.mitc-bubble code { background: var(--mitc-border); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.mitc-sources { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--mitc-border); }
.mitc-sources-title { font: 700 10.5px/1 system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; color: var(--mitc-muted); margin-bottom: 5px; }
.mitc-source { font: 500 11.5px/1.4 system-ui, sans-serif; color: var(--mitc-muted); }
.mitc-source b { color: var(--mitc-text); font-weight: 600; }

/* welcome + chips */
.mitc-welcome { color: var(--mitc-muted); font: 400 13px/1.55 system-ui, sans-serif; }
.mitc-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.mitc-chip {
  border: 1px solid var(--mitc-border); background: transparent; color: var(--mitc-text);
  border-radius: 999px; padding: 7px 12px; font: 500 12px/1 system-ui, sans-serif; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.mitc-chip:hover { background: var(--mitc-border); border-color: var(--mitc-accent); }

/* typing */
.mitc-typing { display: inline-flex; gap: 4px; align-items: center; }
.mitc-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--mitc-muted); animation: mitc-blink 1.2s infinite both; }
.mitc-typing span:nth-child(2) { animation-delay: .2s; } .mitc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes mitc-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ─── Input ───────────────────────────────────────────────────────── */
.mitc-input-wrap { padding: 12px; border-top: 1px solid var(--mitc-border); display: flex; gap: 9px; align-items: flex-end; }
.mitc-input {
  flex: 1; resize: none; max-height: 120px; min-height: 42px;
  padding: 11px 13px; border-radius: 12px; border: 1px solid var(--mitc-border);
  background: var(--mitc-bubble-bot); color: var(--mitc-text);
  font: 400 13.5px/1.4 system-ui, sans-serif; outline: none;
}
.mitc-input:focus { border-color: var(--mitc-accent); }
.mitc-send {
  width: 42px; height: 42px; flex: none; border: none; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--mitc-accent), var(--mitc-accent-2));
}
.mitc-send:disabled { opacity: .45; cursor: not-allowed; }
.mitc-send svg { width: 18px; height: 18px; }
.mitc-disclaimer { padding: 0 12px 10px; font: 400 10px/1.4 system-ui, sans-serif; color: var(--mitc-muted); text-align: center; }

@media (max-width: 520px) {
  .mitc-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .mitc-fab { right: 14px; bottom: 14px; }
}

/* Não imprimir o assistente de IA (FAB + painel) nos relatórios/PDF */
@media print {
  .mitc-fab, .mitc-panel { display: none !important; }
}
