/* ============================================================
   Zentria — dashboard.css
   Panel de estadísticas de visitas (Aviso Legal · 5 dblclicks
   + código 1235). Tema claro/oscuro vía variables del sitio.
   ============================================================ */

.zt-dash {
  margin: 40px auto 72px;
  padding: 0 16px;
  max-width: 1280px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.zt-dash.open { opacity: 1; transform: none; }

.zt-dash-inner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 24px;
  overflow: hidden;
}
@media (max-width: 640px) { .zt-dash-inner { padding: 16px; border-radius: 16px; } }

/* ---------- cabecera ---------- */
.zt-dash-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.zt-dash-head h2 {
  font-size: clamp(19px, 3vw, 24px);
  display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.02em;
}
.zt-dash-head h2 svg { width: 22px; height: 22px; color: var(--accent); }
.zt-dash-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.zt-dash-close {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 8px 16px;
  font: 600 13px/1 var(--font-sans, system-ui, sans-serif);
  cursor: pointer; transition: all 0.2s ease;
}
.zt-dash-close svg { width: 15px; height: 15px; }
.zt-dash-close:hover { color: var(--fg); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.zt-dash-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- barra de herramientas ---------- */
.zt-dash-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.zt-dash-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zt-dash-range select {
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 14px; font: 500 13.5px/1 var(--font-sans, system-ui, sans-serif);
  cursor: pointer; min-width: 170px;
}
.zt-dash-range select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.zt-dash-custom { display: inline-flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.zt-dash-datefield { display: flex; flex-direction: column; gap: 4px; }
.zt-dash-datefield label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.zt-dash-datefield input {
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 7px 10px; font: 500 13px/1 var(--font-sans, system-ui, sans-serif);
  color-scheme: light dark;
}
.zt-dash-datefield input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.zt-dash-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zt-export-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-right: 2px; }

.zt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px; padding: 8px 14px;
  font: 600 12.5px/1 var(--font-sans, system-ui, sans-serif);
  cursor: pointer; transition: all 0.2s ease;
}
.zt-btn svg { width: 13px; height: 13px; }
.zt-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); transform: translateY(-1px); }
.zt-btn:active { transform: none; }
.zt-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.zt-btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.zt-btn-ghost:hover { color: var(--fg); border-color: var(--accent); }

/* ---------- KPIs ---------- */
.zt-kpis {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  margin-bottom: 22px;
}
.zt-kpi {
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 6%, var(--card)), var(--card) 60%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; min-height: 74px;
}
.zt-kpi .k {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem); font-weight: 600;
  letter-spacing: -0.02em; color: var(--fg);
}
.zt-kpi .v {
  font-size: 10.5px; color: var(--muted); margin-top: 5px;
  text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.35;
}

/* ---------- rejilla de tarjetas ---------- */
.zt-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  margin-bottom: 14px;
}
.zt-card {
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 14px;
}
.zt-card h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 600; margin-bottom: 14px;
}
.zt-h3-second { margin-top: 22px; }
.zt-card-wide { grid-column: 1 / -1; }

.zt-chart-wrap { position: relative; height: 235px; }
.zt-chart-wrap canvas { display: block; width: 100%; height: 100%; }
.zt-donut-wrap { height: 170px; max-width: 260px; margin: 0 auto; }

.zt-chart-legend, .zt-donut-legend {
  display: flex; flex-wrap: wrap; gap: 10px 18px;
  margin-top: 10px; font-size: 12px; color: var(--muted);
}
.zt-lg-item { display: inline-flex; align-items: center; gap: 7px; }
.zt-lg-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.zt-lg-item b { color: var(--fg); font-weight: 600; }

/* ---------- barras horizontales HTML ---------- */
.zt-hbars { display: flex; flex-direction: column; gap: 9px; }
.zt-hbar { display: grid; grid-template-columns: minmax(84px, 150px) 1fr auto; align-items: center; gap: 10px; }
.zt-hbar-label {
  font-size: 12.5px; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zt-hbar-track {
  height: 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  overflow: hidden; display: block;
}
.zt-hbar-fill { display: block; height: 100%; border-radius: 999px; opacity: 0.9; }
.zt-hbar-val { font-size: 12px; color: var(--fg); font-weight: 600; white-space: nowrap; }
.zt-hbar-val em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 11px; }

.zt-empty { color: var(--muted); font-size: 12.5px; padding: 10px 0; }
.zt-loading {
  grid-column: 1 / -1; text-align: center; padding: 34px 0;
  color: var(--muted); font-size: 14px;
}

/* ---------- tablas ---------- */
.zt-tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.zt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 640px; }
.zt-table-contacts { min-width: 480px; }
.zt-table thead th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0; background: var(--card);
}
.zt-table tbody td {
  padding: 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--fg);
}
.zt-table tbody tr:last-child td { border-bottom: none; }
.zt-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.zt-td-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.zt-td-num { text-align: center; font-weight: 600; }
.zt-td-origin { max-width: 190px; }
.zt-ref { color: var(--muted); font-size: 11px; }
.zt-mail { color: var(--accent); text-decoration: none; }
.zt-mail:hover { text-decoration: underline; }

.zt-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.zt-badge-mobile { background: color-mix(in srgb, #f97316 16%, transparent); color: #c2610c; }
.zt-badge-tablet { background: color-mix(in srgb, #a855f7 16%, transparent); color: #7d3bd1; }
.zt-badge-desktop { background: color-mix(in srgb, #0078c8 14%, transparent); color: #0078c8; }
html.dark .zt-badge-mobile { color: #fdba74; }
html.dark .zt-badge-tablet { color: #d8b4fe; }
html.dark .zt-badge-desktop { color: #4cb3e8; }

.zt-type {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.zt-type-new { background: color-mix(in srgb, #22c55e 15%, transparent); color: #15803d; }
.zt-type-ret { background: color-mix(in srgb, #00b4c8 15%, transparent); color: #0e7490; }
html.dark .zt-type-new { color: #4ade80; }
html.dark .zt-type-ret { color: #4cd4d4; }

.zt-td-journey { max-width: 420px; }
.zt-jstep {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  font-size: 11px; white-space: nowrap;
}
.zt-jsep { color: var(--muted); font-size: 10px; margin: 0 2px; }
.zt-jmore { color: var(--muted); font-size: 11px; font-weight: 600; }

/* ---------- pie ---------- */
.zt-dash-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
.zt-dash-foot-right { letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px; }
.zt-limited-note { display: block; width: 100%; font-size: 11px; opacity: 0.85; }
.zt-err { color: var(--destructive); font-weight: 600; }

/* ---------- tooltip ---------- */
.zt-tip {
  position: fixed; z-index: 999;
  background: var(--fg); color: var(--bg);
  padding: 6px 12px; border-radius: 8px;
  font: 600 11.5px/1.3 var(--font-sans, system-ui, sans-serif);
  box-shadow: 0 6px 20px -6px rgba(0,0,0,0.4);
  pointer-events: none; max-width: 300px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- accesibilidad / movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .zt-dash, .zt-dash.open { transition: none; opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  .zt-kpis { grid-template-columns: repeat(2, 1fr); }
  .zt-grid { grid-template-columns: 1fr; }
  .zt-hbar { grid-template-columns: minmax(70px, 105px) 1fr auto; }
  .zt-dash-toolbar { flex-direction: column; align-items: stretch; }
  .zt-dash-actions { justify-content: flex-end; }
}

/* ---------- IP · país en la tabla de sesiones ---------- */
.zt-td-ip { white-space: nowrap; }
.zt-td-ip .zt-ip {
  display: block;
  font-family: var(--zt-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 12px;
  color: var(--fg);
}
.zt-td-ip .zt-cc {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
