/* =========================================================================
   ZOE · Sistema de diseño
   Paleta "cuaderno de Zoe": fondo nube-lila, tinta ciruela, y un color por
   módulo (bitácora, salud, calendario, escuela, acuerdos) que actúa como
   separador de carpeta -- la firma visual de toda la app.
   ========================================================================= */

:root {
  --bg: #FAF8FC;
  --surface: #FFFFFF;
  --surface-tint: #F4F0FB;
  --ink: #2A2340;
  --ink-soft: #6B637E;
  --ink-faint: #A79FBE;
  --line: #ECE7F5;

  --coral: #FF6B6B;      /* Bitácora */
  --coral-soft: #FFE3E1;
  --mint: #22B296;       /* Salud */
  --mint-soft: #DBF5EF;
  --violet: #8B7FE8;     /* Calendario */
  --violet-soft: #E9E6FB;
  --mustard: #F5A623;    /* Escuela */
  --mustard-soft: #FDECD1;
  --rose: #F2609A;       /* Acuerdos */
  --rose-soft: #FCE1EC;
  --home: #7C6FE0;       /* Inicio */

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-card: 0 2px 8px rgba(42, 35, 64, 0.06), 0 10px 24px -14px rgba(42, 35, 64, 0.16);
  --shadow-float: 0 14px 30px -10px rgba(139, 127, 232, 0.5);
  --shadow-nav: 0 -6px 24px rgba(42, 35, 64, 0.08);

  --font-display: 'Cabinet Grotesk', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
}

/* Fondo decorativo suave detrás de todo, sensación de páginas de cuaderno */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 40% at 85% -5%, rgba(255, 107, 107, 0.12), transparent 60%),
    radial-gradient(50% 35% at 10% 0%, rgba(139, 127, 232, 0.14), transparent 60%);
}

/* ---------- App shell ---------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(42, 35, 64, 0.06);
}

@media (min-width: 540px) {
  body { background: var(--surface-tint); }
  .app-shell { margin-top: 24px; margin-bottom: 24px; border-radius: 32px; overflow: hidden; min-height: calc(100vh - 48px); }
}

.app-header {
  padding: 22px 22px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.app-header .greeting-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 4px;
}

.app-header h1 {
  font-size: 1.5rem;
  color: var(--ink);
}

.app-header .header-sub {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-top: 2px;
}

.avatar-badge {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--coral), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 8px 18px -8px rgba(139, 127, 232, 0.6);
}

/* ---------- Content area ---------- */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 110px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.view {
  animation: view-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 4px 12px;
}
.section-heading h2 {
  font-size: 1.05rem;
  color: var(--ink);
}
.section-heading a, .section-heading .link-btn {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Ribbon card (firma visual) ----------
   Cada tarjeta lleva una "pestaña de separador" doblada en la esquina,
   coloreada según el módulo: bitácora, salud, calendario, escuela, acuerdos. */
.ribbon-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px 18px 16px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
  border-left: 4px solid var(--tab-color, var(--violet));
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.ribbon-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 26px;
  background: var(--tab-color, var(--violet));
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  opacity: 0.9;
}
.ribbon-card:active { transform: scale(0.99); }

.ribbon-card .card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.ribbon-card h3 {
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.ribbon-card .card-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.ribbon-card p.card-body {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.45;
}
.ribbon-card .card-meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* tint variants */
.tab-coral   { --tab-color: var(--coral); }
.tab-mint    { --tab-color: var(--mint); }
.tab-violet  { --tab-color: var(--violet); }
.tab-mustard { --tab-color: var(--mustard); }
.tab-rose    { --tab-color: var(--rose); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-body);
}
.pill-coral   { background: var(--coral-soft); color: #C1453F; }
.pill-mint    { background: var(--mint-soft); color: #17805F; }
.pill-violet  { background: var(--violet-soft); color: #5B4FCB; }
.pill-mustard { background: var(--mustard-soft); color: #A8690A; }
.pill-rose    { background: var(--rose-soft); color: #C13D71; }
.pill-done    { background: var(--mint-soft); color: #17805F; }
.pill-pending { background: var(--mustard-soft); color: #A8690A; }

/* ---------- Stat pills (dashboard) ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-card .stat-num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
  display: block;
}
.stat-card .stat-label {
  font-size: 0.68rem;
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Module shortcut grid (home) ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.module-tile {
  border-radius: var(--radius-md);
  padding: 18px 16px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 30px;
  min-height: 96px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease;
}
.module-tile:active { transform: scale(0.97); }
.module-tile .tile-icon { font-size: 1.4rem; }
.module-tile .tile-label { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.module-tile .tile-sub { font-size: 0.72rem; opacity: 0.85; margin-top: 2px; }
.module-tile::after {
  content: '';
  position: absolute;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  right: -30px; bottom: -30px;
}
.tile-coral { background: linear-gradient(135deg, #FF8080, var(--coral)); }
.tile-mint { background: linear-gradient(135deg, #35D1B0, var(--mint)); }
.tile-violet { background: linear-gradient(135deg, #A79BFF, var(--violet)); }
.tile-mustard { background: linear-gradient(135deg, #FFC761, var(--mustard)); }
.tile-rose { background: linear-gradient(135deg, #FF87B4, var(--rose)); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty-state .empty-emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.empty-state h4 { color: var(--ink); font-size: 0.95rem; margin-bottom: 4px; }
.empty-state p { font-size: 0.85rem; }

/* ---------- Bottom nav (pestañas de carpeta) ---------- */
.bottom-nav {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface);
  box-shadow: var(--shadow-nav);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 12px;
  color: var(--ink-faint);
  transition: color 0.15s ease, transform 0.15s ease;
}
.nav-btn .nav-icon { font-size: 1.15rem; line-height: 1; }
.nav-btn .nav-label { font-size: 0.6rem; font-weight: 700; }
.nav-btn.active { color: var(--nav-color, var(--violet)); transform: translateY(-2px); }
.nav-btn.active .nav-icon {
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.12));
}
.nav-home    { --nav-color: var(--home); }
.nav-bitacora{ --nav-color: var(--coral); }
.nav-salud   { --nav-color: var(--mint); }
.nav-calendario { --nav-color: var(--violet); }
.nav-escuela { --nav-color: var(--mustard); }
.nav-acuerdos{ --nav-color: var(--rose); }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 50%;
  transform: translateX(calc(240px - 78px));
  bottom: 88px;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: var(--fab-color, var(--violet));
  color: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-float);
  z-index: 25;
  transition: transform 0.18s ease, background 0.2s ease;
}
.fab:active { transform: translateX(calc(240px - 78px)) scale(0.92); }
@media (max-width: 480px) {
  .fab { right: 18px; transform: none; }
  .fab:active { transform: scale(0.92); }
}

/* ---------- Bottom sheet (formularios) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 35, 64, 0.42);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  transform: translate(-50%, 100%);
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  z-index: 41;
  padding: 14px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -20px 50px rgba(42,35,64,0.25);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle {
  width: 40px; height: 5px;
  background: var(--line);
  border-radius: 999px;
  margin: 0 auto 14px;
}
.sheet h3 {
  font-size: 1.15rem;
  margin-bottom: 14px;
  color: var(--ink);
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.field textarea { min-height: 88px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.mood-picker { display: flex; gap: 8px; justify-content: space-between; }
.mood-opt {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  border-radius: 14px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  font-size: 1.3rem;
}
.mood-opt.selected { border-color: var(--coral); background: var(--coral-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.92rem;
  width: 100%;
}
.btn-primary { background: var(--btn-color, var(--violet)); color: #fff; }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost { background: var(--bg); color: var(--ink-soft); }
.btn-danger-text { color: #C1453F; font-weight: 700; font-size: 0.85rem; padding: 8px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Calendar grid ---------- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 4px 10px;
}
.cal-header h2 { font-size: 1.1rem; }
.cal-nav-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}
.cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ink-faint);
  padding-bottom: 4px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--surface);
  position: relative;
  font-family: var(--font-mono);
}
.cal-day.faded { color: var(--ink-faint); background: transparent; }
.cal-day.today { border: 2px solid var(--violet); font-weight: 700; }
.cal-day.selected { background: var(--violet); color: #fff; }
.cal-day .dot-row { display: flex; gap: 2px; margin-top: 2px; }
.cal-day .dot { width: 4px; height: 4px; border-radius: 50%; }

/* ---------- Login gate ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 18px;
  background:
    radial-gradient(60% 45% at 20% 0%, rgba(255, 107, 107, 0.18), transparent 60%),
    radial-gradient(55% 45% at 90% 10%, rgba(139, 127, 232, 0.2), transparent 60%),
    var(--bg);
}
.login-screen .logo-mark {
  width: 76px; height: 76px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--coral), var(--violet));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  box-shadow: var(--shadow-float);
}
.login-screen h1 { font-size: 1.6rem; }
.login-screen p.tag { color: var(--ink-soft); max-width: 260px; }
.pin-dots { display: flex; gap: 12px; margin: 10px 0; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--violet);
  transition: background 0.15s ease;
}
.pin-dot.filled { background: var(--violet); }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 12px;
}
.pin-key {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}
.pin-key:active { transform: scale(0.94); }
.pin-key.wide { font-size: 1rem; color: var(--ink-soft); }
.login-error {
  color: #C1453F;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 18px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.22,1,0.36,1);
  box-shadow: 0 12px 24px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Loader ---------- */
.loader-wrap { display: flex; justify-content: center; padding: 40px 0; }
.loader-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--violet);
  margin: 0 4px;
  animation: bounce 1s infinite ease-in-out;
  display: inline-block;
}
.loader-dot:nth-child(2) { animation-delay: 0.15s; background: var(--coral); }
.loader-dot:nth-child(3) { animation-delay: 0.3s; background: var(--mint); }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-8px); opacity: 1; } }

/* ---------- Segmented filter ---------- */
.segmented {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.seg-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow-card);
}
.seg-btn.active { background: var(--seg-color, var(--violet)); color: #fff; box-shadow: none; }

/* Utility */
.hidden { display: none !important; }
.mt-1 { margin-top: 6px; }
.text-center { text-align: center; }
