/* ─────────────────────────────────────────────────────────────
   ALIEE Admin Portal — Light Theme
   ───────────────────────────────────────────────────────────── */

:root {
  --bg-page: #f5f7fa;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  --bg-hover: #f3f4f6;

  --border: #e5e7eb;
  --border-light: #f3f4f6;

  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;

  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;

  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.06), 0 8px 10px -6px rgba(0,0,0,0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 260px;
}

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

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand h1 span {
  color: var(--primary);
  font-weight: 400;
}

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

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

.sidebar-user span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-link {
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color 0.15s, background 0.15s;
}

.logout-link:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* ── Main Content ────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 36px;
  min-height: 100vh;
}

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

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
}

.breadcrumb-link {
  font-size: 0.82rem;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.breadcrumb-link:hover { text-decoration: underline; }

/* ── Status Dot ──────────────────────────────────────────── */

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: #d1d5db;
}

.status-dot.status-disconnected { background: var(--danger); }
.status-dot.status-starting,
.status-dot.status-connecting,
.status-dot.status-qr_ready     { background: var(--warning); animation: pulse-dot 1.5s infinite; }
.status-dot.status-authenticated { background: var(--primary); }
.status-dot.status-connected,
.status-dot.status-ready         { background: var(--success); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* ── Stats Grid (Dashboard) ──────────────────────────────── */

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue  { background: var(--primary-light); color: var(--primary); }
.stat-icon-green { background: var(--success-light); color: var(--success); }
.stat-icon-wa    { background: #ecfdf5; color: #25d366; }

.stat-body {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

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

/* ── Quick Actions (Dashboard) ───────────────────────────── */

.quick-actions-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
}

.action-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ── Demos Grid ──────────────────────────────────────────── */

.demos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.demo-card:hover { box-shadow: var(--shadow-md); }

.demo-card-active {
  border-color: var(--success);
  border-width: 2px;
}

.demo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.demo-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-card-title h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.demo-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.demo-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.4;
}

.demo-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-active   { background: var(--success-light); color: var(--success); }
.badge-neutral  { background: var(--bg-hover); color: var(--text-muted); }
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
  line-height: 1;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-success-outline {
  background: transparent;
  color: var(--success);
  border-color: var(--success);
}
.btn-success-outline:hover:not(:disabled) { background: var(--success-light); }

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-light); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ── Forms ────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.form-group input,
.form-group textarea,
.select-control {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  font-family: var(--font);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.form-group textarea {
  resize: vertical;
  line-height: 1.5;
}

.form-group input:focus,
.form-group textarea:focus,
.select-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ── Editor Meta Card ────────────────────────────────────── */

.editor-meta-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* ── Wizard Layout ───────────────────────────────────────── */

.wizard-layout {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 500px;
  overflow: hidden;
}

.wizard-sidebar {
  width: 200px;
  background: var(--bg-page);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.wizard-step:hover {
  color: var(--text);
  background: rgba(0,0,0,0.02);
}

.wizard-step.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left-color: var(--primary);
  font-weight: 600;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-step.active .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step-title {
  font-size: 0.82rem;
}

.wizard-body {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.wizard-form {
  flex: 1;
}

.wizard-panel {
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.2s ease;
}

.wizard-panel.active {
  display: flex;
}

.wizard-panel h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}

.panel-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.wizard-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

/* ── Paso 7: Voz y Canal ─────────────────────────────────── */

.voice-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-select {
  flex: 1;
}

.voice-loading-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.response-mode-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.response-mode-card {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg-page);
}

.response-mode-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.response-mode-card input[type="radio"] {
  display: none;
}

.response-mode-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.response-mode-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.response-mode-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.response-mode-body strong {
  font-size: 0.88rem;
  color: var(--text);
}

.response-mode-body span {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

@media (max-width: 600px) {
  .response-mode-group {
    grid-template-columns: 1fr;
  }
}

/* ── PDF Dropzone ────────────────────────────────────────── */

.pdf-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pdf-dropzone:hover,
.pdf-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.dropzone-main {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dropzone-sub {
  font-size: 0.78rem;
}

.pdf-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--primary);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(37,99,235,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── RAG Section ─────────────────────────────────────────── */

.rag-section {
  margin-top: 20px;
}

.rag-section h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.rag-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Data Table ──────────────────────────────────────────── */

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

.data-table th,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.data-table th {
  background: var(--bg-page);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 24px !important;
}

.mono {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

/* ── Chat ────────────────────────────────────────────────── */

.chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chat-toolbar-left,
.chat-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-toolbar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.select-control {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-width: 180px;
}

.chat-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: 520px;
  box-shadow: var(--shadow-sm);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 75%;
  animation: fadeIn 0.2s ease;
}

.msg-user {
  align-self: flex-end;
}

.msg-assistant {
  align-self: flex-start;
}

.msg-system {
  align-self: center;
  max-width: 100%;
  background: var(--bg-page);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.msg-sender {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  padding: 0 4px;
}

.msg-user .msg-sender { text-align: right; }

.msg-body {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg-user .msg-body {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.msg-assistant .msg-body {
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 2px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dotBlink 1.4s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBlink {
  0% { opacity: .2; }
  20% { opacity: 1; }
  100% { opacity: .2; }
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--border-light);
}

.chat-input-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  font-family: var(--font);
}

.chat-input-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.chat-input-bar input:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
}

/* ── WhatsApp View ───────────────────────────────────────── */

.wa-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.wa-status-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.wa-status-box strong {
  font-size: 0.95rem;
  display: block;
}

.wa-status-box p {
  font-size: 0.8rem;
  margin-top: 2px;
}

.wa-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.wa-actions button { flex: 1; }

.qr-area {
  text-align: center;
  padding: 16px;
  background: var(--bg-page);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.qr-frame {
  display: inline-block;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  margin: 12px 0;
}

#qrCanvas { display: block; width: 200px; height: 200px; }

.wa-active-demo-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* ── Console Log ─────────────────────────────────────────── */

.console-log {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  height: 400px;
  overflow-y: auto;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-error   { color: #f38ba8; }
.log-success { color: #a6e3a1; }
.log-info    { color: #89b4fa; }

/* ── Empty / Loading states ──────────────────────────────── */

.loading-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px;
  font-size: 0.9rem;
}

.empty-state-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}

.empty-state-card svg {
  margin-bottom: 12px;
}

.empty-state-card h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-card p {
  font-size: 0.88rem;
  margin-bottom: 16px;
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.modal-overlay.modal-visible { opacity: 1; }
.modal-overlay.modal-closing { opacity: 0; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  margin: 16px;
  transform: translateY(8px);
  transition: transform 0.15s ease;
}

.modal-visible .modal-card { transform: translateY(0); }

.modal-card-sm { max-width: 400px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 0;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 20px;
}

.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1) !important;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) { background: #dc2626; }

/* ── WhatsApp Multi-Demo Layout ──────────────────────────── */

.wa-multi-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.wa-demos-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wa-account-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  transition: box-shadow 0.15s;
}

.wa-account-card:hover {
  box-shadow: var(--shadow-sm);
}

.wa-account-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.wa-account-phone {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wa-phone-icon {
  font-size: 1.4rem;
}

.wa-phone-number {
  display: block;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.wa-phone-name {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.wa-account-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wa-account-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.wa-account-demo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-account-actions {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
}

.wa-section-divider {
  padding: 16px 0 8px;
  text-align: center;
  position: relative;
}

.wa-section-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px solid var(--border-light);
}

.wa-section-divider span {
  position: relative;
  background: var(--bg-card);
  padding: 0 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wa-demo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.wa-demo-row:last-child { border-bottom: none; }

.wa-demo-row.wa-unlinked {
  opacity: 0.7;
}

.wa-demo-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-demo-info strong {
  display: block;
  font-size: 0.92rem;
}

.wa-demo-info .text-sm {
  display: block;
  margin-top: 1px;
}

.wa-demo-actions {
  flex-shrink: 0;
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.form-select:focus {
  border-color: var(--primary);
}

/* ── Utility ─────────────────────────────────────────────── */

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    position: relative;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { padding: 12px 16px; border-bottom: none; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .nav-section { display: none; }
  .sidebar-footer { display: none; }
  .main-content { margin-left: 0; padding: 20px 16px; }
  body { flex-direction: column; }
  .wa-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .wizard-layout { flex-direction: column; }
  .wizard-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
  }
  .wizard-step { border-left: none; white-space: nowrap; padding: 8px 12px; }
  .wizard-step.active { border-left-color: transparent; border-bottom: 3px solid var(--primary); }
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .demos-grid { grid-template-columns: 1fr; }
  .chat-toolbar { flex-direction: column; align-items: stretch; }
}

/* ── Fonoteca ──────────────────────────────────────────────── */

.fonoteca-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.fonoteca-generator { padding: 24px; display: flex; flex-direction: column; gap: 18px; }

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
}

.fono-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font);
  line-height: 1.6;
}

.fono-char-count {
  text-align: right;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.fonoteca-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.fono-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--val, 95%), var(--border) var(--val, 95%));
  outline: none;
  margin: 8px 0 4px;
  cursor: pointer;
}
.fono-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.fono-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  cursor: pointer;
}

.fono-range-val {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

.fono-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text-muted);
}

.fono-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
}
.fono-status--info    { background: var(--primary-light); color: var(--primary); }
.fono-status--success { background: var(--success-light); color: var(--success); }
.fono-status--error   { background: var(--danger-light); color: var(--danger); }

.fono-generate-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: .9rem;
}

/* Spinner */
.fono-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fono-spin 0.7s linear infinite;
}
.fono-spinner--sm {
  width: 12px;
  height: 12px;
  border-color: rgba(37,99,235,0.25);
  border-top-color: var(--primary);
}
@keyframes fono-spin { to { transform: rotate(360deg); } }

/* Clips panel */
.fonoteca-clips-card { padding: 24px; }

.fono-clips-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.fono-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
}
.fono-empty svg { opacity: .35; }
.fono-empty p { font-size: .875rem; }

.fono-clip-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.fono-clip-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

.fono-clip-text {
  font-size: .875rem;
  color: var(--text);
  line-height: 1.5;
  font-style: italic;
}

.fono-clip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
}

.fono-tag {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.fono-tag--tone {
  background: var(--primary-light);
  border-color: transparent;
  color: var(--primary);
}

.fono-inline-player {
  margin: 4px 0;
}

.fono-clip-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .fonoteca-layout { grid-template-columns: 1fr; }
  .fonoteca-two-col { grid-template-columns: 1fr; }
}
