/* ============================================================
   ESTILOS PANTALLA CATEGORÍAS — MODO CLARO
   ============================================================ */

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

:root {
  --bg: #f8f7f4;
  --card: #ffffff;
  --card-2: #eeefe8;
  --accent: #53604D;
  --accent-2: #7d8f73;
  --text: #3D3E3C;
  --muted: #545650;
  --border: #e6e5df;
}

html, body { width: 100%; overflow-x: hidden; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.5s ease, color 0.5s ease;
}

.pantalla-categorias {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================================================
   CABECERA (3 columnas)
   ============================================================ */
.cat-header { padding: 20px 0 10px; }

.cat-header-grid {
  display: grid;
  /* La columna central ahora puede crecer (minmax) */
  grid-template-columns: 1fr minmax(auto, 2fr) 1fr; 
  align-items: center;
  width: 100%;
  gap: 10px; /* Un poco de aire entre el botón, el logo y el título */
}

.cat-header-left { justify-self: start; }

.btn-volver {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s;
}

.btn-volver:hover { opacity: 0.7; }

.cat-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center; /* Para que si baja de línea quede bonito */
}

.cat-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.cat-header h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ============================================================
   LISTA DE CATEGORÍAS
   ============================================================ */
.cat-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-bloque {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(52, 56, 50, 0.04);
  position: relative;
  overflow: hidden;
}

.cat-bloque:hover {
  background: var(--card-2);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(102, 119, 96, 0.15);
}

.cat-bloque h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  line-height: 1.3;
}

.cat-bloque p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ============================================================
   COLORES POR CATEGORÍA
   ============================================================ */
.cat-bloque:nth-of-type(1)  { --cat-color: #6c8cff; }
.cat-bloque:nth-of-type(2)  { --cat-color: #328E51; }
.cat-bloque:nth-of-type(3)  { --cat-color: #CF953D; }
.cat-bloque:nth-of-type(4)  { --cat-color: #BC84A2; }
.cat-bloque:nth-of-type(5)  { --cat-color: #9371CF; }
.cat-bloque:nth-of-type(6)  { --cat-color: #b8843f; }
.cat-bloque:nth-of-type(7)  { --cat-color: #CF7E3D; }
.cat-bloque:nth-of-type(8)  { --cat-color: #00999A; }
.cat-bloque:nth-of-type(9)  { --cat-color: #BA4D4D; }
.cat-bloque:nth-of-type(10) { --cat-color: #1D1F7D; }
.cat-bloque:nth-of-type(11) { --cat-color: #8395a7; }
.cat-bloque:nth-of-type(12) { --cat-color: #43665C; }
.cat-bloque:nth-of-type(13) { --cat-color: #4482CF; }
.cat-bloque:nth-of-type(14) { --cat-color: #17A982; }
.cat-bloque:nth-of-type(15) { --cat-color: #CEA446; }
.cat-bloque:nth-of-type(16) { --cat-color: #BA74B1; }
.cat-bloque:nth-of-type(17) { --cat-color: #BA9E2B; }
.cat-bloque:nth-of-type(18) { --cat-color: #5b4fd6; }

.cat-bloque::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--cat-color, var(--accent));
  opacity: 0.5;
  transition: opacity 0.2s;
}

.cat-bloque:hover {
  border-color: var(--cat-color, var(--accent));
  box-shadow: 0 4px 14px rgba(52, 56, 50, 0.1), 0 0 8px var(--cat-color, var(--accent));
}

.cat-bloque:hover::before { opacity: 1; }
.cat-bloque:hover h2 { color: var(--cat-color, var(--accent)); }

/* ============================================================
   TARJETAS DE TEST
   ============================================================ */
.test-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(52, 56, 50, 0.04);
}

.test-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--cat-color, var(--accent));
  opacity: 0.8;
  transition: opacity 0.2s;
}

.test-card:hover {
  transform: translateY(-3px);
  border-color: var(--cat-color, var(--accent));
  box-shadow: 0 6px 20px rgba(52, 56, 50, 0.12), 0 0 10px var(--cat-color, var(--accent));
}

.test-card:hover::before { opacity: 1; }

.test-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}

.test-card-desc {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
  flex-grow: 1;
}

.test-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.test-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.test-card-meta .meta-symbol {
  color: var(--cat-color, var(--accent));
  font-size: 1rem;
  font-weight: 800;
}

/* ============================================================
   ÚLTIMOS TESTS
   ============================================================ */
.ultimos-tests-lista {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: stretch;
}

.ultimos-tests-lista .test-card {
  margin-bottom: 0;
  height: 100%;
}

@media (max-width: 1100px) {
  .ultimos-tests-lista { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .ultimos-tests-lista { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .ultimos-tests-lista { grid-template-columns: 1fr; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.inicio-footer {
  margin-top: 40px;
  padding: 22px 16px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  width: 100%;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-bottom: 10px;
}

.footer-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dotted transparent;
  transition: border-color 0.15s;
}

.footer-links a:hover { border-bottom-color: var(--accent); }

.footer-disclaimer {
  max-width: 640px;
  margin: 8px auto 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.footer-copy {
  margin-top: 10px;
  font-size: 0.72rem;
  color: #9a9d95;
}

.footer-copy a { color: var(--accent); text-decoration: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  body { padding: 12px; }

  .cat-header-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .cat-header-left { justify-self: center; }

  .cat-header-center {
    flex-direction: column;
    gap: 10px;
  }

  .cat-logo { height: 50px; }

  .cat-header h1 {
    font-size: 1.8rem;
    text-align: center;
  }

  .cat-bloque { padding: 14px 16px; }
  .cat-bloque h2 { font-size: 1rem; }
  .cat-bloque p { font-size: 0.85rem; }
}

/* ============================================================
   LOGO MODO CLARO
   ============================================================ */
.cat-logo[data-logo-claro] {
  content: url("../images/GETUP.png");
}

/* ============================================================
   BUSCADOR DINÁMICO (MODO CLARO)
   ============================================================ */
.buscador-tests {
  position: relative;
  margin-bottom: 24px;
}

.buscador-tests::before {
  content: "🔍";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--accent);
  pointer-events: none;
  z-index: 2;
}

#buscador-tests {
  width: 100%;
  padding: 14px 20px 14px 48px;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#buscador-tests:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(83, 96, 77, 0.2);
}

#buscador-tests::placeholder { color: var(--muted); }

.resultados-buscador {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 2px solid var(--accent);
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -2px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 15px 40px rgba(52, 56, 50, 0.2);
}

.resultados-buscador.hidden { display: none; }

.resultado-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease, padding-left 0.15s ease;
}

.resultado-item:last-child { border-bottom: none; }

.resultado-item:hover {
  background: rgba(83, 96, 77, 0.08);
  padding-left: 24px;
}

.resultado-nombre {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
  line-height: 1.3;
}

.resultado-item:hover .resultado-nombre { color: var(--accent); }

.resultado-cat {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0.8;
}

.resultado-vacio {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ============================================================
   INTERRUPTOR DE TEMA (SWITCH)
   ============================================================ */
.btn-tema-switch {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 54px;
  height: 30px;
  background-color: #f0f0f0;
  border-radius: 30px;
  border: 1px solid #dcdcdc;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 2;
}

.switch-icon-sun,
.switch-icon-moon {
  position: absolute;
  font-size: 14px;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.switch-icon-sun { left: 8px; color: #a0a0a0; }
.switch-icon-moon { right: 8px; color: #a0a0a0; }

[data-tema="oscuro"] .switch-track {
  background-color: #1a1a1a;
  border-color: #333;
}

[data-tema="oscuro"] .switch-thumb {
  transform: translateX(24px);
  background-color: #2c2c2c;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

[data-tema="oscuro"] .switch-icon-moon { color: #ffffff; }
[data-tema="oscuro"] .switch-icon-sun { color: #555; }

@media (max-width: 720px) {
  .btn-tema-switch {
    top: 15px;
    right: 15px;
    transform: scale(0.9);
  }
}

/* ============================================================
   TRANSICIONES SUAVES
   ============================================================ */
.cat-bloque,
.test-card,
.pantalla-categorias {
  transition: background-color 0.5s ease, border-color 0.5s ease, color 0.5s ease, box-shadow 0.5s ease;
}
/* ============================================================
   MODALES LEGALES (para páginas que no cargan styles.css)
   ============================================================ */
.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}

.legal-modal.open { display: flex; }

.legal-modal .legal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 780px;
  width: 100%;
  padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  color: var(--text);
  line-height: 1.65;
  font-size: 0.9rem;
  position: relative;
}

.legal-modal .legal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.legal-modal .legal-close:hover { background: var(--border); }

.legal-modal h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
  color: var(--accent);
  padding-right: 40px;
}

.legal-modal h3 {
  font-size: 0.98rem;
  margin: 18px 0 8px;
  color: var(--accent);
}

.legal-modal p { margin-bottom: 10px; }
.legal-modal ul { margin: 8px 0 12px 22px; }
.legal-modal ul li { margin-bottom: 5px; }

.legal-modal .legal-meta {
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.legal-modal .legal-highlight {
  background: rgba(76, 217, 123, 0.10);
  border-left: 3px solid #4cd97b;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.86rem;
  color: var(--text);
}

.legal-modal .legal-warn {
  background: rgba(255, 184, 76, 0.12);
  border-left: 3px solid #ffb84c;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.86rem;
  color: var(--text);
}

.legal-modal code {
  background: var(--card-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
  border: 1px solid var(--border);
}

@media (max-width: 600px) {
  .legal-modal { padding: 14px 10px; }
  .legal-modal .legal-box { padding: 20px 16px; border-radius: 12px; }
  .legal-modal h2 { font-size: 1.08rem; }
}
/* ============================================================
   BOTÓN PULSADOR DE TEMA (☀ / ☾)
   ============================================================ */
.btn-tema-switch {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e6e5df);
  color: var(--text, #343832);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-tema-switch:hover {
  transform: translateY(-1px) scale(1.05);
  border-color: var(--accent, #667760);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.btn-tema-switch:active {
  transform: scale(0.95);
}

.btn-tema-switch:focus-visible {
  outline: 2px solid var(--accent, #667760);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .btn-tema-switch {
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
}
/* FIX PARA EL BOTÓN DE TEMA EN LA NUEVA BARRA SUPERIOR */
.top-nav .btn-tema-switch {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  margin: 0;
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
}

/* Asegurarnos de que el switch interior también se vea bien en modo oscuro */
[data-tema="oscuro"] .top-nav .switch-track {
  background-color: #1a1a1a;
  border-color: #333;
}

[data-tema="oscuro"] .top-nav .switch-thumb {
  background-color: #2c2c2c;
}