/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== VARIABLES ===== */
:root {
  --primary:       #0B3861;
  --primary-light: #1565a0;
  --primary-dark:  #072a47;
  --accent:        #1976D2;
  --bg:            #f0f4f8;
  --card:          #ffffff;
  --border:        #dde3ea;
  --text:          #1a2533;
  --muted:         #7a8999;
  --row-alt:       #f7f9fc;
  --row-hover:     #e8f0fe;
  --shadow:        0 2px 8px rgba(0,0,0,0.10);
  --radius:        8px;
  /* Color de títulos sobre --card. En claro es --primary (buen contraste
     sobre blanco); en oscuro theme.css lo redefine a --accent, porque
     --primary (azul oscuro) se pierde sobre --card oscuro. */
  --heading:       var(--primary);
}

/* ===== BASE ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--primary);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.navbar-brand img { height: 30px; }
.navbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  transition: background .2s, border-color .2s;
}
.navbar-logout:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.6);
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1500px;
  margin: 24px auto;
  padding: 0 20px;
}

/* ===== LOGIN ===== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.13);
  padding: 44px 40px 36px;
  width: 360px;
  max-width: 100%;
  text-align: center;
}
.login-card img.qr { max-width: 100%; height: auto; }
.login-card img { height: 50px; margin-bottom: 14px; }
.login-card h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 28px;
}
.login-card .field {
  margin-bottom: 16px;
}

/* ===== ALERTS ===== */
.alert {
  border-radius: 6px;
  padding: 11px 16px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}
.alert-error   { background: #ffebee; color: #b71c1c; border: 1px solid #ffcdd2; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }

/* ===== FORM CONTROLS ===== */
input[type="text"],
input[type="password"],
select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25,118,210,0.12);
}
input[type="checkbox"] { cursor: pointer; }
input:disabled, select:disabled {
  background: var(--row-alt);
  color: var(--muted);
  cursor: not-allowed;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.btn-danger    { background: #c62828; color: #fff; }
.btn-danger:hover  { background: #b71c1c; box-shadow: 0 2px 8px rgba(198,40,40,.3); }
.btn-success   { background: #2e7d32; color: #fff; }
.btn-success:hover { background: #1b5e20; box-shadow: 0 2px 8px rgba(46,125,50,.3); }
.btn-secondary { background: var(--row-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--row-hover); }
.btn-full { width: 100%; }

/* ===== SEARCH BAR ===== */
.search-bar {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.search-bar label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.search-bar .search-input { width: 220px; max-width: 100%; }

/* ===== RESULTS INFO ===== */
.results-info {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  padding: 0 4px;
}
.results-info strong { color: var(--text); }

/* ===== TABLE ===== */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-color: var(--border) var(--card);
}
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: var(--card); }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }
table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
table.results thead th {
  background: var(--primary);
  color: #fff;
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  border-right: 1px solid var(--primary-light);
}
table.results thead th:last-child { border-right: none; }
table.results thead th:hover { background: var(--primary-light); }
table.results thead th a {
  display: block;
  margin: -10px -10px;
  padding: 10px 10px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.results tbody tr { border-bottom: 1px solid var(--border); }
table.results tbody tr:nth-child(even) { background: var(--row-alt); }
table.results tbody tr:hover { background: var(--row-hover); }
table.results tbody td { padding: 7px 10px; vertical-align: middle; }
table.results tbody tr.secondary td { color: var(--muted); }
table.results .edit-cell { text-align: center; width: 40px; }
table.results .edit-cell form { margin: 0; }
table.results .edit-cell input[type="image"] {
  width: 20px; height: 20px; opacity: 0.6; cursor: pointer;
  transition: opacity .2s;
}
table.results .edit-cell input[type="image"]:hover { opacity: 1; }

/* ===== SUMMARY ===== */
.results-summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--muted);
  display: inline-block;
}
.results-summary strong { color: var(--text); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}
.pagination-info { font-size: 13px; color: var(--muted); }
.pagination .is-disabled { opacity: .4; cursor: default; pointer-events: none; }

/* ===== EDIT PAGE ===== */
.edit-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 16px;
  background: var(--bg);
  min-height: 100vh;
}
.edit-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 32px;
  width: 560px;
  max-width: 100%;
}
.edit-card h2 {
  color: var(--heading);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}
.edit-meta {
  background: var(--row-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.edit-meta span strong { color: var(--text); }
.edit-meta .key-value {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text);
  word-break: break-all;
  white-space: normal;
  margin-top: 6px;
  width: 100%;
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.form-row label {
  width: 110px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}
.form-row input[type="text"] { flex: 1; }
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}
.radio-section {
  background: var(--row-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}
.inline-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.inline-inputs input[type="text"] { width: 50px; text-align: center; padding: 5px 6px; }
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== RESPONSIVE (smartphones) ===== */
@media (max-width: 720px) {
  .navbar {
    height: auto;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .navbar-brand { flex: 1 1 100%; font-size: 14px; }
  .theme-lang-switch { flex: 1 1 100%; justify-content: flex-start; }

  .container { padding: 0 12px; margin: 16px auto; }
  .search-bar { padding: 12px 14px; }
  .search-bar .search-input { flex: 1 1 100%; }
  .search-bar select { flex: 1 1 auto; }

  .pagination { flex-wrap: wrap; justify-content: center; text-align: center; }

  table.results { font-size: 11px; }
}

@media (max-width: 480px) {
  .login-card, .edit-card { padding: 28px 20px 24px; }
  .edit-wrap { padding: 24px 12px; }

  .form-row { flex-wrap: wrap; }
  .form-row label { width: 100%; text-align: left; margin-bottom: 4px; }

  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions > div { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  .edit-meta { font-size: 11px; gap: 8px 14px; }
}
