@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --surface-2: #eef1f6;
  --border: #dde2ea;
  --text: #111111;
  --text-muted: #606060;
  --primary: #284473;
  --primary-hover: #1e3358;
  --primary-light: rgba(40, 68, 115, 0.08);
  --primary-light-2: rgba(40, 68, 115, 0.15);
  --secondary: #606060;
  --danger: #c0392b;
  --danger-light: rgba(192, 57, 43, 0.08);
  --success: #1a7f4b;
  --success-light: rgba(26, 127, 75, 0.08);
  --warning: #b45309;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --font-title: 'Orbitron', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

/* ─── Layout ─────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

/* ─── Navbar ─────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; gap: 24px;
  background: #fff;
  padding: 0 28px; height: 54px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.nav-brand { display: flex; align-items: center; }
.nav-brand a { display: flex; align-items: center; }
.nav-logo { height: 26px; width: auto; }
.nav-links { display: flex; gap: 24px; flex: 1; }
.nav-links a {
  color: var(--text-muted); font-size: 13px;
  font-weight: 500; position: relative;
  transition: color .15s;
}
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-muted); }
.btn-link { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; font-family: var(--font-body); }
.btn-link:hover { color: var(--primary); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 14px;
  font-weight: 500; font-family: var(--font-body);
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ─── Forms ───────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select, textarea {
  background: #fff; border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 8px 12px; font-size: 14px; width: 100%;
  font-family: var(--font-body);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
label {
  display: block; margin-bottom: 5px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.form-group { margin-bottom: 16px; }

/* ─── Login ───────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f4fb 0%, #e8edf5 100%);
}
.login-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 44px 40px;
  width: 100%; max-width: 390px;
  box-shadow: 0 8px 32px rgba(40,68,115,.12);
}
.login-logo { margin-bottom: 10px; text-align: center; }
.login-logo img { height: 38px; width: auto; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 30px; text-align: center; }
.login-card label { margin-top: 16px; }
.login-card .btn { width: 100%; margin-top: 22px; justify-content: center; padding: 10px; font-size: 15px; }

/* ─── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 11px 15px; border-radius: var(--radius);
  margin-bottom: 18px; font-size: 14px;
}
.alert-error {
  background: var(--danger-light);
  border: 1px solid rgba(192,57,43,.25);
  color: var(--danger);
}

/* ─── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.badge-new { background: var(--primary); color: #fff; }
.badge-ok { background: var(--success-light); color: var(--success); border: 1px solid rgba(26,127,75,.2); }
.badge-error { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(192,57,43,.2); }
.badge-iniciado { background: rgba(180,83,9,.08); color: var(--warning); border: 1px solid rgba(180,83,9,.2); }
.badge-off { background: var(--surface-2); color: var(--text-muted); }
.hidden { display: none; }

/* ─── Page headers ────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--primary-light);
}
.page-header h2 {
  font-size: 18px; color: var(--primary);
  letter-spacing: 0.05em; text-transform: uppercase;
}

/* ─── Search ──────────────────────────────────────────────── */
.search-page {}
.search-page h2 {
  font-size: 17px; color: var(--primary);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 20px;
}
.search-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 24px;
}
.search-main { display: flex; gap: 10px; margin-bottom: 0; }
.input-search {
  flex: 1; font-size: 15px; padding: 10px 14px;
  border: 1.5px solid var(--border);
}
.input-search:focus { border-color: var(--primary); }

.filtros {
  border: none; border-top: 1px solid var(--border);
  padding: 14px 0 0; margin-top: 14px;
}
.filtros summary {
  cursor: pointer; color: var(--primary);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.03em; list-style: none;
}
.filtros summary::-webkit-details-marker { display: none; }
.filtros summary::before { content: '▸ '; }
details[open] .filtros summary::before { content: '▾ '; }
.filtros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 12px; margin-top: 14px;
}
.filtro-group label { margin-bottom: 4px; }

.search-options {
  display: flex; gap: 20px; font-size: 13px;
  color: var(--text-muted); align-items: center;
  border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px;
}
.search-options select { width: auto; padding: 4px 8px; font-size: 13px; }

/* ─── Results ─────────────────────────────────────────────── */
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-size: 14px; color: var(--text-muted);
}
.result-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.result-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.result-meta {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 8px; flex-wrap: wrap;
}
.badge-tipo {
  background: var(--primary-light); color: var(--primary);
  padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.result-fecha { font-size: 12px; color: var(--text-muted); }
.result-provincia { font-size: 12px; color: var(--secondary); }
.result-conf { font-size: 12px; color: var(--success); font-weight: 500; }
.result-objeto { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.result-objeto a { color: var(--text); }
.result-objeto a:hover { color: var(--primary); text-decoration: none; }
.result-detail {
  display: flex; gap: 16px; font-size: 13px;
  color: var(--secondary); flex-wrap: wrap; margin-bottom: 8px;
}
.result-monto { color: var(--success); font-weight: 600; }
.link-original { font-size: 12px; color: var(--text-muted); }
.link-original:hover { color: var(--primary); }
.no-results { color: var(--text-muted); text-align: center; padding: 48px; font-size: 15px; }

/* ─── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 16px;
  justify-content: center; margin-top: 28px;
  font-size: 14px; color: var(--text-muted);
}

/* ─── Item detalle ────────────────────────────────────────── */
.item-detalle { max-width: 820px; }
.back-link { display: inline-block; margin-bottom: 20px; font-size: 14px; color: var(--text-muted); }
.back-link:hover { color: var(--primary); text-decoration: none; }
.item-header {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 20px; margin-bottom: 24px;
}
.item-header h1 { font-size: 18px; margin: 10px 0 8px; color: var(--text); }
.item-meta { display: flex; gap: 14px; font-size: 13px; color: var(--secondary); flex-wrap: wrap; }
.item-fields {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; margin-bottom: 24px;
}
@media (max-width: 600px) { .item-fields { grid-template-columns: 1fr; } }
.field {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.field label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px;
}
.field span { font-size: 14px; font-weight: 500; }
.entidades { margin-bottom: 24px; }
.entidades h3, .item-contenido h3 {
  font-size: 12px; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 10px; font-family: var(--font-title);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px 12px;
  font-size: 12px; display: flex; gap: 6px; align-items: center;
}
.chip-tipo {
  font-size: 10px; color: var(--primary); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.contenido-texto {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  font-size: 13px; font-family: 'Courier New', monospace;
  white-space: pre-wrap; overflow-x: auto;
  max-height: 420px; overflow-y: auto; line-height: 1.7;
  color: var(--text);
}
.item-original { margin-top: 24px; }

/* ─── Alertas ─────────────────────────────────────────────── */
.alertas-page h2 {
  font-size: 17px; color: var(--primary);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px;
}
.plan-info { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.nueva-alerta {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 28px;
}
.nueva-alerta > summary {
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--primary);
  list-style: none;
}
.nueva-alerta > summary::-webkit-details-marker { display: none; }
.nueva-alerta > summary::before { content: '+ '; }
.alerta-form { margin-top: 16px; max-width: 520px; }
.alertas-list { display: flex; flex-direction: column; gap: 12px; }
.alerta-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm);
}
.alerta-card.inactiva { opacity: .55; }
.alerta-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.alerta-header strong { font-size: 14px; font-weight: 600; }
.alerta-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.alerta-prov { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.empty-state { color: var(--text-muted); text-align: center; padding: 48px; }

/* ─── Admin ───────────────────────────────────────────────── */
.admin-page h2 {
  font-size: 17px; color: var(--primary);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 28px;
}
.admin-section { margin-bottom: 44px; }
.admin-section h3 {
  font-size: 13px; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}
.table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: #fff; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.table th {
  text-align: left; padding: 10px 14px;
  background: var(--surface); color: var(--text-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; border-bottom: 1px solid var(--border);
}
.table td {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface); }
.inline-form {
  display: flex; gap: 8px; align-items: center; padding: 14px 0; flex-wrap: wrap;
}
.inline-form input, .inline-form select { width: auto; }

/* ─── Errors ──────────────────────────────────────────────── */
.error-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--surface);
}
.error-card { text-align: center; }
.error-card h1 {
  font-size: 90px; color: var(--primary);
  font-family: var(--font-title); letter-spacing: 0.1em;
}
.error-card p { color: var(--text-muted); margin: 14px 0 28px; font-size: 16px; }

/* ─── Theme toggle button ─────────────────────────────────── */
.btn-theme {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 5px;
  border-radius: var(--radius-sm); display: flex; align-items: center;
  transition: color .15s, background .15s;
}
.btn-theme:hover { color: var(--primary); background: var(--primary-light); }
.btn-theme svg, .btn-theme-login svg { width: 16px; height: 16px; }

.btn-theme-login {
  position: fixed; top: 16px; right: 16px;
  background: #fff; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 8px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); display: flex; align-items: center;
  transition: box-shadow .15s, background .15s;
}
.btn-theme-login:hover { box-shadow: var(--shadow); }

/* en modo claro: luna visible, sol oculto */
.icon-sun { display: none; }
.icon-moon { display: block; }

/* ─── Dark mode ───────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #060c1a;
  --surface: #0d1628;
  --surface-2: #152035;
  --border: #1e2d47;
  --text: #e4e8f0;
  --text-muted: #7b8399;
  --primary: #5b8fd4;
  --primary-hover: #7aaee0;
  --primary-light: rgba(40,68,115,.25);
  --primary-light-2: rgba(40,68,115,.4);
  --secondary: #8b8fa8;
  --danger: #e05c4b;
  --danger-light: rgba(224,92,75,.12);
  --success: #2ea867;
  --success-light: rgba(46,168,103,.12);
  --warning: #d97706;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow: 0 2px 8px rgba(0,0,0,.5);
}

/* en modo oscuro: sol visible, luna oculta */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

[data-theme="dark"] .login-logo img { filter: brightness(0) invert(1); }

[data-theme="dark"] .login-body {
  background: linear-gradient(135deg, #040913 0%, #080f1e 100%);
}
[data-theme="dark"] .login-card { background: var(--surface); }
[data-theme="dark"] .btn-theme-login { background: var(--surface); color: var(--text-muted); }

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}

[data-theme="dark"] .navbar {
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}
[data-theme="dark"] .nav-links a { color: var(--text-muted); }
[data-theme="dark"] .nav-links a:hover { color: var(--primary); }
[data-theme="dark"] .nav-user { color: var(--text-muted); }
[data-theme="dark"] .btn-link { color: var(--text-muted); }
[data-theme="dark"] .btn-link:hover { color: var(--primary); }
[data-theme="dark"] .btn-theme { color: var(--text-muted); }
[data-theme="dark"] .btn-theme:hover { color: var(--primary); background: rgba(91,143,212,.1); }

[data-theme="dark"] .result-card { background: var(--surface); }
[data-theme="dark"] .alerta-card { background: var(--surface); }
[data-theme="dark"] .table { background: var(--surface); }
[data-theme="dark"] .table th { background: var(--surface-2); }
[data-theme="dark"] .search-form { background: var(--surface); }
[data-theme="dark"] .item-header { background: var(--surface); }
[data-theme="dark"] .field { background: var(--surface); }
[data-theme="dark"] .nueva-alerta { background: var(--surface); }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .navbar { padding: 0 16px; }
  .container { padding: 18px 14px; }
  .search-main { flex-direction: column; }
  .filtros-grid { grid-template-columns: 1fr; }
  .item-fields { grid-template-columns: 1fr; }
}
