/* Painel CI (Computer Intelligence) */

.ci-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow: auto;
}

.ci-panel__header h2 {
  margin: 0;
  font-size: 16px;
}

/* ── Bloco de aprendizado ──────────────────────────────── */

.ci-panel__learn-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.ci-panel__learn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ci-panel__learn-row > input:not([type="checkbox"]),
.ci-panel__learn-row > select {
  flex: 1;
  min-width: 200px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
}

.ci-panel__learn-row select {
  min-width: 160px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
}

/* Input with datalist (combobox) */
.ci-panel__learn-row input[list] {
  min-width: 200px;
  padding: 4px 8px;
  padding-right: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.ci-panel__learn-row input[list]:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
}

/* Datalist options styling (limited but works) */
.ci-ai-select {
  appearance: auto;
}

.ci-persistent-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.ci-persistent-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  flex-grow: 0;
  flex-basis: auto;
  min-width: 0;
	  cursor: pointer;
}

/* Linha de opções do aprendizado (loop + iterações) */
.ci-panel__learn-options {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ci-iterations-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--text-muted, #888);
}

.ci-iterations-field input[type="number"] {
  width: 60px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 12px;
  text-align: center;
  -moz-appearance: textfield;
}

.ci-iterations-field input[type="number"]::-webkit-inner-spin-button,
.ci-iterations-field input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

.ci-learn-progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted, #888);
  font-size: 13px;
}

.ci-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.ci-progress-fill {
  height: 100%;
  width: 40%;
  background: var(--primary, #3b82f6);
  animation: ci-pulse 1.5s infinite;
}

@keyframes ci-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Estatísticas ──────────────────────────────────────── */

.ci-panel__stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-muted, #888);
}

.ci-panel__stats strong {
  color: var(--text);
}

/* ── Filtros ───────────────────────────────────────────── */

.ci-panel__filters {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ci-filter {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}

.ci-filter.active {
  background: var(--primary, #3b82f6);
  color: #fff;
  border-color: transparent;
}

#ci-category-filter {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
}

/* ── Tabela ────────────────────────────────────────────── */

.ci-panel__table-container {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 200px;
}

.ci-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ci-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-soft, #f5f5f5);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--text-muted, #888);
  font-weight: 600;
}

.ci-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.ci-table tr:hover td {
  background: var(--bg-soft, rgba(0,0,0,0.02));
}

.ci-category-header td {
  background: var(--bg-soft, #f8f8f8);
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}

.ci-category-header:hover td {
  background: var(--border, #e5e5e5);
}

.ci-category-toggle {
  display: inline-block;
  width: 14px;
  font-size: 10px;
}

.status-active {
  color: var(--success, #16a34a);
  font-weight: 600;
}

.status-candidate {
  color: var(--warning, #f59e0b);
}

.ci-delete-btn {
  padding: 2px 6px;
  font-size: 12px;
  opacity: 0.6;
}

.ci-delete-btn:hover {
  opacity: 1;
}

/* ── Sinônimos ─────────────────────────────────────────── */

.ci-panel__synonyms {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--bg-card);
}

.ci-synonyms__header {
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.ci-synonyms__header:hover {
  color: var(--primary, #3b82f6);
}

.ci-synonyms__list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ci-synonym-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
}

.ci-synonym-row:hover {
  background: var(--bg-soft, rgba(0,0,0,0.03));
}

.ci-synonym-words {
  flex: 1;
}

.ci-synonym-actions {
  display: flex;
  gap: 4px;
}

.ci-synonym-actions .ghost-button {
  padding: 2px 8px;
  font-size: 12px;
}

/* ── Textarea auto-expansível ──────────────────────────── */

#ci-learn-input {
  flex: 1;
  min-width: 200px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  max-height: 120px;
}

#ci-learn-input:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
}

/* ── Modal de acompanhamento do aprendizado ────────────── */

.ci-learn-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.ci-learn-modal[hidden] {
  display: none;
}

.ci-learn-modal__dialog {
  width: min(760px, 92vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card, #111827);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.ci-learn-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ci-learn-modal__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  min-width: 0;
}

.ci-learn-modal__objective {
  color: var(--text-muted, #888);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-learn-modal__meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted, #888);
  white-space: nowrap;
}

.ci-learn-modal__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.ci-learn-modal__pulse.is-working {
  background: var(--success, #16a34a);
  animation: ci-pulse-dot 1.2s infinite;
}

@keyframes ci-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.ci-learn-modal__warning {
  padding: 6px 16px;
  font-size: 12px;
  color: var(--warning, #f59e0b);
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid var(--border);
}

.ci-learn-modal__log {
  flex: 1;
  min-height: 240px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 10px 16px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-soft, #0d1420);
}

.ci-learn-modal__log-line {
  color: var(--text, #e5edf7);
  white-space: pre-wrap;
  word-break: break-word;
}

.ci-learn-modal__log-line.is-warning {
  color: var(--warning, #f59e0b);
}

.ci-learn-modal__log-line.is-error {
  color: var(--danger, #ef4444);
}

.ci-learn-modal__result {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--border);
}

.ci-learn-modal__result.is-success { color: var(--success, #16a34a); }
.ci-learn-modal__result.is-error { color: var(--danger, #ef4444); }
.ci-learn-modal__result.is-cancelled { color: var(--text-muted, #888); }

.ci-learn-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

/* ── Danger button (Parar) ─────────────────────────────── */

.danger-button {
  background: var(--danger, #dc2626);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

/* ── Campo de busca ────────────────────────────────────── */

.ci-panel__search {
  margin-top: 2px;
}

.ci-panel__search input {
  width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
}

.ci-panel__search input:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
}

/* ── Botão editar ──────────────────────────────────────── */

.ci-edit-btn {
  margin-right: 2px;
}

/* ── Modal de edição de entrada ────────────────────────── */

.ci-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9100;
}

.ci-edit-modal[hidden] {
  display: none;
}

.ci-edit-modal__dialog {
  width: min(520px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card, #111827);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ci-edit-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ci-edit-modal__header strong {
  font-size: 14px;
}

.ci-edit-modal__close {
  font-size: 16px;
  padding: 0 6px;
}

.ci-edit-modal__dialog label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ci-edit-modal__dialog label span {
  font-size: 12px;
  color: var(--text-muted, #888);
}

.ci-edit-modal__dialog label small {
  font-size: 11px;
  color: var(--text-muted, #888);
}

.ci-edit-modal__dialog label input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input, var(--bg-card));
  color: var(--text);
  font-size: 13px;
}

.ci-edit-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
