/* CearIA v.1 (by Ceara) — Sidepanel Styles */

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #6c5ce7;
  --accent-hover: #7c6cf7;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --success: #00b894;
  --warning: #fdcb6e;
  --error: #e74c3c;
  --materia: #f9ca24;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-y: auto;
}

/* ── Header ──────────────────────────────────────────────── */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-right {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.header-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.brand-ia {
  color: var(--accent);
  font-weight: 800;
}
.brand-ver {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.header-author {
  font-size: 9px;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
  letter-spacing: 0.2px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }
.icon-settings { color: var(--accent); font-size: 16px; }
.icon-settings:hover { color: var(--accent-hover); background: var(--accent-glow); }

/* MinutaIA indicator */
.minutaia-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.minutaia-indicator .mi-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
}
.minutaia-indicator.is-connected {
  background: rgba(0,184,148,0.12); color: var(--success);
  border-color: rgba(0,184,148,0.35);
}
.minutaia-indicator.is-connected .mi-dot {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(0,184,148,0.2);
}
.minutaia-indicator.is-disconnected {
  background: rgba(231,76,60,0.12); color: var(--error);
  border-color: rgba(231,76,60,0.35);
}
.minutaia-indicator.is-disconnected .mi-dot { background: var(--error); }
.minutaia-indicator.is-loading {
  background: rgba(253,203,110,0.12); color: var(--warning);
  border-color: rgba(253,203,110,0.35);
}
.minutaia-indicator.is-loading .mi-dot {
  background: var(--warning);
  animation: mi-pulse 1.3s ease-in-out infinite;
}
.minutaia-indicator.is-unknown {
  background: var(--bg-hover); color: var(--text-muted);
  border-color: var(--border);
}
@keyframes mi-pulse {
  0%,100% { opacity: 0.4; transform: scale(0.85); }
  50%     { opacity: 1;   transform: scale(1.1); }
}

/* ── Sections ────────────────────────────────────────────── */

.section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.hidden { display: none !important; }

/* ── Banner ──────────────────────────────────────────────── */

.banner { padding: 6px 12px; font-size: 11px; text-align: center; }
.banner.error   { background: var(--error); color: #fff; }
.banner.warning { background: #1a1400; color: var(--warning); border-bottom: 1px solid var(--warning); }
.banner.success { background: #001a10; color: var(--success); border-bottom: 1px solid var(--success); }
.banner.loading { background: var(--bg-card); color: var(--text-muted); border-bottom: 1px solid var(--border); }

/* ── Processo Info (reformulated) ────────────────────────── */

.proc-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.proc-header.empty { opacity: 0.5; }

.proc-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
}

.proc-label-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  min-width: 52px;
  flex-shrink: 0;
  font-weight: 600;
}

.proc-pasta {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}
.proc-header.empty .proc-pasta { color: var(--text-muted); font-weight: 500; font-size: 13px; }

.proc-materia {
  font-size: 12px;
  font-weight: 600;
  color: var(--materia);
}

.proc-value {
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proc-tipo {
  display: inline-block;
  margin-top: 5px;
  font-size: 10px;
  color: var(--bg);
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* ── Contexto ────────────────────────────────────────────── */

.ctx-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.ctx-icon { font-size: 14px; }
.ctx-status.loaded  { color: var(--success); }
.ctx-status.loading { color: var(--warning); }
.ctx-status.error   { color: var(--error); }

.retry-btn { margin-left: auto; font-size: 13px; flex-shrink: 0; }

.sync-progress { margin-top: 6px; }
.progress-bar {
  height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.3s; width: 0%;
}
.sync-msg { display: block; margin-top: 3px; font-size: 10px; color: var(--text-muted); }

.docs-list {
  display: flex; flex-direction: column; gap: 3px; margin-top: 6px;
}
.docs-list:empty { margin: 0; }
.doc-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; font-size: 10px;
}
.doc-item .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.doc-item .doc-meta { color: var(--text-muted); margin: 0 6px; white-space: nowrap; }
.doc-item .btn-remove { background: none; border: none; color: var(--error); cursor: pointer; font-size: 12px; padding: 0 2px; }
.doc-item.process-doc { border-color: var(--accent); border-style: dashed; }

.drop-zone-inline {
  margin-top: 6px;
  text-align: center;
  font-size: 11px;
}
.upload-label {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  transition: color 0.15s;
}
.upload-label:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Config ──────────────────────────────────────────────── */

.field-label {
  display: block; font-size: 10px; color: var(--text-muted);
  margin-bottom: 3px; margin-top: 8px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.field-label:first-child { margin-top: 0; }

.input-filtro {
  width: 100%; padding: 5px 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); font-size: 11px; margin-bottom: 3px; outline: none;
}
.input-filtro:focus { border-color: var(--accent); }
.input-filtro::placeholder { color: var(--text-muted); font-size: 10px; }

select, .input-field {
  width: 100%; padding: 6px 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); font-size: 11px; outline: none;
  transition: border-color 0.15s;
}
select:focus, .input-field:focus { border-color: var(--accent); }

.config-inline {
  display: flex; gap: 12px; margin-top: 8px;
}
.config-col { flex: 1; }

.esforco-row {
  display: flex; align-items: center; gap: 4px; margin-top: 3px;
}

.toggle-group {
  display: flex; margin-top: 3px;
  border: 1px solid var(--border); border-radius: 5px; overflow: hidden;
}
.toggle-btn {
  flex: 1; padding: 4px 8px; font-size: 10px; font-weight: 600;
  border: none; background: var(--bg); color: var(--text-muted);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.toggle-btn.active { background: var(--accent); color: #fff; }
.toggle-btn:hover:not(.active) { background: var(--bg-hover); }

.slider { width: 100%; accent-color: var(--accent); }
.slider-label { font-size: 12px; font-weight: 700; color: var(--accent); }

/* ── Collapsible sections ────────────────────────────────── */

.btn-collapsible {
  width: 100%; text-align: left;
  padding: 5px 8px; font-size: 11px;
  color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.btn-collapsible:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text); }

.collapsible-details {
  margin-top: 8px;
}
.collapsible-details summary {
  list-style: none; cursor: pointer;
}
.collapsible-details summary::-webkit-details-marker { display: none; }
.collapsible-details[open] summary .btn-collapsible,
.collapsible-details summary.btn-collapsible[open] {
  border-color: var(--accent); color: var(--text);
}
.modelos-body { margin-top: 6px; }

.prompt-row { margin-top: 6px; }
#ta-prompt {
  width: 100%; min-height: 60px; max-height: 180px;
  margin-top: 5px; padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text);
  font-size: 11px; font-family: inherit; resize: vertical; outline: none;
}
#ta-prompt:focus { border-color: var(--accent); }

.btn-primary {
  display: block; width: 100%; margin-top: 10px; padding: 9px;
  background: var(--accent); color: #fff; border: none; border-radius: 7px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modelos ─────────────────────────────────────────────── */

.modelos-header {
  display: flex; align-items: center; justify-content: flex-end; margin-bottom: 4px;
}
.toggle-rigoroso {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.toggle-rigoroso input { accent-color: var(--accent); }
.toggle-rigoroso:has(input:checked) span { color: var(--accent); }

.modelos-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 5px; }
.modelos-empty { text-align: center; color: var(--text-muted); font-size: 11px; padding: 6px; }
.modelo-item {
  display: flex; align-items: center; padding: 4px 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; font-size: 10px; gap: 4px;
}
.modelo-item label { flex: 1; display: flex; align-items: center; gap: 4px; cursor: pointer; overflow: hidden; }
.modelo-item .modelo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.modelo-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.modelo-item .btn-remove { background: none; border: none; color: var(--error); cursor: pointer; font-size: 12px; padding: 0 2px; flex-shrink: 0; }

.modelos-actions { display: flex; gap: 4px; }
.upload-modelo-label { cursor: pointer; }

/* ── Resultado ───────────────────────────────────────────── */

.resultado-header {
  margin-bottom: 6px; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
}

.resultado-content {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 10px;
  max-height: 55vh; overflow-y: auto;
  font-size: 12px; line-height: 1.6;
}
.resultado-content h1, .resultado-content h2, .resultado-content h3 { color: var(--text); margin: 10px 0 4px; }
.resultado-content h1 { font-size: 15px; }
.resultado-content h2 { font-size: 13px; }
.resultado-content h3 { font-size: 12px; }
.resultado-content p { margin: 4px 0; }
.resultado-content ul, .resultado-content ol { padding-left: 18px; margin: 4px 0; }
.resultado-content blockquote {
  border-left: 3px solid var(--accent); padding-left: 8px;
  margin: 6px 0; color: var(--text-muted); font-style: italic;
}
.resultado-content strong { color: var(--text); }

.resultado-bottom-bar {
  display: flex; gap: 6px; margin-top: 8px; align-items: center;
}
.resultado-bottom-bar .btn-sm { flex: 1; text-align: center; }

.btn-sm {
  padding: 4px 8px; font-size: 10px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn-sm:hover { background: var(--bg-hover); border-color: var(--accent); }

.btn-danger { border-color: rgba(231,76,60,0.5); color: var(--error); }
.btn-danger:hover { background: rgba(231,76,60,0.1); border-color: var(--error); }

.btn-attus-sm {
  flex: 1; text-align: center;
  padding: 4px 8px; font-size: 10px; font-weight: 600;
  background: #e17055; color: #fff; border: none; border-radius: 5px;
  cursor: pointer; transition: background 0.15s;
}
.btn-attus-sm:hover { background: #d35400; }
.btn-attus-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-attus-sm.success { background: var(--success); }
.btn-attus-sm.error { background: var(--error); }

/* ── Field utilities ─────────────────────────────────────── */

.field-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 3px 0; }
.field-hint { font-size: 10px; color: var(--text-muted); line-height: 1.4; }
.field-hint.success { color: var(--success); }
.field-actions { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; }

/* ── Thinking ────────────────────────────────────────────── */

#thinking-section { font-size: 10px; }
#thinking-section summary { cursor: pointer; color: var(--text-muted); font-weight: 600; }
.thinking-log {
  max-height: 150px; overflow-y: auto; padding: 6px;
  background: var(--bg); border-radius: 5px; margin-top: 4px;
  font-family: monospace; font-size: 10px; color: var(--text-muted);
  white-space: pre-wrap;
}

/* ── Modal ────────────────────────────────────────────────── */

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; width: 90%; max-width: 340px;
  max-height: 80vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.modal-body { padding: 12px; }

.settings-status { margin-top: 6px; font-size: 10px; text-align: center; }
.settings-status.success { color: var(--success); }
.settings-status.error { color: var(--error); }

/* ── Spinner ─────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 4px;
}
