/* estilo.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 50%, #0f1d35 100%);
  background-attachment: fixed;
  color: #e8ecf1;
  overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  background: linear-gradient(135deg, #0d1f3c 0%, #162a4a 100%);
  border-bottom: 1px solid rgba(100, 149, 237, 0.12);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  width: 100%;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.header-container h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  font-weight: 700;
  background: linear-gradient(90deg, #e8ecf1 0%, #87ceeb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.btn-volver {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  background: linear-gradient(135deg, #1e5aa8 0%, #2a7cc7 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 15px rgba(42, 124, 199, 0.25);
  margin-left: auto;
  flex-shrink: 0;
}

.btn-volver:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(42, 124, 199, 0.4);
}

/* ============================================================
   CONTENEDOR PRINCIPAL
   ============================================================ */
.contenedor-principal {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 0.5rem 1rem 1rem;
  gap: 1rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 320px;
  min-width: 260px;
  background: linear-gradient(
    145deg,
    rgba(20, 40, 70, 0.7) 0%,
    rgba(15, 30, 55, 0.85) 100%
  );
  border: 1px solid rgba(100, 149, 237, 0.12);
  border-radius: 14px;
  padding: 1.2rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar h2 {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
  color: #87ceeb;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(100, 149, 237, 0.1);
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  color: #c8d8ec;
  border-radius: 8px;
  margin-bottom: 0.3rem;
  cursor: pointer;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: background-color 0.3s ease, border-color 0.3s ease,
    transform 0.2s ease;
}

.sidebar a:hover {
  background: rgba(42, 124, 199, 0.15);
  border-color: rgba(100, 149, 237, 0.25);
  transform: translateX(4px);
}

.sidebar a:active {
  transform: scale(0.98);
}

.sidebar a.activo {
  background: rgba(42, 124, 199, 0.25);
  border-color: rgba(100, 149, 237, 0.4);
  color: #fff;
}

/* Badge de extensión */
.ext-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(135, 206, 235, 0.15);
  color: #87ceeb;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  margin-left: auto;
}

/* ============================================================
   COLUMNA DERECHA: VISOR DE CÓDIGO
   ============================================================ */
.content {
  flex: 1;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(100, 149, 237, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(4px);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Barra superior del visor */
.visor-barra {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: rgba(13, 31, 60, 0.8);
  border-bottom: 1px solid rgba(100, 149, 237, 0.12);
  border-radius: 14px 14px 0 0;
  gap: 1rem;
  flex-shrink: 0;
}

.visor-barra.visible {
  display: flex;
}

.visor-barra .nombre-archivo {
  font-size: 0.85rem;
  color: #87ceeb;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visor-barra .lenguaje-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: rgba(135, 206, 235, 0.12);
  color: #87ceeb;
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}

.btn-descargar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: linear-gradient(135deg, #1a8a4a 0%, #22b05e 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8rem;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 15px rgba(34, 176, 94, 0.25);
  flex-shrink: 0;
}

.btn-descargar:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34, 176, 94, 0.4);
}

/* Placeholder inicial */
.visor-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a9ab8;
  font-size: 0.95rem;
  padding: 1.5rem;
  text-align: center;
}

/* Contenedor del código */
.codigo-contenedor {
  flex: 1;
  overflow: auto;
  padding: 0;
  display: none;
}

.codigo-contenedor.visible {
  display: block;
}

/* ============================================================
   PRISM.JS - ESTILOS DE TOKENS CON COLORES
   ============================================================ */
.codigo-contenedor pre[class*="language-"],
.codigo-contenedor pre.line-numbers {
  margin: 0 !important;
  padding: 0 3.5rem !important;
  background: rgba(10, 18, 36, 0.95) !important;
  border-radius: 0 0 14px 14px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas",
    "Monaco", monospace !important;
  font-size: 0.85rem !important;
  line-height: 1.65 !important;
  tab-size: 4;
  color: #c9d1d9 !important;
  text-shadow: none !important;
  min-height: 100%;
}

/* Aplicar padding solo al código, no al pre */
.codigo-contenedor pre.line-numbers code[class*="language-"] {
  padding: 1.2rem 1.5rem !important;
  display: block;
}

/* Asegurar que los números tengan el mismo padding-top */
.codigo-contenedor .line-numbers-rows {
  padding-top: 1.2rem !important;
  padding-bottom: 1.2rem !important;
}




.codigo-contenedor code[class*="language-"] {
  font-family: inherit !important;
  font-size: inherit !important;
  text-shadow: none !important;
  color: inherit !important;
}

/* TOKENS - Colores específicos */
.codigo-contenedor .token.comment,
.codigo-contenedor .token.prolog,
.codigo-contenedor .token.doctype,
.codigo-contenedor .token.cdata {
  color: #6a7a8e !important;
  font-style: italic;
}

.codigo-contenedor .token.punctuation {
  color: #8b949e !important;
}

.codigo-contenedor .token.property,
.codigo-contenedor .token.tag,
.codigo-contenedor .token.boolean,
.codigo-contenedor .token.number,
.codigo-contenedor .token.constant,
.codigo-contenedor .token.symbol,
.codigo-contenedor .token.deleted {
  color: #79c0ff !important;
}

.codigo-contenedor .token.selector,
.codigo-contenedor .token.attr-name,
.codigo-contenedor .token.string,
.codigo-contenedor .token.char,
.codigo-contenedor .token.builtin,
.codigo-contenedor .token.inserted {
  color: #a5d6ff !important;
}

.codigo-contenedor .token.operator,
.codigo-contenedor .token.entity,
.codigo-contenedor .token.url {
  color: #d2a8ff !important;
}

.codigo-contenedor .token.atrule,
.codigo-contenedor .token.attr-value,
.codigo-contenedor .token.keyword {
  color: #ff7b72 !important;
}

.codigo-contenedor .token.function,
.codigo-contenedor .token.class-name {
  color: #d2a8ff !important;
}

.codigo-contenedor .token.regex,
.codigo-contenedor .token.important,
.codigo-contenedor .token.variable {
  color: #ffa657 !important;
}

/* Números de línea */
.line-numbers .line-numbers-rows {
  border-right: 1px solid rgba(100, 149, 237, 0.15) !important;
}

.line-numbers .line-numbers-rows > span::before {
  color: #3d5066 !important;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(42, 124, 199, 0.4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(42, 124, 199, 0.6);
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: #7a9ab8;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(135, 206, 235, 0.15);
  border-top-color: #87ceeb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .header-container {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-container h1 {
    font-size: 1.1rem;
  }

  .btn-volver {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
  }

  .contenedor-principal {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: 200px;
    border-radius: 12px;
    padding: 0.8rem;
  }

  .content {
    height: 55vh;
    border-radius: 12px;
  }

  .visor-barra {
    flex-wrap: wrap;
    padding: 0.5rem 0.8rem;
    border-radius: 12px 12px 0 0;
  }

  .codigo-contenedor pre[class*="language-"] {
    font-size: 0.78rem !important;
    padding: 1rem !important;
    border-radius: 0 0 12px 12px;
  }
}

@media (max-width: 480px) {
  .header-container h1 {
    font-size: 0.95rem;
  }

  .btn-volver {
    font-size: 0.75rem;
    padding: 0.3rem 0.8rem;
  }

  .sidebar {
    max-height: 160px;
  }

  .sidebar a {
    font-size: 0.8rem;
    padding: 0.5rem 0.7rem;
  }

  .btn-descargar {
    font-size: 0.72rem;
    padding: 0.35rem 0.7rem;
  }

  .codigo-contenedor pre[class*="language-"] {
    font-size: 0.72rem !important;
  }
}

/* ============================================================
   ACCESIBILIDAD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid #87ceeb;
  outline-offset: 2px;
}
