/* ═══════════════════════════════════════════════════════════
   TOGGLE UNIVERSAL - Estilos CSS unificados
   Incluye: cejilla, TOC, y ventanas
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Colores del TEC (del curso de Probabilidad) */
  --tec-bg:      #f0ede8;
  --tec-ink:     #0d1117;
  --tec-accent:  #1a4f8a;
  --tec-gold:    #c8922a;
  --tec-rule:    #d4cfc9;
  --tec-info-bg: #eef3fb;
  
  /* Colores legacy del TOC */
  --tverde: #176B3B;
  --fondo:  #FFFCF5;
  --borde:  #EAE5DC;
  --hover:  #F0F0F0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tec-bg:      #0d1117;
    --tec-ink:     #e4dfd8;
    --tec-accent:  #4a9ade;
    --tec-rule:    #1e2d3d;
    --tec-info-bg: #0f2035;
    --fondo:       #1a1a1a;
    --borde:       #333;
    --hover:       #252525;
  }
}

/* ═══════════════════════════════════════════════════════════
   CEJILLA - Pestañas colapsables estilo TEC
   ═══════════════════════════════════════════════════════════ */

.cejilla-container {
  background: var(--tec-info-bg);
  border: 1px solid var(--tec-rule);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0;
}

.cejilla-toggle {
  width: 100%;
  padding: 0.75rem 1.1rem;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tec-accent);
  text-align: left;
  transition: background 0.2s;
}

.cejilla-toggle:hover {
  background: rgba(26, 79, 138, 0.05);
}

.cejilla-toggle:focus {
  outline: 2px solid var(--tec-accent);
  outline-offset: -2px;
}

.cejilla-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.cejilla-toggle[aria-expanded="true"] .cejilla-arrow {
  transform: rotate(180deg);
}

.cejilla-body {
  padding: 0 1.1rem 1.1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--tec-ink);
}

.cejilla-body[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .cejilla-body {
    animation: cejilla-slide 0.2s ease;
  }
  
  @keyframes cejilla-slide {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ═══════════════════════════════════════════════════════════
   TOC - Tabla de contenidos (estilo legacy minimalista)
   ═══════════════════════════════════════════════════════════ */

.toc-btn {
  background: var(--fondo);
  border: 1px solid var(--borde);
  padding: 8px 15px;
  cursor: pointer;
  margin: 1em 0;
  font-size: 0.9em;
  color: #666;
  display: inline-flex;
  align-items: center;
  transition: all 0.3s ease;
  border-radius: 4px;
  position: relative;
}

.toc-btn:hover {
  background: var(--hover);
  border-color: #D5D5D5;
}

.toc-btn::after {
  content: "";
  margin-left: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #999;
  transition: all 0.3s ease;
}

.toc-btn.collapsed::after {
  border-top: none;
  border-bottom: 6px solid #999;
}

#toc-container {
  display: none;
  background: var(--fondo);
  padding: 1.2em;
  margin: 0.5em 0 1.5em;
  border: 1px solid var(--borde);
  border-radius: 4px;
}

#toc-container.visible {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#toc-container ul {
  list-style: none;
  padding-left: 0.8em;
  margin: 0;
}

#toc-container li {
  padding: 5px 0;
  position: relative;
}

#toc-container li::before {
  content: "•";
  color: #CCC;
  position: absolute;
  left: -0.8em;
  font-size: 0.9em;
}

#toc-container a {
  text-decoration: none;
  color: #666;
  font-size: 0.88em;
  transition: color 0.3s ease;
}

#toc-container a:hover {
  color: #444;
}

/* ═══════════════════════════════════════════════════════════
   VENTANA - Toggle genérico con data-target
   No requiere estilos específicos, usa los del elemento target
   ═══════════════════════════════════════════════════════════ */

.toggle-ventana-btn {
  cursor: pointer;
}

/* Ajustes para modo oscuro en TOC */
@media (prefers-color-scheme: dark) {
  .toc-btn {
    color: #aaa;
  }
  
  .toc-btn:hover {
    background: var(--hover);
  }
  
  #toc-container a {
    color: #aaa;
  }
  
  #toc-container a:hover {
    color: #ddd;
  }
}

