/* =====================================================
   PROGRAMADOR WEB JUNIOR — Estilos principales
   Editorial Ciberecus MX | José Luis Pérez Resendiz
   Diseño ligero, imprimible en B/N, alto contraste
   ===================================================== */

:root {
  --color-primary: #0f3460;
  --color-primary-dark: #0a2547;
  --color-secondary: #16a085;
  --color-accent: #e94560;
  --color-warning: #f39c12;
  --color-success: #27ae60;
  --color-danger: #c0392b;
  --color-bg: #f7f8fb;
  --color-bg-alt: #eef1f6;
  --color-card: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #5b6473;
  --color-border: #e2e6ee;
  --shadow-sm: 0 1px 2px rgba(15,52,96,.06);
  --shadow:    0 4px 12px rgba(15,52,96,.08);
  --shadow-lg: 0 12px 32px rgba(15,52,96,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --max-width: 1200px;
  --transition: all .2s ease;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; height: auto; display: block; }

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--color-text-muted); }
.small { font-size: .875rem; }

/* =====================================================
   HEADER / NAV
   ===================================================== */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(15,52,96,.08);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 76px;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--color-primary);
  text-decoration: none;
}
.brand:hover { color: var(--color-primary-dark); }
.brand-mark { font-size: 2rem; }
.brand-text strong { display: block; font-size: 1.05rem; color: var(--color-primary-dark); }
.brand-text small  { display: block; font-size: .78rem; color: #4a5568; font-weight: 500; }

.main-nav {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.main-nav a {
  font-size: .95rem;
  font-weight: 600;
  color: #1a202c;            /* Contraste WCAG AAA sobre blanco */
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  text-decoration: none;
  transition: all .15s ease;
}
.main-nav a:hover {
  color: var(--color-primary);
  background: #f0f4fa;
  border-bottom-color: var(--color-secondary);
}
.main-nav a.btn {
  /* Reset para que los botones del nav se vean como botones, no como links */
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}
.main-nav a.btn-ghost { color: #1a202c; }
.main-nav a.btn-ghost:hover { background: #edf2f7; color: var(--color-primary); }

/* =====================================================
   BOTONES
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: .95rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  letter-spacing: .01em;
}
.btn-primary  { background: var(--color-primary); color: #ffffff; border-color: var(--color-primary); }
.btn-primary:hover  { background: var(--color-primary-dark); color: #ffffff; border-color: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15,52,96,.25); }
.btn-secondary{ background: var(--color-secondary); color: #ffffff; border-color: var(--color-secondary); }
.btn-secondary:hover{ background: #138d75; color: #ffffff; border-color: #138d75; transform: translateY(-1px); }
.btn-outline   { background: #ffffff; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary); color: #ffffff; }
.btn-ghost     { background: transparent; color: #1a202c; }
.btn-ghost:hover   { background: #edf2f7; color: var(--color-primary); }
.btn-danger    { background: var(--color-danger); color: #ffffff; border-color: var(--color-danger); }
.btn-danger:hover  { background: #a53025; color: #ffffff; border-color: #a53025; }
.btn-sm        { padding: 7px 14px; font-size: .85rem; }
.btn-lg        { padding: 14px 28px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* =====================================================
   MAIN / FOOTER
   ===================================================== */
.site-main { min-height: calc(100vh - 72px - 240px); padding: 32px 0; }

.site-footer {
  background: var(--color-primary-dark);
  color: #cbd5e0;
  padding: 48px 0 24px;
  margin-top: 64px;
}
.site-footer h4 { color: #fff; margin-bottom: 12px; font-size: 1rem; }
.site-footer ul { list-style: none; }
.site-footer ul li { margin-bottom: 6px; }
.site-footer a { color: #cbd5e0; }
.site-footer a:hover { color: var(--color-secondary); }
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
}

/* =====================================================
   HERO / LANDING
   ===================================================== */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  padding: 80px 0 64px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(22,160,133,.25) 0, transparent 40%),
                    radial-gradient(circle at 80% 70%, rgba(233,69,96,.2) 0, transparent 40%);
  pointer-events: none;
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1.2fr .8fr; gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.1; margin-bottom: 18px; font-weight: 800; }
.hero .lead { font-size: 1.15rem; opacity: .92; max-width: 560px; margin-bottom: 28px; }
.hero .hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero .pill { display: inline-block; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); padding: 6px 14px; border-radius: 999px; font-size: .85rem; margin-bottom: 18px; }

.hero-card {
  background: #fff; color: var(--color-text);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.hero-card h3 { color: var(--color-primary); margin-bottom: 12px; font-size: 1.2rem; }
.hero-card ul { list-style: none; }
.hero-card ul li { padding: 6px 0; border-bottom: 1px dashed var(--color-border); font-size: .9rem; }
.hero-card ul li:last-child { border: 0; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 36px; }
@media (max-width: 700px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
.stat { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; color: #fff; }
.stat-lbl { font-size: .82rem; opacity: .8; }

/* =====================================================
   SECCIONES GENERALES
   ===================================================== */
.section { padding: 56px 0; }
.section-title { text-align: center; margin-bottom: 36px; }
.section-title h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--color-primary); margin-bottom: 8px; }
.section-title p { color: var(--color-text-muted); max-width: 720px; margin: 0 auto; }

/* =====================================================
   CARDS / CHAPTERS / FEATURES
   ===================================================== */
.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card h3 { color: var(--color-primary); margin-bottom: 10px; font-size: 1.15rem; }
.card .meta { font-size: .82rem; color: var(--color-text-muted); margin-bottom: 8px; }

.feature-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem; margin-bottom: 14px;
}

.chapter-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  border: 1px solid var(--color-border);
}
.chapter-card .ch-head {
  padding: 22px;
  color: #fff;
  position: relative;
}
.chapter-card.c1 .ch-head { background: linear-gradient(135deg, #0f3460, #16537e); }
.chapter-card.c2 .ch-head { background: linear-gradient(135deg, #16a085, #1abc9c); }
.chapter-card.c3 .ch-head { background: linear-gradient(135deg, #e94560, #c0394e); }
.chapter-card .ch-num { font-size: .8rem; opacity: .8; text-transform: uppercase; letter-spacing: 1.2px; }
.chapter-card .ch-title { font-size: 1.4rem; font-weight: 700; margin-top: 6px; }
.chapter-card .ch-body { padding: 22px; flex: 1; }
.chapter-card .ch-body p { color: var(--color-text-muted); margin-bottom: 14px; }
.chapter-card .ch-foot { padding: 14px 22px; border-top: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; background: var(--color-bg-alt); }

/* =====================================================
   TEMA (vista individual)
   ===================================================== */
.tema-hero {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  padding: 56px 0 40px;
}
.tema-hero .breadcrumb { font-size: .85rem; opacity: .85; margin-bottom: 12px; }
.tema-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 12px; }
.tema-hero .tema-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.tema-hero .tema-meta span { background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 999px; font-size: .85rem; }
.tema-hero .tema-frase {
  font-style: italic; opacity: .92;
  border-left: 3px solid var(--color-secondary);
  padding: 10px 16px; margin-top: 18px; max-width: 720px;
}

.tema-body { display: grid; grid-template-columns: 240px 1fr; gap: 32px; padding: 36px 0; }
@media (max-width: 900px) { .tema-body { grid-template-columns: 1fr; } }

.tema-side {
  position: sticky; top: 96px;
  align-self: start;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.tema-side h4 { color: var(--color-primary); font-size: .95rem; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--color-secondary); }
.tema-side ol { list-style: none; counter-reset: sec; }
.tema-side ol li { counter-increment: sec; padding: 8px 0 8px 30px; position: relative; font-size: .9rem; border-bottom: 1px dashed var(--color-border); }
.tema-side ol li::before { content: counter(sec); position: absolute; left: 0; top: 8px; background: var(--color-primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.tema-side ol li a { color: var(--color-text); }
.tema-side ol li a:hover { color: var(--color-secondary); }

.tema-content h2 { color: var(--color-primary); font-size: 1.6rem; margin: 32px 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--color-secondary); }
.tema-content h3 { color: var(--color-primary-dark); font-size: 1.2rem; margin: 22px 0 10px; }
.tema-content h4 { color: var(--color-primary); font-size: 1.05rem; margin: 16px 0 8px; }
.tema-content p, .tema-content li { margin-bottom: 10px; }
.tema-content ul, .tema-content ol { padding-left: 22px; }

.callout {
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg-alt);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}
.callout.warning { border-left-color: var(--color-warning); background: #fef5e7; }
.callout.success { border-left-color: var(--color-success); background: #e8f8ef; }
.callout.danger  { border-left-color: var(--color-danger);  background: #fceae8; }
.callout.info    { border-left-color: var(--color-secondary); background: #e8f6f3; }
.callout strong  { color: var(--color-primary); }

.code-block {
  background: #1e2530;
  color: #d1d5db;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .9rem;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.5;
}
.code-block .kw { color: #f59e0b; }
.code-block .str{ color: #34d399; }
.code-block .com{ color: #94a3b8; font-style: italic; }

.video-slot {
  background: var(--color-bg-alt);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0;
  text-align: center;
}
.video-slot .video-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius-sm); background: #000; }
.video-slot .video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-slot .placeholder { padding: 40px 20px; color: var(--color-text-muted); }
.video-slot .placeholder .ico { font-size: 3rem; margin-bottom: 8px; }

.timeline { position: relative; padding-left: 30px; margin: 18px 0; }
.timeline::before { content:''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--color-secondary); }
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item::before { content:''; position: absolute; left: -29px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--color-primary); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--color-primary); }
.timeline-item .tl-year { font-weight: 700; color: var(--color-primary); }
.timeline-item .tl-title { font-weight: 600; }
.timeline-item .tl-desc { color: var(--color-text-muted); font-size: .9rem; }

.comparativa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
@media (max-width: 700px) { .comparativa-grid { grid-template-columns: 1fr; } }
.comparativa-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; }
.comparativa-card h4 { text-align: center; color: var(--color-primary); margin-bottom: 10px; }
.comparativa-card ul { list-style: none; }
.comparativa-card ul li { padding: 6px 0; border-bottom: 1px dashed var(--color-border); }

.table-wrap { overflow-x: auto; margin: 14px 0; }
table { width: 100%; border-collapse: collapse; }
table th { background: var(--color-primary); color: #fff; padding: 10px 12px; text-align: left; font-size: .9rem; }
table td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
table tr:nth-child(even) { background: var(--color-bg-alt); }

/* =====================================================
   FORMULARIOS
   ===================================================== */
.form-card {
  max-width: 480px; margin: 40px auto;
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
}
.form-card h2 { color: var(--color-primary); margin-bottom: 6px; }
.form-card p  { color: var(--color-text-muted); margin-bottom: 22px; font-size: .95rem; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--color-text); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 1rem;
  background: #fff; color: var(--color-text);
  transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: 0; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15,52,96,.12);
}
.form-help { font-size: .8rem; color: var(--color-text-muted); margin-top: 4px; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .9rem; }
.alert-error   { background: #fceae8; color: var(--color-danger);  border-left: 4px solid var(--color-danger); }
.alert-success { background: #e8f8ef; color: var(--color-success); border-left: 4px solid var(--color-success); }
.alert-info    { background: #e8f0fc; color: var(--color-primary); border-left: 4px solid var(--color-primary); }

/* =====================================================
   DASHBOARD / TABS
   ===================================================== */
.dash-hero {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff; padding: 32px 0;
}
.dash-hero h1 { font-size: 1.6rem; margin-bottom: 6px; }
.dash-hero p { opacity: .9; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
.dash-stat { background: rgba(255,255,255,.12); padding: 14px; border-radius: var(--radius-sm); }
.dash-stat strong { display: block; font-size: 1.6rem; }
.dash-stat small { opacity: .85; font-size: .8rem; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--color-border); margin-bottom: 24px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px; cursor: pointer;
  border: 0; background: transparent; font-family: inherit; font-size: .95rem;
  color: var(--color-text-muted); font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab:hover { color: var(--color-primary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-secondary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* =====================================================
   TEST
   ===================================================== */
.test-progress {
  background: var(--color-card); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 84px; z-index: 50; box-shadow: var(--shadow-sm);
}
.progress-bar { height: 8px; background: var(--color-bg-alt); border-radius: 4px; flex: 1; margin: 0 16px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--color-primary), var(--color-secondary)); transition: width .3s ease; }
.question-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.question-num { color: var(--color-secondary); font-weight: 700; font-size: .85rem; }
.question-text { font-size: 1.05rem; font-weight: 600; margin: 6px 0 14px; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  background: #fff;
}
.option:hover { border-color: var(--color-primary); background: var(--color-bg-alt); }
.option input[type="radio"] { margin: 0; }
.option.selected { border-color: var(--color-primary); background: rgba(15,52,96,.05); }
.option.correct { border-color: var(--color-success); background: #e8f8ef; }
.option.incorrect { border-color: var(--color-danger); background: #fceae8; }
.option.disabled { cursor: default; opacity: .9; }
.option-key { font-weight: 700; min-width: 24px; color: var(--color-primary); }
.option-text { flex: 1; }
.option.disabled.correct .option-key { color: var(--color-success); }
.option.disabled.incorrect .option-key { color: var(--color-danger); }

.explanation { background: var(--color-bg-alt); border-left: 3px solid var(--color-secondary); padding: 10px 14px; margin-top: 12px; border-radius: var(--radius-sm); font-size: .9rem; }

.test-result { text-align: center; padding: 40px 20px; }
.test-result .score { font-size: 4rem; font-weight: 800; color: var(--color-primary); margin: 16px 0; }
.test-result .verdict { font-size: 1.2rem; margin-bottom: 24px; }
.test-result .verdict.pass { color: var(--color-success); }
.test-result .verdict.fail { color: var(--color-danger); }

/* =====================================================
   ADMIN
   ===================================================== */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 72px); }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-side {
  background: var(--color-primary-dark);
  color: #cbd5e0; padding: 24px 0;
}
.admin-side h3 { color: #fff; padding: 0 22px 14px; font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 14px; }
.admin-side nav a { display: flex; align-items: center; gap: 10px; padding: 12px 22px; color: #cbd5e0; border-left: 3px solid transparent; }
.admin-side nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin-side nav a.active { background: rgba(22,160,133,.18); color: #fff; border-left-color: var(--color-secondary); }

.admin-main { padding: 24px 32px; overflow-x: auto; }
.admin-main h1 { color: var(--color-primary); margin-bottom: 20px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 24px; }
.kpi { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.kpi-label { color: var(--color-text-muted); font-size: .85rem; }
.kpi-value { font-size: 1.8rem; font-weight: 800; color: var(--color-primary); margin-top: 4px; }
.kpi-delta { font-size: .8rem; color: var(--color-secondary); }

.chart-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.chart-card h3 { color: var(--color-primary); margin-bottom: 12px; font-size: 1.05rem; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.bar { flex: 1; background: linear-gradient(180deg, var(--color-secondary), var(--color-primary)); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; transition: all .2s; }
.bar:hover { opacity: .8; }
.bar-label { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--color-text-muted); white-space: nowrap; }
.bar-value { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: .75rem; font-weight: 700; color: var(--color-primary); }

.table-admin { width: 100%; background: var(--color-card); border-collapse: collapse; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-admin th, .table-admin td { padding: 10px 14px; text-align: left; font-size: .9rem; border-bottom: 1px solid var(--color-border); }
.table-admin th { background: var(--color-primary); color: #fff; font-weight: 600; }
.table-admin tr:hover td { background: var(--color-bg-alt); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #e8f8ef; color: var(--color-success); }
.badge-warning { background: #fef5e7; color: var(--color-warning); }
.badge-danger  { background: #fceae8; color: var(--color-danger); }
.badge-info    { background: #e8f0fc; color: var(--color-primary); }

/* =====================================================
   PROGRESS BARS (XP / Insignia)
   ===================================================== */
.xp-bar { background: var(--color-bg-alt); border-radius: 6px; height: 8px; overflow: hidden; margin: 8px 0; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--color-warning), var(--color-accent)); transition: width .3s; }

.tema-list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  margin-bottom: 10px;
  transition: var(--transition);
}
.tema-list-item:hover { box-shadow: var(--shadow); transform: translateX(2px); border-left: 4px solid var(--color-secondary); }
.tema-list-item .badge-num {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.tema-list-item.c1 .badge-num { background: var(--color-primary); }
.tema-list-item.c2 .badge-num { background: var(--color-secondary); }
.tema-list-item.c3 .badge-num { background: var(--color-accent); }
.tema-list-item .info { flex: 1; }
.tema-list-item .info h4 { font-size: 1rem; margin-bottom: 2px; color: var(--color-primary); }
.tema-list-item .info small { color: var(--color-text-muted); font-size: .82rem; }

/* =====================================================
   UTILIDADES
   ===================================================== */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.flex { display: flex; } .flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.hide { display: none !important; }

/* =====================================================
   FONDOS CON IMAGEN (fondofs.png)
   Overlay oscuro para mantener contraste de texto
   ===================================================== */
.with-bg {
  position: relative;
  background-image: url('../img/fondofs.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: #ffffff;
  isolation: isolate;
}
.with-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10, 25, 60, 0.85) 0%, rgba(30, 40, 90, 0.78) 50%, rgba(15, 30, 80, 0.85) 100%);
  z-index: -1;
}
/* Combinaciones: cuando .with-bg se aplica a secciones con su propio fondo, sobrescribe */
.hero.with-bg,
.section.with-bg,
.ia-hero.with-bg,
.ia-section.ia-principios.with-bg {
  background-image: url('../img/fondofs.png') !important;
  background-color: transparent !important;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
.with-bg h1, .with-bg h2, .with-bg h3 { color: #ffffff; }
.with-bg .muted, .with-bg .small { color: rgba(255,255,255,.78) !important; }
.with-bg .card {
  background: rgba(255,255,255,.96);
  color: var(--color-text);
}
.with-bg .card h3 { color: var(--color-primary); }
.with-bg .feature-icon {
  background: linear-gradient(135deg, #5b21b6, #2563eb);
}
.with-bg .section-title h2 { color: #ffffff; }
.with-bg .section-title p { color: rgba(255,255,255,.85); }

@media (max-width: 700px) {
  .with-bg { background-attachment: scroll; }
}

/* =====================================================
   SECCIÓN "IA COMO COPILOTO"
   ===================================================== */
.ia-hero {
  color: #fff;
  padding: 80px 0 64px;
  position: relative;
  overflow: hidden;
  background-color: #0a2547;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(139,92,246,.35) 0, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(56,189,248,.3) 0, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(236,72,153,.18) 0, transparent 50%);
}
.ia-hero .container { position: relative; z-index: 1; }
.ia-badge {
  display: inline-block;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 16px;
  backdrop-filter: blur(6px);
}
.ia-hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.1;
  margin-bottom: 16px;
  max-width: 800px;
  font-weight: 800;
}
.ia-lead {
  font-size: 1.15rem;
  opacity: .92;
  max-width: 720px;
  line-height: 1.5;
}

.ia-section {
  padding: 64px 0;
}
/* "Cómo se usa la IA en este manual": overlay más ligero para que se vea la imagen */
.ia-section.ia-principios.with-bg::before {
  background: linear-gradient(135deg, rgba(10, 25, 60, 0.45) 0%, rgba(30, 40, 90, 0.30) 50%, rgba(15, 30, 80, 0.50) 100%) !important;
}
.ia-section.ia-principios.with-bg h2.text-center {
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  padding: 6px 18px;
  display: inline-block;
  background: rgba(10, 25, 60, 0.35);
  border-radius: 12px;
  backdrop-filter: blur(4px);
}
/* Reconvertir las tarjetas de principios para que combinen con el fondo visible */
.ia-section.ia-principios.with-bg .ia-principio-card {
  background: rgba(255, 255, 255, 0.97);
}
.ia-section h2 {
  color: var(--color-primary);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  margin-bottom: 24px;
  font-weight: 700;
}
.ia-section h2.text-center { text-align: center; }

.ia-intro {
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.ia-intro-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 40px;
  align-items: start;
}
.ia-intro-grid p {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--color-text);
}
.ia-quote {
  background: linear-gradient(135deg, #f0f4fa 0%, #ffffff 100%);
  border-left: 4px solid var(--color-secondary);
  padding: 20px 24px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0;
  position: relative;
}
.ia-quote p {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--color-primary-dark);
  line-height: 1.5;
  margin-bottom: 12px;
}
.ia-quote cite {
  display: block;
  font-size: .85rem;
  font-style: normal;
  color: var(--color-text-muted);
  font-weight: 600;
}
.ia-quote::before {
  content: '"';
  position: absolute;
  top: -8px;
  left: 12px;
  font-size: 5rem;
  color: var(--color-secondary);
  opacity: .2;
  font-family: Georgia, serif;
  line-height: 1;
}
@media (max-width: 800px) {
  .ia-intro-grid { grid-template-columns: 1fr; }
}

.ia-principios { background: var(--color-bg-alt); }
.ia-principio-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}
.ia-principio-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.ia-principio-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #5b21b6, #2563eb);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 14px;
  color: #fff;
}
.ia-principio-card h3 {
  color: var(--color-primary-dark);
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.ia-principio-card p {
  color: var(--color-text-muted);
  font-size: .95rem;
  line-height: 1.55;
}

.ia-beneficios { background: var(--color-card); }
.ia-beneficio-card {
  background: linear-gradient(180deg, #f0f4fa 0%, #ffffff 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.ia-beneficio-card::before {
  content: '✓';
  position: absolute;
  top: 14px;
  right: 14px;
  width: 24px;
  height: 24px;
  background: var(--color-secondary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.ia-beneficio-card h3 {
  color: var(--color-primary-dark);
  font-size: 1rem;
  margin-bottom: 8px;
  padding-right: 30px;
}
.ia-beneficio-card p {
  color: var(--color-text-muted);
  font-size: .9rem;
  line-height: 1.5;
}

.ia-cta {
  background: linear-gradient(135deg, #f39c12 0%, #d97706 100%);
  color: #fff;
  padding: 56px 0;
}
.ia-cta h2 {
  color: #fff;
  font-size: 2rem;
  margin-bottom: 12px;
  font-weight: 800;
}
.ia-cta p {
  font-size: 1.1rem;
  opacity: .95;
  max-width: 640px;
  margin: 0 auto 24px;
}
.ia-cta .btn-secondary {
  background: #ffffff;
  color: #d97706;
  border-color: #ffffff;
  font-weight: 700;
}
.ia-cta .btn-secondary:hover {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}

/* =====================================================
   COMPONENTE MANUAL AMAZON
   ===================================================== */
.manual-inline {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
  background: linear-gradient(135deg, #fff8e1 0%, #ffffff 50%);
  border: 2px solid #f0c674;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.manual-inline::before {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(243,156,18,.12) 0, transparent 70%);
  pointer-events: none;
}
.manual-inline-cover {
  position: relative;
  z-index: 1;
}
.manual-inline-cover img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  transition: transform .25s ease;
}
.manual-inline-cover a:hover img {
  transform: scale(1.03) rotate(-1deg);
}
.manual-inline-body { z-index: 1; position: relative; }
.manual-badge {
  display: inline-block;
  background: #f0c674;
  color: #5d4500;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.manual-inline-body h3 {
  font-size: 1.4rem;
  color: #5d4500;
  line-height: 1.25;
  margin-bottom: 4px;
}
.manual-subtitulo {
  color: #6b5300;
  font-style: italic;
  margin-bottom: 8px;
  font-size: .95rem;
}
.manual-meta {
  color: var(--color-text-muted);
  font-size: .9rem;
  margin-bottom: 10px;
}
.manual-rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: .9rem;
  color: var(--color-text-muted);
}
.manual-stars {
  color: #f39c12;
  font-size: 1.1rem;
  letter-spacing: 2px;
}
.manual-prices {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.manual-precio-old {
  text-decoration: line-through;
  color: #888;
  font-size: .9rem;
}
.manual-precio-new {
  color: var(--color-danger);
  font-size: 1.6rem;
  font-weight: 800;
}
.manual-oferta {
  background: var(--color-danger);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.manual-desc {
  color: var(--color-text);
  font-size: .92rem;
  line-height: 1.5;
  margin-bottom: 14px;
}
.manual-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.manual-isbn {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--color-text-muted);
}

.manual-sidebar {
  position: sticky;
  top: 96px;
  font-size: .9rem;
}
.manual-sidebar .manual-cover {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
  margin-bottom: 8px;
}

.manual-compact:hover {
  border-color: var(--color-secondary);
  transform: translateY(-1px);
}

@media (max-width: 700px) {
  .manual-inline { grid-template-columns: 1fr; }
  .manual-inline-cover { max-width: 180px; margin: 0 auto; }
}

/* =====================================================
   ACORDEÓN (Respuestas de autoevaluación)
   ===================================================== */
.accordion { display: flex; flex-direction: column; gap: 10px; }
.accordion-item {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.accordion-item.open {
  box-shadow: var(--shadow);
  border-color: var(--color-secondary);
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--color-card);
  border: 0;
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  transition: background .15s ease;
}
.accordion-header:hover { background: var(--color-bg-alt); }
.accordion-header .acc-chevron {
  transition: transform .2s ease;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-left: 12px;
}
.accordion-item.open .acc-chevron { transform: rotate(180deg); color: var(--color-secondary); }
.accordion-header .acc-title { flex: 1; min-width: 0; }
.accordion-header .acc-counter {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  margin-right: 8px;
}
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease;
}
.accordion-item.open .accordion-content { max-height: 12000px; }
.accordion-body { padding: 4px 20px 20px; }
.accordion-subitem {
  border-top: 1px solid var(--color-border);
  margin-top: 12px;
  padding-top: 12px;
}
.accordion-subitem:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.accordion-subitem h4 {
  font-size: 1rem;
  color: var(--color-secondary);
  margin-bottom: 8px;
}
.acc-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.acc-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
}

/* =====================================================
   IMPRESIÓN (B/N friendly)
   ===================================================== */
@media print {
  .site-header, .site-footer, .tema-side, .video-slot, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .tema-body { grid-template-columns: 1fr; padding: 0; }
  .tema-hero { background: #fff !important; color: #000; padding: 12px 0; border-bottom: 2px solid #000; }
  .tema-hero h1, .tema-hero h2, .tema-hero h3 { color: #000 !important; }
  .code-block { background: #f4f4f4 !important; color: #000 !important; border: 1px solid #999; }
  .callout { border: 1px solid #000 !important; background: #fff !important; page-break-inside: avoid; }
  h2, h3 { page-break-after: avoid; }
  .card, .question-card, .chapter-card { break-inside: avoid; box-shadow: none; border: 1px solid #999; }
}
