/* =========================================================
   Calendario familiar · Curso 2025–2026
   Tema: Neumorphic Design + Accesibilidad
   Archivo: styles.css (REEMPLAZO)
   ========================================================= */

/* ---------- Reset y utilidades ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tipografía fluida y legible */
:root {
  /* Paleta base (clara) */
  --bg: #e9eef6;            /* superficie general (ligeramente azulada, agradable) */
  --fg: #0f172a;            /* texto principal */
  --muted: #526070;         /* texto secundario */
  --brand: #0ea5e9;         /* acento */
  --brand-2: #0284c7;

  /* Superficies para Neumorfismo */
  --surface: #eef3fb;       /* paneles/cards */
  --surface-2: #e6ecf7;     /* header/controles */
  --border: #d7deea;        /* línea sutil para mejorar contraste */

  /* Sombras Neumórficas (luz arriba-izquierda) */
  --neu-dark: rgba(26, 45, 77, 0.18);
  --neu-light: rgba(255, 255, 255, 0.85);

  /* Elevaciones (puedes ajustar intensidades si quieres) */
  --depth-1: 6px 6px 14px var(--neu-dark), -6px -6px 14px var(--neu-light);
  --depth-2: 12px 12px 24px var(--neu-dark), -12px -12px 24px var(--neu-light);
  --inset-1: inset 6px 6px 12px var(--neu-dark), inset -6px -6px 12px var(--neu-light);

  /* Accesibilidad */
  --focus: #22c55e;
  --focus-ring: 3px;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 22px;

  /* Eventos por tipo (fondo sutil + borde para contraste) */
  --ev-drop: #ecfdf5;
  --ev-pick: #fffbeb;
  --ev-kitchen: #fef2f2;
  --ev-laundry: #eff6ff;
  --ev-bath: #fdf2f8;
  --ev-floors: #f0fdf4;
  --ev-terrace: #faf5ff;
  --ev-trash: #f1f5f9;
  --ev-reset: #fff7ed;
  --ev-holiday: #eef2ff;
  --ev-schooloff: #f1f5f9;
  --ev-extra: #e5f3ff;

  /* Botones */
  --btn-fg: #0f172a;
  --btn-bg: #eef3fb;
  --btn-border: #cbd5e1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220;
    --fg: #e5e7eb;
    --muted: #a7b0bf;
    --brand: #22c55e;
    --brand-2: #16a34a;

    --surface: #0f172a;
    --surface-2: #0c111c;
    --border: #1b2333;

    --neu-dark: rgba(0,0,0,0.45);
    --neu-light: rgba(255,255,255,0.08);

    --ev-drop: #143d2d;
    --ev-pick: #3d3514;
    --ev-kitchen: #3b1515;
    --ev-laundry: #121f35;
    --ev-bath: #301326;
    --ev-floors: #143216;
    --ev-terrace: #27183e;
    --ev-trash: #12141a;
    --ev-reset: #2e1d0e;
    --ev-holiday: #141c3b;
    --ev-schooloff: #191f29;
    --ev-extra: #13243a;

    --btn-fg: #e5e7eb;
    --btn-bg: #0f172a;
    --btn-border: #22304a;
  }
}

/* Modo alto contraste opcional (lo activaremos añadiendo .contrast al html en el siguiente paso) */
html.contrast {
  --surface: #ffffff;
  --surface-2: #ffffff;
  --border: #9aa4b2;
  --neu-light: rgba(255,255,255,1);
  --neu-dark: rgba(0,0,0,0.28);
}

/* Escala fluida */
html { font-size: 16px; }
@media (min-width: 480px) { html { font-size: 17px; } }
@media (min-width: 768px) { html { font-size: 18px; } }

/* Utilidades de accesibilidad */
:focus-visible {
  outline: var(--focus-ring) solid var(--focus);
  outline-offset: 2px;
  border-radius: 10px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Contenedor base */
.container { width: min(1150px, 94vw); margin: 0 auto; }

/* ---------- Header con Neumorfismo ---------- */
.site-header {
  background: var(--surface-2);
  color: var(--fg);
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--depth-1);
}
.header-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.site-header h1 { margin: 0; font-weight: 800; letter-spacing: 0.2px; }
.sub { margin: 6px 0 0; color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Botones Neumórficos ---------- */
.btn {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--depth-1);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn:active { box-shadow: var(--inset-1); transform: translateY(0); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.btn-outline {
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--brand);
  box-shadow: var(--depth-1);
}
.btn-sm { padding: 8px 12px; font-weight: 700; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Chips (Fer / Marta / Ambos) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--btn-border);
  background: var(--surface); color: var(--muted); box-shadow: var(--depth-1); cursor: pointer; font-weight: 700;
}
.chip.active { color: var(--fg); border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,233,.15), var(--depth-1); }

/* ---------- Panel Neumórfico ---------- */
.panel {
  background: var(--surface);
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--depth-1);
}
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px; padding-left: 0; margin: 0; }
.legend li { list-style: none; display: flex; align-items: center; gap: 8px; color: var(--muted); }

.badge { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--border); box-shadow: inset 2px 2px 4px var(--neu-dark), inset -2px -2px 4px var(--neu-light); }
.badge-drop{ background: var(--ev-drop); }
.badge-pick{ background: var(--ev-pick); }
.badge-kitchen{ background: var(--ev-kitchen); }
.badge-laundry{ background: var(--ev-laundry); }
.badge-bath{ background: var(--ev-bath); }
.badge-floors{ background: var(--ev-floors); }
.badge-terrace{ background: var(--ev-terrace); }
.badge-trash{ background: var(--ev-trash); }
.badge-reset{ background: var(--ev-reset); }
.badge-holiday{ background: var(--ev-holiday); }
.badge-schooloff{ background: var(--ev-schooloff); }
.badge-extra{ background: var(--ev-extra); }

.controls { display: grid; gap: 12px; margin-top: 12px; }
.controls .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

.control label { font-weight: 800; display: block; margin-bottom: 6px; color: var(--fg); }
.control small { color: var(--muted); }
.control input[type="date"], .control input[type="time"], .control input[type="text"], .control select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 100%;
  background: var(--surface); color: var(--fg);
  box-shadow: var(--inset-1);
}
.control input::placeholder { color: #8aa; }
.control .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.control .row.add input[type="date"] { max-width: 170px; }
.control .row.add input[type="time"] { max-width: 130px; }
.control .row.add input[type="text"] { flex: 1 1 300px; }

.toggles summary { cursor: pointer; padding: 8px 0; font-weight: 800; }
.toggles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; color: var(--muted); }
.toggles-grid label { display: flex; gap: 8px; align-items: center; }

/* ---------- Calendario mensual ---------- */
.calendar-section { margin: 16px 0 40px; }
.calendar-header { display: grid; gap: 8px; }
.month { margin: 0; font-weight: 800; letter-spacing: 0.2px; }
.weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0 2px;
}
.weekdays div { text-align: center; text-transform: uppercase; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.day {
  background: var(--surface);
  min-height: 140px;
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  box-shadow: var(--depth-1);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.day:hover { transform: translateY(-2px); box-shadow: var(--depth-2); }
.day .date { font-weight: 900; margin-bottom: 8px; }
.day .events { display: flex; flex-direction: column; gap: 6px; }

/* Eventos: tarjetas compactas con relieve */
.event {
  font-size: 0.92rem;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--depth-1);
  /* Indicador de color a la izquierda */
  position: relative;
  overflow: hidden;
}
.event::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  opacity: .9;
}
.event.drop{ background: var(--ev-drop); }
.event.drop::before { background: #34d399; }
.event.pick{ background: var(--ev-pick); }
.event.pick::before { background: #fbbf24; }
.event.kitchen{ background: var(--ev-kitchen); }
.event.kitchen::before { background: #f87171; }
.event.laundry{ background: var(--ev-laundry); }
.event.laundry::before { background: #93c5fd; }
.event.bath{ background: var(--ev-bath); }
.event.bath::before { background: #f472b6; }
.event.floors{ background: var(--ev-floors); }
.event.floors::before { background: #86efac; }
.event.terrace{ background: var(--ev-terrace); }
.event.terrace::before { background: #d8b4fe; }
.event.trash{ background: var(--ev-trash); }
.event.trash::before { background: #94a3b8; }
.event.reset{ background: var(--ev-reset); }
.event.reset::before { background: #fbbf24; }
.event.holiday{ background: var(--ev-holiday); }
.event.holiday::before { background: #818cf8; }
.event.schooloff{ background: var(--ev-schooloff); }
.event.schooloff::before { background: #94a3b8; }
.event.extra{ background: var(--ev-extra); }
.event.extra::before { background: #60a5fa; }

.day.muted { background: transparent; border: none; box-shadow: none; }

/* ---------- Modal de día (para el siguiente paso JS/HTML) ---------- */
.modal {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 13, 25, 0.35);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.modal.open { display: flex; animation: zoomIn 180ms ease-out; }
@keyframes zoomIn {
  from { transform: scale(.98); opacity: 0; } to { transform: scale(1); opacity: 1; }
}
.modal-card {
  width: min(1100px, 92vw);
  height: min(80vh, 820px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--depth-2);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--depth-1);
}
.modal-title { font-weight: 900; }
.modal-body { display: grid; grid-template-columns: 1fr 300px; gap: 12px; padding: 12px; }
@media (max-width: 900px){ .modal-body { grid-template-columns: 1fr; height: 100%; } }

/* Time-grid del día (7:00–23:00, marcas cada 30') */
.day-grid {
  position: relative;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--inset-1);
  border: 1px solid var(--border);
  padding: 6px;
}
.time-slot {
  height: 36px; /* 30’ ≈ 36px -> cómodo para tocar */
  border-bottom: 1px dashed var(--border);
  position: relative; padding-left: 56px;
  color: var(--muted);
}
.time-slot .label {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-weight: 700; font-size: .9rem;
}
.block {
  position: absolute;
  left: 56px; right: 8px;
  min-height: 28px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--depth-1);
  padding: 8px 10px;
  font-weight: 700;
  cursor: grab;
  user-select: none;
}
.block:active { cursor: grabbing; box-shadow: var(--inset-1); }
.block .resize {
  position: absolute; left: 6px; right: 6px; height: 6px;
  border-radius: 6px; background: rgba(0,0,0,.08);
}
.block .resize.top { top: -3px; cursor: ns-resize; }
.block .resize.bottom { bottom: -3px; cursor: ns-resize; }

/* Columna lateral del modal (resumen + acciones) */
.sidebar {
  display: grid; gap: 10px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--depth-1);
  padding: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }

/* ---------- Sheet “Añadir evento” ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: -100%; z-index: 60;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -20px 40px rgba(8, 13, 25, .25), var(--depth-2);
  transition: bottom 220ms ease;
  padding: 14px 16px;
  max-height: 82vh; overflow: auto;
}
.sheet.open { bottom: 0; }
.sheet .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 10px; }
.sheet .field { display: grid; gap: 6px; }
.sheet .field input, .sheet .field select, .sheet .field textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); box-shadow: var(--inset-1);
}
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ---------- Footer ---------- */
.site-footer { color: var(--muted); font-size: .95rem; padding: 10px 0 24px; }

/* ---------- Impresión ---------- */
@media print {
  body { background: #fff; }
  .site-header, .panel .controls, .actions, .modal, .sheet { display: none !important; }
  .container { width: 100%; margin: 0; padding: 0 10mm; }
  .calendar-grid .day { min-height: 36mm; box-shadow: none; }
  @page { size: A4 portrait; margin: 8mm; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Estados de error/aviso ---------- */
.alert {
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); box-shadow: var(--depth-1); background: var(--surface);
}
.alert.success { border-color: #22c55e; }
.alert.warn { border-color: #f59e0b; }
.alert.error { border-color: #ef4444; }