/* ===== DPIA · Diseño moderno de tarjetas =====
   Guardar en: static/dpia-cards.css
   ============================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --success: #059669;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, .08), 0 14px 32px rgba(15, 23, 42, .12);
  --nav-bg: rgba(15, 23, 42, .92);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #19223a;
    --text: #e8ecf8;
    --muted: #94a3b8;
    --border: #243049;
    --primary: #818cf8;
    --primary-600: #6366f1;
    --primary-soft: #1e2547;
    --danger: #fb7185;
    --danger-soft: #3a1620;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .5), 0 14px 32px rgba(0, 0, 0, .5);
    --nav-bg: rgba(8, 12, 26, .92);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, video { max-width: 100%; height: auto; }

/* ---------- Navegación ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

nav .dpia-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  text-decoration: none;
  font-size: .9rem;
  transition: transform .15s ease, background .15s ease;
}
nav .dpia-home:hover { background: #e0e7ff; transform: translateY(-1px); }
nav .dpia-home:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

nav .publicidades-link {
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-size: .9rem;
  background: rgba(255, 255, 255, .1);
  transition: background .15s ease;
}
nav .publicidades-link:hover { background: rgba(255, 255, 255, .2); }

nav button {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  margin: 0;
  cursor: pointer;
  border-radius: 999px;
  font-size: .9rem;
  box-shadow: none;
  width: auto;
}
nav button:hover { background: rgba(255, 255, 255, .2); transform: none; box-shadow: none; }
nav button.active { background: var(--primary); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 32px);
  flex: 1;
}

section.tab { display: none; padding: clamp(14px, 3vw, 32px); width: 100%; max-width: 1200px; margin: 0 auto; }
section.tab.active { display: block; }

h1 { margin: 0 0 4px; font-size: clamp(1.3rem, 3.5vw, 1.9rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.05rem, 2.5vw, 1.3rem); margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.page-sub { margin: 0 0 20px; color: var(--muted); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(14px, 2.5vw, 24px);
  margin-bottom: 20px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 650;
}
.card-title .ico {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary-soft);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-actions { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ---------- Formularios ---------- */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="email"], input[type="url"], input[type="number"],
input[type="date"], input[type="time"], input[type="password"], input[type="search"],
input[type="tel"], select, textarea {
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 38px; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; }
input[type="file"] { width: 100%; font: inherit; color: var(--muted); }

/* ---------- Botones ---------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
}
button:hover, .btn:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent); }
button:active, .btn:active { transform: translateY(0); }
button:focus-visible, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #be123c; box-shadow: 0 6px 16px color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-ghost { background: var(--primary-soft); color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); box-shadow: none; filter: brightness(.97); }

/* Botones de acción grandes (tipo tile) */
.action-tile {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  width: 100%;
  min-height: 92px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.action-tile:hover { background: var(--surface); border-color: var(--primary); box-shadow: var(--shadow-hover); }
.action-tile .tile-ico { font-size: 1.6rem; line-height: 1; }
.action-tile .tile-title { font-size: 1rem; font-weight: 650; }
.action-tile .tile-desc { font-size: .82rem; font-weight: 400; color: var(--muted); }

/* ---------- Tablas → listado de tarjetas (siempre, en todo ancho) ---------- */
table:not(.keep-table) { display: block; width: 100%; border: 0; border-collapse: separate; background: transparent; }
table:not(.keep-table) thead,
table:not(.keep-table) tr.dpia-head-row { display: none; }

table:not(.keep-table) tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 16px;
}
table:not(.keep-table) tfoot { display: block; margin-top: 16px; }

table:not(.keep-table) tr {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
table:not(.keep-table) tbody tr:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

table:not(.keep-table) td,
table:not(.keep-table) th {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px dashed var(--border);
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
table:not(.keep-table) td:last-child,
table:not(.keep-table) th:last-child { border-bottom: 0; }

table:not(.keep-table) td::before {
  content: attr(data-label);
  flex: 0 0 38%;
  max-width: 45%;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
table:not(.keep-table) td[data-label=""]::before,
table:not(.keep-table) td:not([data-label])::before { display: none; }
table:not(.keep-table) td[data-label=""],
table:not(.keep-table) td:not([data-label]) { justify-content: flex-start; text-align: left; }

/* Mensajes tipo "sin datos" (colspan) ocupan todo el ancho */
table:not(.keep-table) tr:has(> td[colspan]) { grid-column: 1 / -1; align-items: center; text-align: center; color: var(--muted); }
table:not(.keep-table) td[colspan] { justify-content: center; text-align: center; border: 0; }
table:not(.keep-table) td[colspan]::before { display: none; }

/* Imágenes y acciones dentro de las tarjetas */
table:not(.keep-table) td img { max-width: 100%; max-height: 160px; object-fit: cover; border-radius: var(--radius-sm); margin-left: auto; }
table:not(.keep-table) td button, table:not(.keep-table) td .btn, table:not(.keep-table) td a.btn { padding: 8px 12px; font-size: .85rem; }
table:not(.keep-table) td a { color: var(--primary); }

/* Tarjetas con muchas acciones: botones en fila y a ancho completo */
table:not(.keep-table) td:has(> button:only-child),
table:not(.keep-table) td:has(> button + button) { flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Resultado ---------- */
#resultado:empty { display: none; }
#resultado { margin-top: 20px; overflow-wrap: anywhere; }
#resultado .alert, #resultado .success, #resultado .error {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ---------- Footer ---------- */
.admin-footer { padding: 24px; text-align: center; }
.admin-footer .scrapeador-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  text-decoration: none;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.admin-footer .scrapeador-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  nav { padding: 8px 12px; }
  nav .dpia-home { width: 100%; margin-right: 0; justify-content: center; }
  nav button, nav .publicidades-link { flex: 1 1 auto; text-align: center; justify-content: center; }
  table:not(.keep-table) tbody { grid-template-columns: 1fr; gap: 12px; }
  .grid-2, .grid-actions { grid-template-columns: 1fr; }
  .card { border-radius: 14px; }
  .btn-block-sm { width: 100%; }
}

@media (min-width: 1500px) {
  .container, section.tab { max-width: 1400px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* SweetAlert acorde al diseño */
.swal2-popup { border-radius: var(--radius) !important; font-family: inherit !important; }
.swal2-styled.swal2-confirm { background: var(--primary) !important; border-radius: var(--radius-sm) !important; }