/* Minimal styling for the Mia admin dashboard. No framework, no theme
   switcher — just legible, mobile-friendly defaults. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1a1f2b;
  background: #f7f8fa;
}

/* Topbar -------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e4e7ec;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 16px;
}
.env-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f4;
  color: #5b6378;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.tabs a {
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #5b6378;
  font-weight: 500;
}
.tabs a:hover { background: #f0f2f6; color: #1a1f2b; }
.tabs a.active { background: #e8effc; color: #1d4ed8; }

.auth-state {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-off { background: #cbd0d8; }
.dot-on  { background: #22c55e; }

.link-btn {
  background: none;
  border: 1px solid #d1d5db;
  color: #1d4ed8;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.link-btn:hover { background: #eef0f4; }

/* Views --------------------------------------------------------------- */
main {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}
.view { animation: fadein 0.15s ease-out; }
.view.hidden { display: none; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header h2 { margin: 0; font-size: 22px; }
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.controls label { color: #5b6378; }
.controls select, .controls input {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}
.muted { color: #8b93a3; font-size: 12px; }

/* Metrics cards ------------------------------------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 16px;
}
.card h3 {
  margin: 0 0 10px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5b6378;
}
.metric-pair {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.metric-period {
  font-size: 28px;
  font-weight: 700;
}
.metric-cumulative {
  color: #5b6378;
  font-size: 13px;
}
.metric-cumulative strong { color: #1a1f2b; font-weight: 600; }
.metric-rate {
  font-size: 13px;
  color: #5b6378;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #f0f2f6;
}
.metric-row:last-child { border-bottom: none; }
.metric-row .label { color: #5b6378; }
.metric-row .value { font-variant-numeric: tabular-nums; }

.violation-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.violation-type {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #b91c1c;
}

/* Tables ------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f2f6;
  vertical-align: top;
}
.data-table th {
  background: #f7f8fa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6378;
  font-weight: 600;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfc; }

/* Status pills ------------------------------------------------------- */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill-done       { background: #dcfce7; color: #166534; }
.pill-pending    { background: #fef3c7; color: #92400e; }
.pill-failed     { background: #fee2e2; color: #991b1b; }
.pill-completed  { background: #dcfce7; color: #166534; }
.pill-in-progress{ background: #dbeafe; color: #1e40af; }

.handoff-card {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.handoff-card .candidate {
  font-weight: 600;
  font-size: 15px;
}
.handoff-card .meta {
  color: #5b6378;
  font-size: 12px;
  margin-top: 2px;
}
.handoff-steps {
  display: flex;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.handoff-step {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  background: #f0f2f6;
  color: #5b6378;
}
.handoff-step.done    { background: #dcfce7; color: #166534; }
.handoff-step.pending { background: #fef3c7; color: #92400e; }
.handoff-step.failed  { background: #fee2e2; color: #991b1b; }
.handoff-actions {
  margin-top: 8px;
}

/* OOO dialog --------------------------------------------------------- */
dialog {
  border: none;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
dialog::backdrop { background: rgba(0,0,0,0.3); }
dialog h3 { margin: 0 0 8px 0; }
#ooo-form label { display: block; margin: 12px 0; }
#ooo-form input { width: 100%; margin-top: 4px; }
.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.dialog-buttons button {
  font: inherit;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
}
#ooo-save { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
#ooo-clear { color: #b91c1c; border-color: #fca5a5; }

.error-banner {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Conversations list — reason code + summary preview ------------------ */
.reason-code {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #5b6378;
  background: #f0f2f6;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}
.summary-preview {
  color: #5b6378;
  font-size: 12px;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-confidence-low {
  background: #fef3c7;
  color: #92400e;
  margin-left: 4px;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eef0f4; }

/* Conversation detail view -------------------------------------------- */
.detail-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e4e7ec;
}
.detail-back {
  text-decoration: none;
  color: #1d4ed8;
  font-weight: 500;
}
.detail-back:hover { text-decoration: underline; }
.detail-candidate {
  font-size: 18px;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
}
@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* Transcript ---------------------------------------------------------- */
.transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 16px;
  max-height: 70vh;
  overflow-y: auto;
}
.bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.bubble-row.outbound {
  align-self: flex-end;
  align-items: flex-end;
}
.bubble-row.inbound {
  align-self: flex-start;
  align-items: flex-start;
}
.bubble-meta {
  font-size: 11px;
  color: #8b93a3;
  margin-bottom: 2px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.bubble {
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}
.bubble-inbound  .bubble { background: #f0f2f6; color: #1a1f2b; border-bottom-left-radius: 4px; }
.bubble-outbound .bubble { background: #dbeafe; color: #1a1f2b; border-bottom-right-radius: 4px; }

.pill-conf {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill-conf-high   { background: #dcfce7; color: #166534; }
.pill-conf-medium { background: #fef3c7; color: #92400e; }
.pill-conf-low    { background: #fee2e2; color: #991b1b; }

/* Slots panel --------------------------------------------------------- */
.slots-panel {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
}
.slots-panel h3 {
  margin: 0 0 10px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5b6378;
}
.slots-list dt {
  font-size: 11px;
  color: #5b6378;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
}
.slots-list dt:first-child { margin-top: 0; }
.slots-list dd {
  margin: 2px 0 0 0;
  color: #1a1f2b;
}
.slots-list dd.empty { color: #cbd0d8; font-style: italic; }
.slots-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0f2f6;
}
.slots-section p {
  margin: 6px 0 0 0;
  line-height: 1.5;
}
.notes-list {
  margin: 4px 0 0 0;
  padding-left: 18px;
}
.notes-list li { margin-bottom: 2px; }
