/* ============================================================
   Auditor de Radios — sistema visual (consola de ingeniería)
   Tokens claro/oscuro + componentes
   ============================================================ */

:root {
  --bg:        #f4f6f8;
  --surface:   #ffffff;
  --surface-2: #eef1f4;
  --surface-3: #e6eaee;
  --border:    #dde2e8;
  --border-2:  #cbd2da;
  --text:      #141a20;
  --text-2:    #586271;
  --text-3:    #8a93a0;

  --accent:      oklch(0.56 0.15 252);
  --accent-fg:   #ffffff;
  --accent-soft: oklch(0.95 0.03 252);
  --accent-bd:   oklch(0.85 0.06 252);

  --ok:      oklch(0.56 0.13 152);
  --ok-soft: oklch(0.95 0.04 152);
  --ok-bd:   oklch(0.82 0.08 152);

  --dead:      oklch(0.57 0.20 25);
  --dead-soft: oklch(0.95 0.04 25);
  --dead-bd:   oklch(0.85 0.09 25);

  --warn:      oklch(0.66 0.14 70);
  --warn-fg:   oklch(0.34 0.08 70);
  --warn-soft: oklch(0.95 0.05 80);
  --warn-bd:   oklch(0.82 0.10 75);

  --ai:      oklch(0.55 0.18 295);
  --ai-soft: oklch(0.95 0.04 295);
  --ai-bd:   oklch(0.85 0.08 295);

  --ftp:      oklch(0.58 0.12 175);
  --ftp-soft: oklch(0.95 0.04 175);
  --ftp-bd:   oklch(0.82 0.07 175);

  --shadow-sm: 0 1px 2px rgba(20,26,32,.06), 0 1px 3px rgba(20,26,32,.04);
  --shadow-md: 0 2px 6px rgba(20,26,32,.07), 0 6px 18px rgba(20,26,32,.06);
  --shadow-lg: 0 12px 32px rgba(20,26,32,.14), 0 4px 10px rgba(20,26,32,.08);

  --r-sm: 6px;
  --r:    9px;
  --r-lg: 14px;

  --nav-h: 56px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "General Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  --bg:        #0b0d11;
  --surface:   #14171d;
  --surface-2: #1a1e25;
  --surface-3: #222731;
  --border:    #262b34;
  --border-2:  #333a45;
  --text:      #e8ebef;
  --text-2:    #99a2ae;
  --text-3:    #6b7480;

  --accent:      oklch(0.66 0.15 252);
  --accent-fg:   #0b0d11;
  --accent-soft: oklch(0.30 0.07 252);
  --accent-bd:   oklch(0.42 0.09 252);

  --ok:      oklch(0.72 0.15 152);
  --ok-soft: oklch(0.30 0.06 152);
  --ok-bd:   oklch(0.42 0.08 152);

  --dead:      oklch(0.68 0.18 25);
  --dead-soft: oklch(0.30 0.08 25);
  --dead-bd:   oklch(0.44 0.10 25);

  --warn:      oklch(0.78 0.14 75);
  --warn-fg:   oklch(0.86 0.12 80);
  --warn-soft: oklch(0.31 0.07 70);
  --warn-bd:   oklch(0.46 0.09 72);

  --ai:      oklch(0.72 0.16 295);
  --ai-soft: oklch(0.31 0.08 295);
  --ai-bd:   oklch(0.44 0.10 295);

  --ftp:      oklch(0.72 0.11 175);
  --ftp-soft: oklch(0.30 0.05 175);
  --ftp-bd:   oklch(0.42 0.07 175);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}

::selection { background: var(--accent-soft); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 1; }
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.t-ok   { color: var(--ok); }
.t-dead { color: var(--dead); }
.t-ai   { color: var(--ai); }

h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 22px; }
.page { padding: 28px 0 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.row { display: flex; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { align-items: center; }
.grow { flex: 1; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { height: var(--nav-h); display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 15px; }
.brand-name .accent { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.nav-link {
  padding: 7px 11px; border-radius: var(--r-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-spacer { flex: 1; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user { font-size: 12.5px; color: var(--text-2); }
.nav-user .mono { color: var(--text); }
.nav-toggle { display: none; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: var(--r-sm); cursor: pointer; transition: .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-2); }

/* mobile menu */
.mobile-menu { display: none; }

@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-user { display: none; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); border-radius: var(--r-sm); cursor: pointer;
  }
  .mobile-menu.open {
    display: block; position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 49;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md); padding: 8px;
  }
  .mobile-menu .nav-link { display: block; padding: 11px 12px; font-size: 15px; }
  .mobile-menu .mm-user { padding: 11px 12px; color: var(--text-2); font-size: 13px; border-top: 1px solid var(--border); margin-top: 6px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font-family: var(--sans);
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .15s; white-space: nowrap;
  line-height: 1;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, black); }
.btn-success { background: var(--ok); border-color: transparent; color: #fff; }
.btn-success:hover { background: color-mix(in oklch, var(--ok) 88%, black); }
.btn-ftp { background: var(--ftp); border-color: transparent; color: #fff; }
.btn-ftp:hover { background: color-mix(in oklch, var(--ftp) 88%, black); }
.btn-danger { background: transparent; border-color: var(--dead-bd); color: var(--dead); }
.btn-danger:hover { background: var(--dead-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px; }
.card-hover { cursor: pointer; transition: .15s; }
.card-hover:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 100px; font-size: 11.5px; font-weight: 600; line-height: 1.4;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-running, .badge-searching { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-bd); }
.badge-ready  { color: var(--warn-fg); background: var(--warn-soft); border-color: var(--warn-bd); }
.badge-done   { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-bd); }
.badge-error  { color: var(--dead); background: var(--dead-soft); border-color: var(--dead-bd); }
.badge-ai     { color: var(--ai); background: var(--ai-soft); border-color: var(--ai-bd); }
.badge-approved { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-bd); }
.badge-neutral { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
.badge-paused { color: var(--text-2); background: var(--surface-2); border-color: var(--border-2); }
.badge-role-admin { color: var(--ai); background: var(--ai-soft); border-color: var(--ai-bd); }
.badge-role-user { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
.badge-running .dot, .badge-searching .dot { animation: pulse 1.3s ease-in-out infinite; }
.badge-ready .dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

/* ---------- metric cards ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 15px 16px; position: relative; overflow: hidden; }
.metric::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .85; }
.metric.m-ok::before { background: var(--ok); }
.metric.m-dead::before { background: var(--dead); }
.metric.m-accent::before { background: var(--accent); }
.metric.m-neutral::before { background: var(--text-3); }
.metric-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-family: var(--mono); line-height: 1; }
.metric-label { font-size: 12px; color: var(--text-2); margin-top: 7px; }

/* ---------- progress ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 100px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 100px; transition: width .5s ease; position: relative; }
.progress-bar.searching { background: var(--ai); }
.progress-bar::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- spinner ---------- */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- banner ---------- */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r-sm); font-size: 13.5px; border: 1px solid transparent; }
.banner-error { background: var(--dead-soft); border-color: var(--dead-bd); color: var(--dead); }
.banner-success { background: var(--ok-soft); border-color: var(--ok-bd); color: var(--ok); }
.banner-warn { background: var(--warn-soft); border-color: var(--warn-bd); color: var(--warn-fg); }
.banner-info { background: var(--accent-soft); border-color: var(--accent-bd); color: var(--accent); }
.banner strong { font-weight: 600; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.input, .select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); font-family: var(--sans); font-size: 14px; transition: .15s;
}
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.input::placeholder { color: var(--text-3); }
.input-sm { padding: 6px 9px; font-size: 13px; }
.hint { font-size: 12px; color: var(--text-3); }
.hint code { font-family: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; color: var(--text-2); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 11px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 100px; background: var(--surface-3); border: 1px solid var(--border-2); transition: .18s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: .18s; }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch .switch-text { font-size: 13.5px; color: var(--text); }
.switch .switch-text small { display: block; color: var(--text-3); font-size: 12px; }

.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }
.checkbox.danger input { accent-color: var(--dead); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 13px; font-size: 11.5px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 10px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .url { font-family: var(--mono); font-size: 12px; color: var(--text-2); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.status-dot .d { width: 7px; height: 7px; border-radius: 50%; }
.status-dot.ok .d { background: var(--ok); }
.status-dot.dead .d { background: var(--dead); }
.status-dot.ok { color: var(--ok); }
.status-dot.dead { color: var(--dead); }

/* ---------- candidate / audio ---------- */
.candidate { border: 1px solid var(--border); border-radius: var(--r); padding: 13px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.candidate.approved { border-color: var(--accent-bd); background: var(--accent-soft); }
.cand-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.cand-meta .mono { color: var(--text); }

.audio { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 11px; }
.audio-play { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; border: none; background: var(--accent); color: var(--accent-fg); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: .15s; }
.audio-play:hover { background: color-mix(in oklch, var(--accent) 85%, black); }
.audio-wave { flex: 1; display: flex; align-items: center; gap: 2.5px; height: 24px; }
.audio-wave .bar { flex: 1; background: var(--border-2); border-radius: 2px; height: 30%; transition: .15s; }
.audio.playing .audio-wave .bar { background: var(--accent); animation: eq 0.9s ease-in-out infinite; }
.audio-time { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); min-width: 38px; text-align: right; }
@keyframes eq { 0%,100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

/* ---------- dead radio card ---------- */
.dead-card { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.dead-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dead-head.with-accent { border-left: 3px solid var(--dead); }
.dead-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.orig-url { font-family: var(--mono); font-size: 12px; color: var(--text-2); word-break: break-all; background: var(--surface-2); padding: 8px 11px; border-radius: var(--r-sm); border: 1px solid var(--border); }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 54px 24px; color: var(--text-2); border: 1px dashed var(--border-2); border-radius: var(--r-lg); background: var(--surface); }
.empty .emoji { font-size: 30px; margin-bottom: 10px; opacity: .7; }
.empty h3 { color: var(--text); margin-bottom: 5px; }

/* ---------- dropzone ---------- */
.dropzone { border: 1.5px dashed var(--border-2); border-radius: var(--r); padding: 26px; text-align: center; cursor: pointer; transition: .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { color: var(--text-3); margin-bottom: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 100px; font-size: 12.5px; font-family: var(--mono); }
.file-chip .x { cursor: pointer; color: var(--text-3); display: inline-flex; }
.file-chip .x:hover { color: var(--dead); }

/* ---------- segmented (direcciones) ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; color: var(--text-2); font-family: var(--sans); font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 5px; cursor: pointer; transition: .15s; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.kv { display: flex; gap: 8px; font-size: 13px; }
.kv .k { color: var(--text-3); min-width: 92px; }
.pill-link { font-size: 12.5px; color: var(--accent); cursor: pointer; }
.tag-time { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); }
.scroll-soft { scrollbar-width: thin; }
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.shake { animation: shake .4s ease; }
@keyframes shake { 10%,90% { transform: translateX(-1px); } 20%,80% { transform: translateX(2px); } 30%,50%,70% { transform: translateX(-4px); } 40%,60% { transform: translateX(4px); } }

@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 0 16px; }
  .page-head { align-items: flex-start; }
}
