/* style.css — dark theme pour le dashboard Dikta */

:root {
  --bg: #0d0d1a;
  --bg-card: #161627;
  --bg-card-hover: #1e1e35;
  --bg-table-odd: #13132200;
  --bg-table-hover: #1e1e35;
  --accent: #6366f1;
  --accent-dim: #3b3bcc44;
  --text: #e2e2f0;
  --text-dim: #8888aa;
  --text-muted: #555577;
  --border: #2a2a45;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

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

html {
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

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

.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.logo-icon {
  font-size: 1.2rem;
}
.logo-text {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.refresh-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* ─── Tabs ────────────────────────────────────────── */

.tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
  display: flex;
  gap: 0.25rem;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-bottom: 2px solid transparent;
}

.tab:hover {
  background: var(--bg-card);
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── Tab content ─────────────────────────────────── */

.tab-content {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-content.active {
  display: block;
}

/* ─── KPI cards ───────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: background 0.15s;
}

.kpi-card:hover {
  background: var(--bg-card-hover);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.skeleton .kpi-value,
.skeleton .kpi-sub {
  background: var(--border);
  border-radius: 4px;
  color: transparent;
  min-width: 60px;
}

/* ─── Section header ──────────────────────────────── */

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section-sub code {
  font-family: monospace;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* ─── Tables ──────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead tr {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: default;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-table-hover);
}

.data-table td {
  padding: 0.75rem 1rem;
  color: var(--text);
  vertical-align: middle;
}

.data-table tr.clickable {
  cursor: pointer;
}
.data-table tr.clickable:hover {
  background: var(--bg-card-hover);
}
.data-table tr.selected {
  background: var(--accent-dim) !important;
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem !important;
  font-size: 0.875rem;
}

/* ─── Status dots ─────────────────────────────────── */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.dot-green {
  background: var(--green);
}
.dot-yellow {
  background: var(--yellow);
}
.dot-gray {
  background: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-ok {
  background: #22c55e22;
  color: var(--green);
}
.badge-error {
  background: #ef444422;
  color: var(--red);
}
.badge-running {
  background: #3b82f622;
  color: var(--blue);
}
.badge-done {
  background: #22c55e22;
  color: var(--green);
}
.badge-cancelled {
  background: #f59e0b22;
  color: var(--yellow);
}

.channel-badge {
  display: inline-block;
  padding: 0.1em 0.55em;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 500;
  background: #6366f122;
  color: var(--accent);
}

.crm-badge {
  display: inline-block;
  padding: 0.1em 0.55em;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.crm-badge-axonaut {
  background: #f59e0b22;
  color: var(--yellow);
}

.crm-badge-sellsy {
  background: #3b82f622;
  color: var(--blue);
}

.apikey-yes {
  color: var(--green);
  font-size: 0.8rem;
}
.apikey-no {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.text-mono {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.text-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ─── Conversation panel ──────────────────────────── */

.conversation-panel {
  margin-top: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.conversation-panel.hidden {
  display: none;
}

.conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.9rem;
  background: var(--bg-card);
}

.conv-messages {
  padding: 1rem 1.25rem;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.msg-bubble {
  max-width: 70%;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble.in {
  align-self: flex-start;
  background: #2a2a45;
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.msg-bubble.out {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.msg-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.msg-in-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.msg-out-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-tokens {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.conv-pagination {
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

/* ─── LLM session expandable ──────────────────────── */

.llm-row-detail {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.llm-detail-inner {
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.llm-detail-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.llm-detail-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.llm-detail-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

/* ─── Pagination ──────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.page-info {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary.hidden {
  display: none;
}

/* ─── Scrollbars ──────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.config-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.config-field {
  margin-bottom: 1.25rem;
}

.config-field:last-child {
  margin-bottom: 0;
}

.config-field-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.config-field-inline .config-label {
  min-width: 200px;
  margin-bottom: 0;
}

.config-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.config-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.config-hint code {
  font-family: monospace;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
}

.config-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: monospace;
  font-size: 0.82rem;
  padding: 0.6rem 0.75rem;
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.config-textarea-lg {
  min-height: 200px;
}

.config-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.config-select,
.config-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.15s;
}

.config-select:focus,
.config-input:focus {
  outline: none;
  border-color: var(--accent);
}

.config-input {
  width: 110px;
}

.btn-save {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  margin-top: 0.5rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.config-field-inline .btn-save {
  margin-top: 0;
}

.btn-save:hover {
  background: var(--accent);
  color: #fff;
}

.btn-save.btn-save-ok {
  background: #16652a;
  border-color: var(--green);
  color: var(--green);
}

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  transition: opacity 0.15s;
}

.btn-primary:hover {
  opacity: 0.85;
}

/* Tools list */

.tools-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: background 0.1s;
}

.tool-row:hover {
  background: var(--bg-card-hover);
}

.tool-info {
  flex: 1;
}

.tool-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  font-family: monospace;
}

.tool-desc {
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.config-tools-footer {
  display: flex;
  justify-content: flex-end;
}

/* Toggle switch */

.tool-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.tool-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.tool-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background 0.2s;
}

.tool-toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.tool-toggle input:checked + .tool-toggle-slider {
  background: var(--accent-dim);
}

.tool-toggle input:checked + .tool-toggle-slider::before {
  transform: translateX(16px);
  background: var(--accent);
}

/* ─── Btn info (icône ℹ dans le tableau) ──────────── */

.btn-info {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}

.btn-info:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── User CRM modal ──────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-section-meta {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.modal-meta-title {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.modal-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.modal-row-badge {
  align-items: center;
}

.modal-key {
  min-width: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.modal-val {
  color: var(--text);
  word-break: break-word;
}
