/* ARGOS — sistema de diseño (tema oscuro por defecto; claro vía [data-theme="light"]).
   Los nombres de variables y de clases se mantienen: las pantallas existentes
   adoptan el nuevo estilo sin cambiar su marcado. */

:root {
  --bg:       #09090b;
  --surface:  #111113;
  --surface-2:#18181b;
  --border:   #26262b;
  --border-h: #3a3a40;
  --accent:   #4fe3b0;      /* menta */
  --accent-h: #6ff0c3;
  --accent-bg: rgba(79,227,176,.12);
  --accent-fg: #04140d;     /* texto sobre menta */
  --green:    #4fe3b0;
  --red:      #f87171;
  --yellow:   #fbbf24;
  --blue:     #7dd3fc;
  --text:     #fafafa;
  --muted:    #9a9aa3;
  --radius:   10px;
  --radius-lg:14px;
  --shadow:   0 8px 30px rgba(0,0,0,.35);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg:#fafafa; --surface:#ffffff; --surface-2:#f4f4f5; --border:#e4e4e7; --border-h:#d0d0d5;
  --accent:#0f9d73; --accent-h:#0b8460; --accent-bg:rgba(15,157,115,.1); --accent-fg:#ffffff;
  --green:#0b8460; --red:#dc2626; --yellow:#b45309; --blue:#0369a1;
  --text:#18181b; --muted:#63636b; --shadow:0 8px 30px rgba(0,0,0,.08);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: var(--accent-bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* NAV */
nav {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; margin-right: 22px; }
.nav-brand-logo { height: 32px; width: auto; display: block; }
:root[data-theme="light"] .nav-brand-logo { filter: invert(1); }
nav > a:not(.nav-brand) {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: color .15s, background .15s;
}
nav > a:not(.nav-brand):hover, nav > a.active { color: var(--text); background: var(--surface-2); }
.nav-badge, .wa-badge-pill { /* contador de WhatsApp */
  background: var(--accent) !important; color: var(--accent-fg) !important;
}

/* NAV — iconos y zona de usuario */
.nav-ic { margin-right: 7px; opacity: .85; flex: none; }
nav > a.active .nav-ic { color: var(--accent); opacity: 1; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-user {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: 13px;
  padding: 4px 12px 4px 4px; border-radius: 999px;
}
.nav-user-av {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.nav-logout {
  background: none; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font: 500 13px var(--font); padding: 7px 14px; border-radius: var(--radius);
  transition: color .15s, border-color .15s, background .15s;
}
.nav-logout:hover { color: var(--red); border-color: var(--red); background: rgba(248,113,113,.08); }

/* ENCABEZADO DE PÁGINA */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-tools select { width: auto; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.page-tools label { margin: 0; }

/* GRILLAS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin-top: 12px; font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.stats-grid > * { animation: fade-in .35s ease both; }
.stats-grid > *:nth-child(2) { animation-delay: .05s; }
.stats-grid > *:nth-child(3) { animation-delay: .1s; }
.stats-grid > *:nth-child(4) { animation-delay: .15s; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* COMPONENTES COMUNES DE PANTALLA */
.table-wrap { overflow-x: auto; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; padding: 16px 20px; }
.filters .field { flex: 0 1 180px; min-width: 140px; }
.filters .field.grow { flex: 1 1 240px; }
.filters label { margin-bottom: 4px; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }
.back { color: var(--muted); text-decoration: none; font-size: 13px; transition: color .15s; }
.back:hover { color: var(--text); }
.head-left { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.head-left h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.chan { display: inline-flex; align-items: center; gap: 6px; }
.chan svg { flex: none; color: var(--muted); }
.badge-chan { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px; transition: color .15s, background .15s; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.stats-grid.cols { grid-template-columns: repeat(var(--cols, 4), 1fr); }
@media (max-width: 900px) { .stats-grid.cols { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .stats-grid.cols { grid-template-columns: 1fr; } }

/* Métricas (llamadas y WhatsApp) */
.wm-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.wm-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; transition: border-color .2s, transform .2s; }
.wm-kpi:hover { border-color: var(--border-h); transform: translateY(-1px); }
.wm-kpi .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; font-weight: 500; }
.wm-kpi .val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.wm-kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.wm-kpi .val.green { color: var(--green); } .wm-kpi .val.blue { color: var(--accent-h); }
.wm-kpi .val.yellow { color: var(--yellow); } .wm-kpi .val.red { color: var(--red); }
.wm-periods { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.wm-periods a { padding: 6px 12px; border-radius: var(--radius); font-size: 13px; font-weight: 500; text-decoration: none;
                background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s; }
.wm-periods a:hover { color: var(--text); border-color: var(--border-h); }
.wm-periods a.on { background: var(--accent-bg); border-color: rgba(79,227,176,.35); color: var(--accent); }
:root[data-theme="light"] .wm-periods a.on { border-color: rgba(18,184,134,.4); }
.wm-chart { display: flex; align-items: flex-end; gap: 2px; height: 190px; padding-top: 8px; }
.wm-day { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.wm-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 1px; }
.wm-bar { flex: 1; max-width: 10px; border-radius: 3px 3px 0 0; min-height: 0; transition: opacity .15s; }
.wm-day:hover .wm-bar { opacity: .8; }
.wm-bar.s { background: var(--blue); } .wm-bar.r { background: var(--green); }
.wm-bar.ok { background: var(--green); } .wm-bar.vm { background: var(--yellow); } .wm-bar.fl { background: var(--red); }
.wm-lbl { height: 18px; font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; }
.wm-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.wm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 800px) { .wm-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .wm-kpis { grid-template-columns: 1fr; } }
code { font: 12px var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 0 0 9px; cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }
tr.unread td { background: var(--accent-bg); }
tr.unread:hover td { background: var(--accent-bg); }

/* Formulario de campaña */
.form-narrow { max-width: 640px; }
.choices { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.choice {
  display: flex; align-items: center; gap: 10px; flex: 1 1 200px; margin: 0;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--border-h); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.choice input { width: auto; accent-color: var(--accent); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.code-chip { background: var(--surface-2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 6px; font: 12px var(--mono); }
.subcard { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.upload-zone svg { color: var(--accent); }

/* BOTÓN DE TEMA */
.theme-toggle {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); color: var(--muted); border-radius: var(--radius);
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-h); background: var(--surface-2); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }

/* LAYOUT */
.page { max-width: 1280px; margin: 0 auto; padding: 32px; animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } * { transition: none !important; } }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border-h); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

/* BOTONES */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font); font-size: 13px; font-weight: 500; line-height: 1.4;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s, opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: 1; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
}
.badge-pending    { background: rgba(251,191,36,.12); color: var(--yellow); }
.badge-processing { background: rgba(125,211,252,.12); color: var(--blue); }
.badge-completed  { background: var(--accent-bg); color: var(--green); }
.badge-failed     { background: rgba(248,113,113,.12); color: var(--red); }
.badge-skipped    { background: var(--surface-2); color: var(--muted); }
.badge-replied    { background: rgba(125,211,252,.12); color: var(--blue); }
:root[data-theme="light"] .badge-pending { background: rgba(180,83,9,.1); }
:root[data-theme="light"] .badge-failed { background: rgba(220,38,38,.1); }
:root[data-theme="light"] .badge-processing, :root[data-theme="light"] .badge-replied { background: rgba(3,105,161,.1); }

/* Indicador de WhatsApp sin leer */
.wa-dot { display:inline-block; width:9px; height:9px; border-radius:50%; background:var(--accent);
  box-shadow:0 0 0 3px var(--accent-bg); margin-right:6px; vertical-align:middle; }
.nav-badge { display:inline-block; min-width:18px; padding:1px 6px; margin-left:6px; border-radius:999px;
  font-size:11px; font-weight:700; text-align:center; line-height:16px; }

/* TABLA */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 0 12px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tr:hover td { background: var(--surface-2); }

/* FORM */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=search], input[type=file], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
::placeholder { color: var(--muted); opacity: .8; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--border-h); transform: translateY(-1px); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }
.stat-value.blue  { color: var(--accent-h); }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--accent-bg); color: var(--green); border-color: rgba(79,227,176,.3); }
.alert-error   { background: rgba(248,113,113,.1); color: var(--red); border-color: rgba(248,113,113,.3); }
.alert-warning { background: rgba(251,191,36,.1); color: var(--yellow); border-color: rgba(251,191,36,.3); }
.alert-info    { background: rgba(125,211,252,.1); color: var(--blue); border-color: rgba(125,211,252,.3); }

/* UPLOAD ZONE */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 40px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-bg); }
.upload-zone p { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* TRANSCRIPT */
.transcript {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; max-height: 300px; overflow-y: auto; font-size: 13px; line-height: 1.8;
}
.turn-agent { color: var(--accent); }
.turn-client { color: var(--text); }

/* HTMX loading */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  z-index: 200; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 480px; box-shadow: var(--shadow);
  animation: fade-in .2s ease;
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; letter-spacing: -.01em; }

/* Scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-h) transparent; }

/* RESPONSIVE */
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  nav { padding: 8px 16px; }
  .nav-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .page { padding: 20px 16px; }
  .card { padding: 18px; }
  .stats-grid { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
