/* ============================================================================
 * CodeFinder — Estilos
 * Paleta: azul oscuro (#1a2a3a) + naranja (#f39c12). Mobile First.
 * ========================================================================== */

:root {
  --cf-navy: #1a2a3a;
  --cf-navy-dark: #111d29;
  --cf-navy-soft: #22344a;
  --cf-card: #1f3143;
  --cf-card-hover: #263a4f;
  --cf-orange: #f39c12;
  --cf-orange-dark: #d98a0b;
  --cf-text: #eaf0f6;
  --cf-muted: #9db0c2;
  --cf-border: rgba(255, 255, 255, 0.08);
  --cf-green: #2ecc71;
  --cf-red: #e74c3c;
  --cf-amber: #f1c40f;
  --cf-radius: 14px;
  --cf-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--cf-text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(243, 156, 18, 0.10), transparent 60%),
    linear-gradient(180deg, var(--cf-navy-dark) 0%, var(--cf-navy) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--cf-orange); text-decoration: none; }
a:hover { color: var(--cf-orange-dark); }

/* ── Header / Navbar ─────────────────────────────────────────────────────── */
.cf-header {
  background: linear-gradient(180deg, rgba(17, 29, 41, 0.97), rgba(26, 42, 58, 0.92));
  border-bottom: 1px solid var(--cf-border);
  padding: 0.8rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.cf-header .container,
.cf-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cf-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--cf-text);
  letter-spacing: -0.02em;
}
.cf-brand:hover { color: var(--cf-text); }
.cf-brand .brand-icon { font-size: 1.5rem; }
.cf-brand .brand-accent { color: var(--cf-orange); }

.cf-lang-select {
  background: var(--cf-navy-soft);
  color: var(--cf-text);
  border: 1px solid var(--cf-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.cf-lang-select:focus { outline: 2px solid var(--cf-orange); }

/* ── Hero / buscador ─────────────────────────────────────────────────────── */
.hero {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
}
.hero-title {
  font-size: clamp(1.7rem, 4.5vw, 2.9rem);
  font-weight: 800;
  margin: 0 0 0.6rem;
  line-height: 1.15;
}
.hero-title .accent { color: var(--cf-orange); }
.hero-subtitle {
  color: var(--cf-muted);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  max-width: 640px;
  margin: 0 auto 1.8rem;
}

.search-wrap { position: relative; max-width: 640px; margin: 0 auto; }
.search-box {
  display: flex;
  gap: 0.5rem;
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 0.45rem;
  box-shadow: var(--cf-shadow);
}
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cf-text);
  font-size: 1.15rem;
  padding: 0.65rem 0.75rem;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.search-input::placeholder {
  color: var(--cf-muted);
  text-transform: none;
  letter-spacing: normal;
}
.search-btn {
  background: var(--cf-orange);
  color: #1a1206;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
.search-btn:hover { background: var(--cf-orange-dark); color: #1a1206; }
.search-btn:active { transform: translateY(1px); }

/* ── Sugerencias (autocompletado) ────────────────────────────────────────── */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  box-shadow: var(--cf-shadow);
  max-height: 340px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  text-align: left;
}
.suggestions.open { display: block; }
.suggestions-title {
  padding: 0.6rem 0.9rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cf-muted);
  border-bottom: 1px solid var(--cf-border);
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--cf-border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover,
.suggestion-item.active { background: var(--cf-card-hover); }
.suggestion-code {
  font-weight: 800;
  color: var(--cf-orange);
  min-width: 5rem;
  letter-spacing: 0.02em;
}
.suggestion-desc {
  color: var(--cf-muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Chips de códigos populares ──────────────────────────────────────────── */
.popular {
  max-width: 640px;
  margin: 1.4rem auto 0;
  text-align: center;
}
.popular-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cf-muted);
  margin-bottom: 0.6rem;
}
.chip {
  display: inline-block;
  margin: 0.25rem;
  padding: 0.4rem 0.85rem;
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: 999px;
  color: var(--cf-text);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.chip:hover { background: var(--cf-orange); color: #1a1206; border-color: var(--cf-orange); }

/* ── Resultados ──────────────────────────────────────────────────────────── */
.results { margin: 1.6rem 0 2.5rem; }
.results-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cf-muted);
  margin: 0 0 0.8rem;
}
.result-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.7rem;
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.08s, border-color 0.15s;
}
.result-card:hover { background: var(--cf-card-hover); border-color: rgba(243, 156, 18, 0.4); transform: translateY(-2px); }
.result-code {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--cf-orange);
  min-width: 5.4rem;
}
.result-desc { color: var(--cf-text); font-size: 0.98rem; }
.result-arrow { margin-left: auto; color: var(--cf-muted); font-size: 1.3rem; }

/* ── Detalle ─────────────────────────────────────────────────────────────── */
.detail-hero {
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 1.5rem;
  margin: 1.8rem 0 1.2rem;
}
.detail-code {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  color: var(--cf-orange);
  line-height: 1;
  letter-spacing: 0.02em;
}
.detail-desc { font-size: 1.15rem; color: var(--cf-text); margin-top: 0.5rem; }

.badge-cat {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: var(--cf-navy-soft);
  border: 1px solid var(--cf-border);
  border-radius: 8px;
  color: var(--cf-muted);
  font-size: 0.85rem;
  margin-top: 0.9rem;
}

.severity-row { margin-top: 0.9rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.severity-label { color: var(--cf-muted); font-size: 0.9rem; }
.sev-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}
.sev-low { background: rgba(46, 204, 113, 0.18); color: var(--cf-green); }
.sev-medium { background: rgba(241, 196, 15, 0.18); color: var(--cf-amber); }
.sev-high { background: rgba(231, 76, 60, 0.2); color: var(--cf-red); }

.card-panel {
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 1.3rem;
  margin-bottom: 1.2rem;
}
.card-panel h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 0.8rem;
  color: var(--cf-text);
}
.cause-list { margin: 0; padding-left: 1.2rem; }
.cause-list li { margin-bottom: 0.45rem; color: var(--cf-text); }
.note { color: var(--cf-muted); font-size: 0.85rem; margin-top: 0.8rem; }

/* ── Video ───────────────────────────────────────────────────────────────── */
.video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.9rem; }
.video-thumb {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--cf-navy-soft);
  border: 1px solid var(--cf-border);
  border-radius: 10px;
  padding: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.video-thumb:hover { border-color: rgba(243, 156, 18, 0.5); }
.video-thumb img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.video-thumb .vt-title { font-size: 0.85rem; color: var(--cf-text); }
.video-thumb .vt-channel { font-size: 0.75rem; color: var(--cf-muted); }

/* ── Anuncios ────────────────────────────────────────────────────────────── */
.ad-slot {
  margin: 1.4rem auto;
  text-align: center;
}
.ad-slot ins.adsbygoogle { display: block; }
.ad-side { min-width: 300px; min-height: 250px; }

/* ── Pie ─────────────────────────────────────────────────────────────────── */
.cf-footer {
  margin-top: auto;
  border-top: 1px solid var(--cf-border);
  background: rgba(17, 29, 41, 0.6);
  padding: 1.4rem 0;
  text-align: center;
  color: var(--cf-muted);
  font-size: 0.85rem;
}
.cf-footer p { margin: 0.25rem 0; }
.cf-footer-nav { margin-bottom: 0.8rem; }
.cf-footer-nav a {
  color: var(--cf-muted);
  margin: 0 0.6rem;
  text-decoration: none;
  font-size: 0.9rem;
}
.cf-footer-nav a:hover { color: var(--cf-orange); }

/* ── Páginas de contenido (guías, legal) ───────────────────────────────── */
.content-page { max-width: 820px; margin: 2rem auto 3rem; }
.content-page h1 {
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  font-weight: 800;
  margin: 0 0 0.5rem;
}
.content-page .lead { color: var(--cf-muted); margin-bottom: 1.6rem; }
.content-page h2 { font-size: 1.25rem; font-weight: 800; margin: 1.8rem 0 0.6rem; color: var(--cf-text); }
.content-page h3 { font-size: 1.05rem; font-weight: 700; margin: 1.2rem 0 0.4rem; }
.content-page p { color: var(--cf-text); line-height: 1.65; margin-bottom: 0.9rem; }
.content-page ul, .content-page ol { color: var(--cf-text); line-height: 1.6; padding-left: 1.4rem; }
.content-page li { margin-bottom: 0.4rem; }
.toc {
  background: var(--cf-card);
  border: 1px solid var(--cf-border);
  border-radius: var(--cf-radius);
  padding: 1rem 1.3rem;
  margin-bottom: 1.6rem;
}
.toc a { display: block; padding: 0.25rem 0; color: var(--cf-orange); }
.toc a:hover { color: var(--cf-orange-dark); }
.guide { margin-bottom: 1.6rem; }
.guide-tag {
  display: inline-block;
  background: rgba(243, 156, 18, 0.15);
  color: var(--cf-orange);
  border-radius: 6px;
  padding: 0.15rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ── Utilidades / estados ────────────────────────────────────────────────── */
.loading {
  text-align: center;
  color: var(--cf-muted);
  padding: 2rem 0;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--cf-border);
  border-top-color: var(--cf-orange);
  border-radius: 50%;
  margin: 0 auto 0.8rem;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; color: var(--cf-muted); padding: 2rem 0; }
.empty-state .big { font-size: 3rem; margin-bottom: 0.6rem; }

.back-link { display: inline-block; margin: 1rem 0 0; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 992px) {
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.4rem;
    align-items: start;
  }
}

@media (max-width: 576px) {
  .search-btn { padding: 0.65rem 1rem; }
  .suggestion-desc { max-width: 60vw; }
  .detail-code { font-size: 2rem; }
  .video-thumb img { width: 80px; height: 45px; }
}
