/* ===== VARIABLES ===== */
:root {
  --color-fondo: #FAF7F2;
  --color-fondo-card: #FFFFFF;
  --color-texto: #1A1A1A;
  --color-texto-secundario: #6B6B6B;
  --color-acento: #7A6B4F;
  --color-acento-claro: #A89B7E;
  --color-acento-bg: #F0EBE1;
  --color-exito: #5A7A5A;
  --color-exito-bg: #E8F0E8;
  --color-borde: #E5E0D8;
  --color-heatmap-0: #EDEAE4;
  --color-heatmap-1: #D4CCB8;
  --color-heatmap-2: #A89B7E;
  --color-heatmap-3: #7A6B4F;
  --font-serif: 'Lora', 'Georgia', serif;
  --font-sans: 'Inter', 'Helvetica Neue', sans-serif;
  --radio: 8px;
  --sombra: 0 1px 3px rgba(0,0,0,0.06);
  --max-ancho: 800px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== BASE ===== */
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--color-fondo);
  color: var(--color-texto);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== TIPOGRAFIA ===== */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; }
h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
p { margin-bottom: 0.75rem; }
a { color: var(--color-acento); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LAYOUT ===== */
.contenedor {
  max-width: var(--max-ancho);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ===== NAVEGACION ===== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  max-width: var(--max-ancho);
  margin: 0 auto;
  border-bottom: 1px solid var(--color-borde);
}
.nav-logo {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-texto);
}
.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.875rem;
  color: var(--color-texto-secundario);
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a.activo {
  color: var(--color-acento);
  text-decoration: none;
}

/* ===== CARDS ===== */
.card {
  background: var(--color-fondo-card);
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--sombra);
}
.card-hoy {
  border-left: 4px solid var(--color-acento);
}
.card-etiqueta {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-acento);
  background: var(--color-acento-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.card-tipo {
  font-size: 0.75rem;
  color: var(--color-texto-secundario);
  text-transform: capitalize;
}
.card-titulo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin: 0.4rem 0;
}
.card-filosofo {
  font-size: 0.9rem;
  color: var(--color-texto-secundario);
  font-style: italic;
}
.card-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-texto-secundario);
}
.card-completada {
  opacity: 0.6;
}
.card-completada .card-titulo {
  text-decoration: line-through;
}

/* ===== BOTONES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radio);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primario {
  background: var(--color-acento);
  color: #fff;
}
.btn-secundario {
  background: var(--color-acento-bg);
  color: var(--color-acento);
}
.btn-exito {
  background: var(--color-exito);
  color: #fff;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== PROGRESO ===== */
.progreso-barra-exterior {
  width: 100%;
  height: 8px;
  background: var(--color-heatmap-0);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.progreso-barra-interior {
  height: 100%;
  background: var(--color-acento);
  border-radius: 4px;
  transition: width 0.5s ease;
}
.progreso-texto {
  font-size: 0.85rem;
  color: var(--color-texto-secundario);
}
.progreso-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

/* ===== RACHA ===== */
.racha {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-acento);
}
.racha-numero {
  font-size: 1.5rem;
  font-family: var(--font-serif);
}

/* ===== HEATMAP ===== */
.heatmap-contenedor {
  overflow-x: auto;
  padding: 0.5rem 0;
}
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  grid-auto-flow: column;
  grid-auto-columns: 14px;
  gap: 3px;
}
.heatmap-celda {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--color-heatmap-0);
}
.heatmap-celda[data-nivel="1"] { background: var(--color-heatmap-1); }
.heatmap-celda[data-nivel="2"] { background: var(--color-heatmap-2); }
.heatmap-celda[data-nivel="3"] { background: var(--color-heatmap-3); }
.heatmap-celda.futuro { background: transparent; border: 1px dashed var(--color-borde); }
.heatmap-meses {
  display: flex;
  gap: 0;
  font-size: 0.7rem;
  color: var(--color-texto-secundario);
  margin-bottom: 0.25rem;
}
.heatmap-meses span {
  flex: 1;
  min-width: 50px;
}

/* ===== PROXIMAS LECTURAS ===== */
.lista-proximas {
  list-style: none;
}
.lista-proximas li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-borde);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lista-proximas li:last-child { border-bottom: none; }
.proxima-titulo {
  font-size: 0.9rem;
}
.proxima-dia {
  font-size: 0.8rem;
  color: var(--color-texto-secundario);
  white-space: nowrap;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}
.modal-overlay.visible {
  display: flex;
}
.modal {
  background: var(--color-fondo-card);
  border-radius: var(--radio);
  padding: 1.5rem;
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal h2 {
  margin-bottom: 1rem;
}
.modal-cerrar {
  float: right;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-texto-secundario);
  line-height: 1;
}

/* ===== FORMULARIOS ===== */
.campo {
  margin-bottom: 1rem;
}
.campo label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--color-texto-secundario);
}
.campo textarea,
.campo input[type="text"],
.campo input[type="time"],
.campo input[type="date"],
.campo input[type="search"],
.campo select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  background: var(--color-fondo);
  color: var(--color-texto);
  resize: vertical;
}
.campo textarea:focus,
.campo input:focus,
.campo select:focus {
  outline: none;
  border-color: var(--color-acento);
  box-shadow: 0 0 0 2px var(--color-acento-bg);
}
.campo textarea { min-height: 80px; }

/* Dificultad (estrellas) */
.dificultad {
  display: flex;
  gap: 0.25rem;
}
.dificultad-btn {
  background: none;
  border: 1px solid var(--color-borde);
  border-radius: 4px;
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--color-texto-secundario);
}
.dificultad-btn.activo,
.dificultad-btn:hover {
  background: var(--color-acento);
  color: #fff;
  border-color: var(--color-acento);
}

/* ===== VISTA ETAPA ===== */
.etapa-header {
  margin-bottom: 1.5rem;
}
.etapa-contexto {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-texto-secundario);
  margin: 1rem 0;
  padding: 1rem;
  background: var(--color-acento-bg);
  border-radius: var(--radio);
}
.etapa-lista {
  list-style: none;
}
.etapa-lista li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-borde);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.etapa-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-borde);
  border-radius: 50%;
  flex-shrink: 0;
}
.etapa-check.hecho {
  background: var(--color-exito);
  border-color: var(--color-exito);
}
.etapa-lista .info {
  flex: 1;
}
.etapa-lista .titulo-lectura {
  font-size: 0.9rem;
}
.etapa-lista .meta-lectura {
  font-size: 0.8rem;
  color: var(--color-texto-secundario);
}

/* ===== NOTAS ===== */
.buscador {
  margin-bottom: 1.5rem;
}
.nota-card {
  border-left: 3px solid var(--color-acento-claro);
}
.nota-card .nota-fecha {
  font-size: 0.8rem;
  color: var(--color-texto-secundario);
}
.nota-card .nota-resumen {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0.5rem 0;
}
.nota-card .nota-frase {
  font-style: italic;
  color: var(--color-acento);
  border-left: 2px solid var(--color-acento-claro);
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.nota-card .nota-pregunta {
  font-size: 0.9rem;
  color: var(--color-texto-secundario);
}
.nota-dificultad {
  display: inline-flex;
  gap: 0.15rem;
  font-size: 0.75rem;
  color: var(--color-acento);
}

/* ===== AJUSTES ===== */
.ajuste-grupo {
  margin-bottom: 1.5rem;
}
.ajuste-grupo h3 {
  margin-bottom: 0.75rem;
}
.estado-notif {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radio);
  margin-top: 0.5rem;
}
.estado-notif.activo {
  background: var(--color-exito-bg);
  color: var(--color-exito);
}
.estado-notif.inactivo {
  background: #FFF3E0;
  color: #E65100;
}

/* ===== VACIO ===== */
.estado-vacio {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-texto-secundario);
}
.estado-vacio h3 {
  color: var(--color-texto);
  margin-bottom: 0.5rem;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-texto);
  color: var(--color-fondo);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radio);
  font-size: 0.875rem;
  z-index: 200;
  transition: transform 0.3s ease;
  white-space: nowrap;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .nav { flex-direction: column; gap: 0.75rem; }
  .card { padding: 1rem; }
  h1 { font-size: 1.4rem; }
  .heatmap { grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 2px; }
  .heatmap-celda { width: 12px; height: 12px; }
  .progreso-stats { flex-direction: column; gap: 0.25rem; }
}

/* ===== LOADER ===== */
.cargando {
  display: flex;
  justify-content: center;
  padding: 2rem;
}
.cargando::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-borde);
  border-top-color: var(--color-acento);
  border-radius: 50%;
  animation: girar 0.6s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ===== SELECTOR ETAPAS ===== */
.etapas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.etapa-mini {
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.2s;
}
.etapa-mini:hover {
  border-color: var(--color-acento);
}
.etapa-mini .etapa-num {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-acento);
}
.etapa-mini .etapa-nombre {
  font-family: var(--font-serif);
  font-size: 1rem;
  margin: 0.25rem 0;
}
.etapa-mini .etapa-progreso-texto {
  font-size: 0.8rem;
  color: var(--color-texto-secundario);
}
