/* ============================================================
   public/css/app.css
   ============================================================ */

:root {
  --bg:        #f0ebe8;
  --surface:   #ffffff;
  --primary:   #2d6a4f;
  --primary2:  #1b4332;
  --accent:    #52b788;
  --text:      #1a1a1a;
  --muted:     #6b7280;
  --border:    #e0d9d3;
  --error:     #c0392b;
  --success:   #2d6a4f;
  --radius:    16px;
  --shadow:    0 2px 20px rgba(0,0,0,.07);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
}

.page-wrap { min-height: 100vh; }

/* ── Contenedor ─────────────────────────────────────────────── */
.container {
  max-width: 660px;
  margin: 0 auto;
  padding: 3rem 1.25rem 5rem;
}

/* ── Header ─────────────────────────────────────────────────── */
.header { margin-bottom: 2rem; }

.badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .3rem .9rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.header h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: .75rem;
}

.header p {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
  max-width: 520px;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 2rem;
}

/* ── Campos ─────────────────────────────────────────────────── */
.field { margin-bottom: 1.35rem; }

.field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .45rem;
  letter-spacing: .01em;
}

.input-field {
  width: 100%;
  padding: .78rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #faf9f7;
  font-size: .9rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,106,79,.1);
  background: #fff;
}

select.input-field {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

optgroup { font-weight: 700; color: var(--primary); }
option   { font-weight: 400; color: var(--text); }

/* ── Botón principal ─────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  margin-top: 1.8rem;
  padding: .9rem 1.5rem;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .01em;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(45,106,79,.25);
}

.btn-primary:hover {
  background: var(--primary2);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(45,106,79,.35);
}

.btn-primary:active  { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; pointer-events: none; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Resultado ──────────────────────────────────────────────── */
.result-header { margin-bottom: 1.5rem; }

.btn-back {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .4rem .9rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 1.2rem;
  transition: border-color .2s, color .2s;
}
.btn-back:hover { border-color: var(--primary); color: var(--primary); }

.result-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  font-weight: 700;
  margin: .5rem 0 .4rem;
}

.result-meta {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.5;
}

.result-card {
  line-height: 1.75;
  font-size: .93rem;
}

.result-card h2, .result-card h3 {
  font-family: 'Fraunces', serif;
  color: var(--primary2);
  margin: 1.4rem 0 .5rem;
}

.result-card h2 { font-size: 1.2rem; }
.result-card h3 { font-size: 1rem; }

.result-card p  { margin-bottom: .8rem; color: #2d2d2d; }

.result-card ul, .result-card ol {
  padding-left: 1.4rem;
  margin-bottom: .8rem;
}

.result-card li { margin-bottom: .35rem; }

.result-card strong { color: var(--primary2); }

.result-card .dato-id {
  margin: .15rem 0;
  line-height: 1.5;
}
.result-card .dato-id strong {
  color: var(--primary2);
  min-width: 160px;
  display: inline-block;
}

.result-card hr {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 1.5rem 0;
}

.result-actions {
  margin-top: 1.5rem;
}

.btn-download { background: var(--primary2); }

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: .7rem 1.3rem;
  border-radius: 10px;
  font-size: .87rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show   { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success{ background: var(--success); }
#toast.error  { background: var(--error); }

/* ── Select múltiple ABP ────────────────────────────────────── */
#materiasMultiple {
  height: auto;
  min-height: 140px;
  background-image: none;  /* sin flecha */
  padding-right: 1rem;
}
#materiasMultiple option {
  padding: .4rem .6rem;
  border-radius: 4px;
  margin-bottom: 2px;
}
#materiasMultiple option:checked {
  background: var(--primary);
  color: #fff;
}
.abp-badge {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 999px;
  margin-left: .4rem;
  vertical-align: middle;
}

/* ── Botones de material ─────────────────────────────────────── */
.material-categoria {
  margin-bottom: .9rem;
}
.material-cat-titulo {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: .4rem;
}
.material-botones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
}
.material-botones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: .2rem;
}
.btn-material {
  padding: .65rem .8rem;
  border: 2px solid #ddd6fe;
  border-radius: 10px;
  background: #faf5ff;
  color: #5b21b6;
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  text-align: left;
}
.btn-material:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  transform: translateY(-1px);
}
.btn-material:disabled {
  opacity: .6;
  pointer-events: none;
}
.btn-material.generando {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}

/* ── Spinner de carga imagen ─────────────────────────────────── */
.img-placeholder {
  width: 100%;
  max-width: 400px;
  height: 200px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 10px;
  display: block;
  margin: .8rem auto;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Material de acompañamiento ────────────────────────────── */
.material-separator {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: 1.2rem 0 .6rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.material-separator::before,
.material-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Hojas de material */
.hoja {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 1.8rem 2rem;
  margin-bottom: 1.4rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
  page-break-after: always;
}
.hoja-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 1.2rem;
  padding-bottom: .8rem;
  border-bottom: 2px solid #ede9fe;
}
.hoja-icono {
  font-size: 1.4rem;
}
.hoja-titulo {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary2);
}
.hoja-subtitulo {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .1rem;
}

/* Imagen generada */
.img-generada {
  width: 100%;
  max-width: 340px;
  border-radius: 10px;
  display: block;
  margin: 1rem auto;
  border: 1.5px solid var(--border);
}
.img-loading {
  width: 100%;
  height: 180px;
  background: linear-gradient(90deg,#f3f4f6 25%,#e5e7eb 50%,#f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 10px;
  margin: 1rem 0;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Tarjetas de vocabulario */
.tarjetas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .8rem;
  margin-top: .8rem;
}
.tarjeta {
  background: #f5f0ff;
  border: 1.5px solid #ddd6fe;
  border-radius: 10px;
  padding: .8rem;
  text-align: center;
}
.tarjeta-palabra {
  font-weight: 700;
  font-size: .95rem;
  color: #5b21b6;
  margin-bottom: .3rem;
}
.tarjeta-def {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Sopa de letras */
.sopa-wrap {
  overflow-x: auto;
  margin: .8rem 0;
}
.sopa-grid {
  display: inline-grid;
  gap: 3px;
  font-family: monospace;
  font-size: .95rem;
}
.sopa-grid span {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text);
  background: #fafafa;
}
.palabras-buscar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}
.palabras-buscar span {
  background: #ede9fe;
  color: #5b21b6;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}

/* Actividades */
.actividad {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  border-radius: 0 8px 8px 0;
  padding: .8rem 1rem;
  margin: .6rem 0;
}
.actividad-num {
  font-weight: 700;
  color: #15803d;
  font-size: .82rem;
  margin-bottom: .2rem;
}
.actividad p { margin: 0; font-size: .9rem; line-height: 1.55; }

/* Ficha de lectura */
.ficha-texto {
  background: #fafafa;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  font-size: .9rem;
  line-height: 1.7;
  margin: .6rem 0 1rem;
  color: #2d2d2d;
}
.preguntas { margin-top: .8rem; }
.pregunta {
  margin: .6rem 0;
  font-size: .9rem;
  padding-left: 1.2rem;
  position: relative;
}
.pregunta::before {
  content: attr(data-n) '.';
  position: absolute;
  left: 0;
  font-weight: 700;
  color: var(--primary);
}
.linea-resp {
  border-bottom: 1.5px solid var(--border);
  height: 22px;
  margin: .3rem 0;
}

/* ── Utils ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.footnote { text-align: center; font-size: .75rem; color: var(--muted); margin-top: 1rem; }

/* ── Animación de entrada ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card, .header { animation: fadeUp .45s ease both; }
.card { animation-delay: .05s; }
