/* =========================================================================
   Assistente de IA — estilos complementares (usa as variáveis de style.css)
   ========================================================================= */

.hidden { display: none !important; }

/* ---------------------------------------------------------------- topo */

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-pill {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  white-space: nowrap;
}
.ai-pill-ok { color: var(--success-green); border-color: rgba(16, 185, 129, 0.4); background: rgba(16, 185, 129, 0.08); }
.ai-pill-idle { color: var(--text-dim); }

/* ------------------------------------------------------------ mensagens */

.ai-md { line-height: 1.65; word-break: break-word; }
.ai-md h3, .ai-md h4 { font-family: var(--font-heading); margin: 14px 0 6px; color: var(--text-main); }
.ai-md h3 { font-size: 1.05rem; }
.ai-md h4 { font-size: 0.95rem; }
.ai-md ul { margin: 8px 0 8px 20px; }
.ai-md li { margin: 3px 0; }
.ai-md a { color: #93c5fd; text-decoration: underline; }
.ai-md code {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.86em;
  font-family: 'Cascadia Code', Consolas, monospace;
}

.ai-code {
  position: relative;
  background: #05070d;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 14px 14px 14px;
  margin: 10px 0;
  overflow-x: auto;
}
.ai-code code {
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  color: #d6deeb;
  font-size: 0.84rem;
}
.ai-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.68rem;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: pointer;
}
.ai-copy-btn:hover { color: var(--text-main); border-color: var(--border-active); }

.ai-msg-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 5px;
  padding-left: 2px;
}

/* --------------------------------------------------------- trilha MCP */

.ai-tool-trace {
  margin: 6px 0 8px;
  border-left: 2px solid var(--primary);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-tool-item {
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.ai-tool-head { font-size: 0.8rem; color: #c7d2fe; }
.ai-tool-args, .ai-tool-out {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  padding: 6px 8px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------- entrada */

.ai-input-area { flex-direction: column; align-items: stretch; gap: 8px; }

.ai-message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.ai-message-form textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 180px;
  line-height: 1.45;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.92rem;
}
.ai-message-form textarea:focus { outline: none; border-color: var(--border-active); }

.ai-icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 1.05rem;
  cursor: pointer;
}
.ai-icon-btn:hover { border-color: var(--border-active); }

.ai-input-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.7rem;
  color: var(--text-dim);
  padding: 0 4px;
  flex-wrap: wrap;
}

#view-ai.ai-dragging { outline: 2px dashed var(--primary); outline-offset: -10px; }

/* -------------------------------------------------------------- anexos */

.ai-attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
}

.ai-attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  max-width: 280px;
}
.ai-attach-chip img {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: 6px;
}
.ai-attach-icon { font-size: 1.4rem; width: 36px; text-align: center; }
.ai-attach-info { display: flex; flex-direction: column; min-width: 0; }
.ai-attach-info strong {
  font-size: 0.78rem;
  color: var(--text-main);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 170px;
}
.ai-attach-info small { font-size: 0.68rem; color: var(--text-dim); }
.ai-attach-remove {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.85rem; padding: 2px 4px;
}
.ai-attach-remove:hover { color: var(--accent-pink); }
.ai-attach-chip.loading { opacity: 0.65; }
.ai-warn { color: #fbbf24; }

.ai-spin {
  width: 14px; height: 14px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- gaveta */

.ai-drawer { position: fixed; inset: 0; z-index: 1200; display: flex; justify-content: flex-end; }
.ai-drawer-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 12, 0.72); backdrop-filter: blur(3px); }

.ai-drawer-panel {
  position: relative;
  width: min(560px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: 1px solid var(--border-light);
  animation: ai-slide 0.22s ease;
}
.ai-drawer-narrow { width: min(400px, 100%); }
@keyframes ai-slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }

.ai-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
}
.ai-drawer-header h3 { font-family: var(--font-heading); font-size: 1.05rem; }

.ai-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
}
.ai-tab {
  flex: 0 0 auto;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
}
.ai-tab:hover { color: var(--text-main); }
.ai-tab.active {
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.16);
  border-color: var(--border-active);
}

.ai-drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.ai-drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 10px;
}
.ai-drawer-footer .ai-inline-row { justify-content: flex-end; }

/* ------------------------------------------------------------- campos */

.ai-field { margin-bottom: 22px; }
.ai-field > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}
.ai-field .help-text { display: block; margin-top: 6px; font-size: 0.72rem; color: var(--text-dim); line-height: 1.5; }
.ai-field input[type="range"] { width: 100%; accent-color: var(--primary); }

.ai-val {
  float: right;
  font-weight: 500;
  color: var(--primary);
  font-size: 0.76rem;
}

.ai-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-two-col > div > label { display: block; font-size: 0.78rem; margin-bottom: 6px; color: var(--text-main); }

.ai-inline-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-inline-row .form-control { flex: 1; min-width: 180px; }
.ai-num { max-width: 120px; flex: 0 0 auto !important; }

.ai-mini-check { margin-top: 8px; font-size: 0.75rem; }
.btn-link {
  background: none; border: none; padding: 4px 0;
  color: var(--text-dim); font-size: 0.73rem;
  text-decoration: underline; cursor: pointer;
}
.btn-link:hover { color: var(--accent-pink); }
.btn-block { width: 100%; justify-content: center; }

.ai-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  margin-left: 6px;
}
.ai-tag-admin { background: rgba(236, 72, 153, 0.18); color: #fbcfe8; }

/* ---------------------------------------------------------- provedores */

.ai-provider-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ai-provider-card {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.ai-provider-card:hover { border-color: var(--border-active); }
.ai-provider-card.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.14);
}
.ai-provider-icon { font-size: 1.4rem; }
.ai-provider-name { font-weight: 600; font-size: 0.86rem; color: var(--text-main); }
.ai-provider-blurb { font-size: 0.68rem; color: var(--text-dim); line-height: 1.4; }

/* ---------------------------------------------------------------- rota */

.ai-route-toggle { display: grid; gap: 10px; }
.ai-route-option {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
}
.ai-route-option:has(input:checked) { border-color: var(--primary); background: rgba(99, 102, 241, 0.12); }
.ai-route-option input { margin-top: 3px; accent-color: var(--primary); }
.ai-route-option strong { display: block; font-size: 0.84rem; color: var(--text-main); }
.ai-route-option small { display: block; font-size: 0.7rem; color: var(--text-dim); line-height: 1.5; margin-top: 3px; }

/* --------------------------------------------------------- teste/modelo */

.ai-test-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.55;
  border: 1px solid var(--border-light);
}
.ai-test-result.ok { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.35); }
.ai-test-result.fail { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.35); }
.ai-test-result ul { margin: 8px 0 0 18px; color: var(--text-muted); }
.ai-test-result li { margin: 4px 0; }
.ai-test-result code { font-size: 0.9em; }

.ai-model-select {
  margin-top: 8px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 0.78rem;
  padding: 6px;
}
.ai-model-select option { padding: 4px 6px; }

.ai-chip {
  display: inline-block;
  margin: 4px 4px 0 0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
}
.ai-chip:hover { border-color: var(--border-active); color: var(--text-main); }
.ai-chip-static { cursor: default; }

.ai-tailnet-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- MCP */

.ai-mcp-servers { display: flex; flex-direction: column; gap: 12px; }
.ai-mcp-servers.ai-dim { opacity: 0.45; pointer-events: none; }
.ai-mcp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
}
.ai-mcp-card.unavailable { opacity: 0.6; }
.ai-mcp-card .help-text { margin: 6px 0 0; }
.ai-mcp-error { color: #fca5a5; font-size: 0.72rem; margin-top: 6px; }
.ai-mcp-tools { margin-top: 8px; }

.ai-admin-box {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(236, 72, 153, 0.3);
  background: rgba(236, 72, 153, 0.06);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ai-admin-box p { margin: 6px 0 10px; line-height: 1.5; }
.ai-admin-box code { font-size: 0.9em; word-break: break-all; }

/* ----------------------------------------------------------- conversas */

.ai-conv-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.ai-conv-item {
  display: flex; align-items: stretch; gap: 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
}
.ai-conv-item.active { border-color: var(--primary); }
.ai-conv-open {
  flex: 1; text-align: left; background: none; border: none;
  padding: 10px 12px; cursor: pointer; color: var(--text-main);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.ai-conv-open strong {
  font-size: 0.82rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-conv-open small { font-size: 0.68rem; color: var(--text-dim); }
.ai-conv-open:hover { background: rgba(255, 255, 255, 0.04); }
.ai-conv-del {
  background: none; border: none; color: var(--text-dim);
  padding: 0 12px; cursor: pointer;
}
.ai-conv-del:hover { color: var(--accent-pink); background: rgba(236, 72, 153, 0.08); }

.auth-alert-error { border-color: rgba(239, 68, 68, 0.4) !important; color: #fca5a5 !important; }

/* ------------------------------------------------------- aula ao vivo */

.ai-pill-rec {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
  animation: aula-pulsar 1.6s ease-in-out infinite;
}
@keyframes aula-pulsar { 50% { opacity: 0.55; } }

.aula-corpo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 12px 0;
}

.aula-barra {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'titulo  controles'
    'motor   metricas'
    'medidor medidor';
  gap: 10px 14px;
  align-items: center;
  padding: 14px 16px;
}

.aula-motor-caixa {
  grid-area: motor;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.aula-motor-caixa label {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.aula-motor-caixa select {
  font-size: 0.76rem;
  padding: 5px 8px;
  min-width: 0;
  flex: 1;
}
.aula-motor-ativo {
  font-size: 0.72rem;
  color: var(--primary);
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
}
.aula-titulo { grid-area: titulo; font-size: 0.9rem; }
.aula-controles { grid-area: controles; display: flex; gap: 8px; flex-wrap: wrap; }
.aula-medidor-caixa {
  grid-area: medidor;
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.aula-medidor {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  background: var(--text-dim);
  transition: width 0.08s linear, background 0.15s;
}
.aula-medidor.falando { background: linear-gradient(90deg, var(--success-green), var(--primary)); }

.aula-metricas {
  grid-area: metricas;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.aula-tempo {
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 1rem;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.aula-transcricao {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  padding: 18px 20px;
  line-height: 1.7;
  font-size: 0.92rem;
}
.aula-transcricao:empty::before {
  content: 'A transcrição aparece aqui, trecho por trecho, enquanto o professor fala.';
  color: var(--text-dim);
  font-style: italic;
}
.aula-linha { margin: 0 0 10px; color: var(--text-main); }
.aula-ts {
  display: inline-block;
  min-width: 58px;
  margin-right: 10px;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 0.72rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.aula-acoes { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.aula-acoes > strong { font-size: 0.8rem; color: var(--text-main); }
.aula-botoes-ia { display: flex; gap: 8px; flex-wrap: wrap; }

.aula-notas {
  padding: 20px 22px;
  max-height: 45vh;
  overflow-y: auto;
  border-left: 3px solid var(--primary);
}

/* ------------------------------------------------------------- celular */

@media (max-width: 768px) {
  .ai-drawer-panel { width: 100%; }
  .ai-two-col { grid-template-columns: 1fr; }
  .ai-message-form { flex-wrap: wrap; }
  .ai-message-form textarea { order: -1; width: 100%; flex: 1 1 100%; }
  .ai-prompt-select { flex: 1; }
  .ai-tabs { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .ai-tab { font-size: 0.72rem; padding: 6px 10px; }
  .ai-inline-row { flex-direction: column; gap: 6px; }
  .ai-inline-row .btn { align-self: flex-end; }
  .ai-inline-row .form-control { min-width: unset; }
  .ai-field { padding: 12px 14px; }
  .ai-drawer-body { padding: 6px 4px; }
  .aula-barra {
    grid-template-columns: 1fr;
    grid-template-areas: 'titulo' 'controles' 'motor' 'medidor' 'metricas';
    gap: 8px;
    padding: 10px;
  }
  .aula-motor-caixa { flex-wrap: wrap; }
  .aula-metricas { justify-content: space-between; font-size: 0.7rem; gap: 8px; }
  .aula-controles { justify-content: stretch; }
  .aula-controles .btn {
    flex: 1;
    font-size: 0.85rem;
    padding: 10px 12px;
  }
  .aula-titulo { font-size: 0.85rem; min-width: 0; }
  .aula-transcricao { min-height: 140px; padding: 14px 12px; font-size: 0.85rem; }
  .aula-notas { max-height: 35vh; padding: 14px 12px; }
  .aula-acoes { padding: 10px 12px; }
  .aula-botoes-ia { flex-direction: column; }
  .aula-botoes-ia .btn {
    width: 100%;
    justify-content: flex-start;
    font-size: 0.82rem;
    padding: 10px 14px;
  }
  .aula-corpo { gap: 8px; padding: 6px 0; }
  .aula-motor-caixa select { font-size: 0.8rem; }
  .ai-status-banner { flex-wrap: wrap; gap: 8px; }
  .ai-status-banner .ai-status-content { flex: 1 1 100%; }
  .ai-status-banner .btn { flex: 0 0 auto; }
}
