/* ============================================================
   LINKC — Administrador de Campañas
   Sistema de diseño JZDS: tema claro, accent teal, un solo
   radio de esquina, sin sombras difusas, sin gradientes lila.
   ============================================================ */

/* --------- Tokens --------- */
:root {
    --bg:          #f2f4f7;
    --surface:     #ffffff;
    --surface-2:   #fafbfc;
    --border:      #e4e8ee;
    --border-strong:#cbd2da;

    --text:        #101828;
    --text-2:      #5b6472;
    --text-3:      #8a94a3;

    --accent:      #0b7a75;
    --accent-strong:#075f5b;
    --accent-soft: #e3f2f1;
    --accent-ink:  #08514d;

    --danger:      #dc2626;
    --danger-soft: #fdebeb;

    --success:     #16803c;
    --success-soft:#e5f5eb;

    --radius:      12px;
    --radius-sm:   8px;

    --shadow-sm:   0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md:   0 1px 3px rgba(16, 24, 40, 0.08),
                   0 4px 12px rgba(16, 24, 40, 0.04);
    --shadow-lg:   0 12px 32px rgba(16, 24, 40, 0.12);

    --font-display: "Sora", "Inter", system-ui, sans-serif;
    --font-body:    "Inter", system-ui, -apple-system, sans-serif;
    --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

/* --------- Base ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(11, 122, 117, 0.06), transparent 60%),
    linear-gradient(180deg, #f8fafb 0%, var(--bg) 260px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
}

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

/* ---------- Layout ---------- */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

/* Barra superior */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand-mark svg { display: block; }

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-title span {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0;
}

.topbar h1 { font-size: 15px; font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Franja de KPIs */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-value.accent { color: var(--accent); }

.stat-note { font-size: 12px; color: var(--text-3); }

/* ---------- Formularios ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  align-items: end;
}

.form-grid .field { display: flex; flex-direction: column; gap: 6px; }

.form-grid label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(11, 122, 117, 0.14);
}

input[type="text"]::placeholder,
input[type="url"]::placeholder,
input[type="password"]::placeholder { color: var(--text-3); }

/* ---------- Botones ---------- */
button,
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 160ms ease-out, background 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

button:active,
.btn:active { transform: scale(0.97); }

button,
.btn-primary {
  background: var(--accent);
  color: #fff;
}

button:hover,
.btn-primary:hover {
  background: var(--accent-strong);
  color: #fff;
}

/* Botones de fila en acciones */
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  font-size: 13px;
}

.btn-secondary:hover {
  background: #fff;
  color: var(--text);
  border-color: var(--accent);
}

.btn-back {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  margin-right: 8px;
  margin-bottom: 20px;
  padding: 8px 14px;
}

.btn-back:hover { background: #fff; color: var(--text); border-color: var(--accent); }

.btn-export {
  background: var(--surface-2);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  padding: 8px 14px;
  margin-bottom: 20px;
}

.btn-export:hover { background: var(--accent-soft); color: var(--accent-strong); }

.btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 13px;
}

.btn-delete:hover {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-logout {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  font-size: 13px;
}

.btn-logout:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.btn-copy {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid transparent;
  padding: 5px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.btn-copy:hover { background: var(--accent-soft); }

/* ---------- Tabla ---------- */
.table-wrap {
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

thead th a { color: var(--text-2); }
thead th a:hover { color: var(--accent); }

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--surface-2); }

/* Tipografía de datos */
.td-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Trunca el contenido largo con elipsis; el texto completo va en title */
.td-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-ellipsis a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-ua {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-2);
}

.tracking-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tracking-cell input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 10px;
}

/* Badge de clicks */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--success-soft);
  color: var(--success);
}

td .btn { margin-right: 4px; }

/* ---------- Paginación ---------- */
.pagination {
  margin-top: 18px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.pagination a {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all 140ms ease;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }

.pagination a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Gráficos ---------- */
.chart-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.chart {
  position: relative;
  height: 280px;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.chart canvas { max-width: 100%; }

.chart-title {
  position: absolute;
  top: 12px;
  left: 18px;
  z-index: 2;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(700px 380px at 50% -10%, rgba(11, 122, 117, 0.1), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 34px 32px 30px;
}

.login-head {
  text-align: center;
  margin-bottom: 26px;
}

.login-head .brand-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
}

.login-head h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card button {
  width: 100%;
  margin-top: 4px;
  justify-content: center;
  padding: 12px 16px;
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: -6px 0 14px;
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; align-items: stretch; }
  .chart-container { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .container { padding: 16px 14px 48px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .btn-logout { align-self: stretch; justify-content: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Motion (prefers-reduced-motion) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
/* ---------- Modal QR ---------- */
.qr-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.qr-modal[hidden] { display: none; }
.qr-modal-backdrop { position: absolute; inset: 0; background: rgba(6, 12, 12, 0.6); backdrop-filter: blur(2px); }
.qr-modal-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 420px; text-align: center; box-shadow: var(--shadow-lg); }
.qr-modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--text-2); font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.qr-modal-close:hover { color: var(--text); background: var(--surface-2); }
.qr-modal-title { margin: 0 0 4px; font-family: var(--font-display); font-size: 18px; }
.qr-modal-name { margin: 0 0 16px; color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.qr-box { background: #fff; border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; }
.qr-box svg { display: block; width: 100%; height: auto; max-width: 260px; margin: 0 auto; }
.qr-modal-url { margin: 0 0 16px; font-family: var(--font-mono); font-size: 11px; color: var(--text-2); overflow-wrap: anywhere; }
.qr-modal-actions { display: flex; gap: 10px; justify-content: center; }
.qr-modal-actions .btn-primary, .qr-modal-actions .btn-secondary { flex: 1; justify-content: center; }
