/* Reset y variables */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Tema claro (por defecto) */
  --bg:        #f8f9fa;
  --surface:   #ffffff;
  --surface-2: #f1f5f9;
  --text:      #1a1f2e;
  --text-muted:#6b7280;
  --border:    #e5e7eb;
  --accent-bg: #fff3ef;

  /* Siempre oscuros (header, pre, callout, arch-diagram) */
  --dark:      #1a1f2e;
  --dark-2:    #242938;
  --dark-text: #e5e7eb;

  /* Acento naranja — siempre igual */
  --accent:    #e8734a;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

[data-theme="dark"] {
  --bg:        #0f1117;
  --surface:   #1a1f2e;
  --surface-2: #242938;
  --text:      #e5e7eb;
  --text-muted:#9ca3af;
  --border:    #374151;
  --accent-bg: #2d1a10;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }

/* Header */
.site-header {
  background: var(--dark);
  color: var(--dark-text);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; color: var(--dark-text); }
.site-header .logo span { color: var(--accent); }
.site-header .badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--dark-2);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #374151;
}

/* Toggle tema */
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid #374151;
  cursor: pointer;
  color: var(--dark-text);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  opacity: 0.65;
  transition: opacity 0.15s;
  font-size: 0.85rem;
  line-height: 1;
}
.theme-toggle:hover { opacity: 1; }
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Layout de página de proyecto */
.project-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}
.sidebar nav a {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.4;
  transition: background 0.1s, color 0.1s;
}
.sidebar nav a:hover { background: var(--bg); color: var(--text); }
.sidebar nav a.active { color: var(--text); background: var(--accent-bg); }
.sidebar nav a .num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 1.25rem;
  margin-top: 0.1rem;
}

/* Contenido principal */
.content { padding: 3rem 4rem; max-width: 760px; }

.content h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 1rem; color: var(--text); }
.content .lead { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 2.5rem; border-bottom: 1px solid var(--border); padding-bottom: 2rem; }

.section { margin-bottom: 3.5rem; scroll-margin-top: 80px; }
.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: white;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: 50%;
  margin-bottom: 0.75rem;
}
.section h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }
.section h3 { color: var(--text); }
.section p { color: var(--text-muted); margin-bottom: 0.75rem; }
.section p strong { color: var(--text); }

/* Tablas */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.875rem; }
thead tr { background: var(--dark); color: var(--dark-text); }
th { padding: 0.6rem 1rem; text-align: left; font-weight: 600; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; }
td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-muted); }
td strong { color: var(--text); }
tr:hover td { background: var(--bg); }

/* Código inline */
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text);
}

/* Bloque de código */
pre {
  background: var(--dark);
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 1rem 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

/* Listas */
.section ul, .section ol { padding-left: 1.5rem; color: var(--text-muted); }
.section li { margin-bottom: 0.4rem; }
.section li strong { color: var(--text); }

/* Chips / badges */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--dark);
  color: var(--dark-text);
  letter-spacing: 0.02em;
}
.chip.green { background: #ecfdf5; color: #065f46; }
.chip.red { background: #fef2f2; color: #991b1b; }

/* Callout */
.callout {
  background: var(--dark-2);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1.25rem 0;
  color: var(--dark-text);
  font-size: 0.9rem;
}
.callout p { color: var(--dark-text); margin: 0; font-size: 0.9rem; }
.callout p strong, .callout strong { color: white; }
.callout code { background: rgba(255,255,255,0.1); color: var(--dark-text); }

/* Pasos de replicación */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li {
  counter-increment: step;
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}
.steps li::before {
  content: counter(step);
  min-width: 1.75rem;
  height: 1.75rem;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.steps li div { flex: 1; }
.steps li strong { display: block; margin-bottom: 0.25rem; color: var(--text); }
.steps li span { font-size: 0.875rem; color: var(--text-muted); }

/* Diagrama de arquitectura */
.arch-diagram {
  background: var(--dark);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 2;
  margin: 1rem 0;
}
.arch-diagram .highlight { color: var(--accent); font-weight: 700; }
.arch-diagram .dim { color: #4b5563; }

/* Index page */
.index-main { padding: 4rem 2rem; max-width: 680px; margin: 0 auto; }
.index-main h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 0.5rem; color: var(--text); }
.index-main .subtitle { font-size: 1rem; color: var(--text-muted); margin-bottom: 3rem; }
.project-grid { display: flex; flex-direction: column; gap: 1rem; }
.project-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.project-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); border-color: #d1d5db; }
.project-card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.35rem; color: var(--text); }
.project-card p { font-size: 0.875rem; color: var(--text-muted); }
.project-card .arrow { color: var(--accent); font-size: 1rem; float: right; margin-top: -1.5rem; }

/* Footer */
.site-footer {
  padding: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

/* Wrapper con botón copiar */
.code-block { position: relative; }
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #94a3b8;
  font-size: 0.7rem;
  font-family: var(--font);
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.5;
}
.copy-btn:hover { background: rgba(255,255,255,0.15); color: #e2e8f0; }
.copy-btn.copied { color: #4ade80; border-color: rgba(74,222,128,0.4); }

/* Nav mobile */
.mobile-nav { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .project-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 1.5rem 1.25rem; }
  .index-main { padding: 2rem 1.25rem; }

  .mobile-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 52px;
    z-index: 90;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    transition: all 0.15s;
  }
  .mobile-nav a.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }
  .mobile-nav a .num {
    font-size: 0.65rem;
    opacity: 0.7;
  }
}
