/* styles.css — mobile-first, responsive. Sin dependencias. */

:root {
  --primary: #8e44ad;
  --primary-dark: #6c3483;
  --bg: #faf7fb;
  --card-bg: #ffffff;
  --text: #2b2b2b;
  --muted: #666;
  --border: #e2d9e8;

  /* Colores por tipo de día en el calendario (contraste accesible) */
  --day-recorded: #c0392b;   /* menstruación registrada */
  --day-predicted: #e67e22;  /* próxima menstruación estimada */
  --day-ovulation: #2980b9;  /* ovulación estimada */
  --day-fertile: #27ae60;    /* ventana fértil estimada */

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  background: var(--primary);
  color: #fff;
  padding: 1rem;
  text-align: center;
}
.app-header h1 { margin: 0; font-size: 1.4rem; }
.app-header .subtitle { margin: 0.25rem 0 0; font-size: 0.85rem; opacity: 0.9; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

section { margin-bottom: 2rem; }
h2 { font-size: 1.15rem; }

/* Botones */
.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
}
.btn:hover { background: #f2eaf6; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--day-recorded); border-color: #e6b0aa; }

/* Tarjetas de resumen */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.card .card-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.card .card-value { font-size: 1.25rem; font-weight: 700; margin-top: 0.15rem; }
.card .card-note { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

/* Formulario */
.cycle-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.cycle-form label { flex-basis: 100%; font-size: 0.9rem; }
.cycle-form input[type="date"] {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.form-error { flex-basis: 100%; color: var(--day-recorded); font-size: 0.85rem; margin: 0.25rem 0 0; min-height: 1em; }

/* Lista de historial */
.cycle-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.cycle-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  background: #fff;
}
.cycle-item .cycle-date { flex: 1; font-variant-numeric: tabular-nums; }
.cycle-item input[type="date"] { padding: 0.35rem; border: 1px solid var(--border); border-radius: 6px; }

/* Calendario */
.calendar-header { display: flex; align-items: center; justify-content: space-between; }
.calendar-nav { display: flex; align-items: center; gap: 0.5rem; }
#cal-month-label { min-width: 9rem; text-align: center; font-weight: 600; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-top: 0.5rem;
}
.cal-weekday {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.25rem 0;
}
.cal-day {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fff;
  position: relative;
}
.cal-day.empty { border: none; background: transparent; }
.cal-day .cal-icon { font-size: 0.8rem; line-height: 1; }
.cal-day.today { outline: 2px solid var(--primary); outline-offset: -2px; }

.cal-day.recorded { background: var(--day-recorded); color: #fff; }
.cal-day.predicted { background: var(--day-predicted); color: #fff; }
.cal-day.ovulation { background: var(--day-ovulation); color: #fff; }
.cal-day.fertile { background: var(--day-fertile); color: #fff; }

/* Leyenda */
.legend { list-style: none; padding: 0; margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.legend li { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; }
.legend .swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.legend .swatch.recorded { background: var(--day-recorded); }
.legend .swatch.predicted { background: var(--day-predicted); }
.legend .swatch.ovulation { background: var(--day-ovulation); }
.legend .swatch.fertile { background: var(--day-fertile); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal h2 { margin-top: 0; }
.modal p { font-size: 0.92rem; }

/* Banner permanente */
.app-footer {
  background: #f3e9f7;
  border-top: 1px solid var(--border);
  padding: 0.9rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.app-footer p { max-width: 720px; margin: 0 auto; }

/* Responsive: tarjetas en grid a partir de pantallas medianas */
@media (min-width: 560px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cal-day { font-size: 0.95rem; }
}
@media (min-width: 800px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
