/* =============================================================
   FAMILIAS NUEVAS · assets/css/app.css
   Diseño calmado, limpio y familiar. Mobile-first. Claridad > decoración.
   ============================================================= */

:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #2b2b31;
  --ink-soft: #6f6f7a;
  --muted: #9a9aa4;
  --line: #e8e6e0;
  --line-strong: #dcd9d1;
  --accent: #5f86b3;      /* azul calmado */
  --accent-soft: #eaf1f8;
  --green: #5aa17a;
  --green-soft: #e7f3ec;
  --amber: #d99a4e;
  --amber-soft: #fbf1e2;
  --red: #cf6a5a;
  --red-soft: #fbeae7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30,30,40,.05), 0 6px 20px rgba(30,30,40,.06);
  --shadow-soft: 0 1px 3px rgba(30,30,40,.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 64px;
  --side-w: 240px;
  --maxw: 1100px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Botones ---------- */
.fn-btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 11px 18px; font-weight: 600; font-size: .95rem;
  box-shadow: var(--shadow-soft); transition: transform .1s ease, background .1s ease; min-height: 44px;
}
.fn-btn:hover { background: var(--surface-2); }
.fn-btn:active { transform: translateY(1px); }
.fn-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.fn-btn.primary:hover { filter: brightness(1.04); background: var(--accent); }
.fn-btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); }
.fn-btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.fn-btn.block { width: 100%; }
.fn-btn.small { padding: 7px 12px; min-height: 36px; font-size: .85rem; }
.fn-icon-btn { border: none; background: transparent; font-size: 1.1rem; padding: 8px; border-radius: 10px; color: var(--ink-soft); }
.fn-icon-btn:hover { background: var(--surface-2); }
.fn-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fn-actions.end { justify-content: flex-end; }

/* ---------- Campos ---------- */
.fn-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.fn-field > span { font-weight: 600; font-size: .85rem; color: var(--ink-soft); }
.fn-input, .fn-select, .fn-textarea {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 1rem; font-family: inherit; background: var(--surface); color: var(--ink); width: 100%;
}
.fn-textarea { resize: vertical; min-height: 64px; }

/* ---------- Layout general ---------- */
.fn-shell { min-height: 100vh; }
.fn-main { max-width: var(--maxw); margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px); }

/* App bar */
.fn-appbar {
  position: sticky; top: 0; z-index: 20; background: rgba(244,243,239,.92);
  backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--line);
}
.fn-appbar-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.fn-brand { font-weight: 800; letter-spacing: -0.02em; font-size: 1.05rem; }
.fn-brand small { display: block; font-weight: 500; color: var(--ink-soft); font-size: .72rem; letter-spacing: 0; }
.fn-appbar-spacer { flex: 1; }
.fn-bell { position: relative; }
.fn-bell .dot { position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff; border-radius: 999px; font-size: .62rem; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.fn-profile-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 4px; font-weight: 600; font-size: .85rem; }
.fn-avatar { width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; color: #fff; }

/* Bottom nav (móvil) */
.fn-bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h); z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.fn-navitem { flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; }
.fn-navitem .ic { font-size: 1.25rem; }
.fn-navitem.active { color: var(--accent); }

/* Sidebar (escritorio) */
.fn-sidebar { display: none; }

/* ---------- Tarjetas y secciones ---------- */
.fn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 16px; margin-bottom: 14px; }
.fn-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 18px 2px 8px; }
.fn-greet { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.fn-date { color: var(--ink-soft); margin-bottom: 4px; text-transform: capitalize; }

/* Bloques de la pantalla Hoy */
.fn-now-card { border-left: 4px solid var(--accent); }
.fn-block-label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin-bottom: 8px; }

/* Item de agenda / tarea */
.fn-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.fn-item:first-child { border-top: none; }
.fn-item .fn-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); min-width: 46px; font-size: .9rem; }
.fn-item .fn-item-main { flex: 1; min-width: 0; }
.fn-item .fn-item-title { font-weight: 600; }
.fn-item .fn-item-sub { color: var(--ink-soft); font-size: .82rem; }
.fn-item.done .fn-item-title { text-decoration: line-through; color: var(--muted); }
.fn-item.skipped .fn-item-title { color: var(--muted); font-style: italic; }
.fn-dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.fn-tag { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }

/* Botón de completar */
.fn-check { width: 30px; height: 30px; border-radius: 999px; border: 2px solid var(--line-strong); background: var(--surface); flex: none; display: flex; align-items: center; justify-content: center; color: transparent; font-size: .9rem; }
.fn-check.on { background: var(--green); border-color: var(--green); color: #fff; }

/* Chips de miembro */
.fn-member-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .82rem; font-weight: 600; }
.fn-member-dot { width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; color: #fff; }

/* Selector de personas (Mi día) */
.fn-people { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.fn-person { border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; font-weight: 600; font-size: .82rem; }
.fn-person.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.fn-person .fn-avatar { width: 40px; height: 40px; font-size: 1.3rem; }

/* Estados vacíos */
.fn-empty { text-align: center; color: var(--ink-soft); padding: 26px 10px; }
.fn-empty .big { font-size: 1.8rem; display: block; margin-bottom: 6px; }

/* ---------- Calendario ---------- */
.fn-cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.fn-cal-title { font-size: 1.2rem; font-weight: 800; text-transform: capitalize; flex: 1; text-align: center; }
.fn-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.fn-seg button { border: none; background: none; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .82rem; color: var(--ink-soft); }
.fn-seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }
.fn-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.fn-filter { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: .8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.fn-filter.off { opacity: .45; }

.fn-monthgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.fn-dow { text-align: center; font-size: .7rem; font-weight: 800; color: var(--muted); padding: 4px 0; }
.fn-daycell { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-height: 74px; padding: 4px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.fn-daycell.other { background: var(--surface-2); opacity: .6; }
.fn-daycell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.fn-daynum { font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.fn-daycell .ev { font-size: .64rem; line-height: 1.25; padding: 1px 4px; border-radius: 5px; background: var(--accent-soft); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-daycell .more { font-size: .62rem; color: var(--muted); font-weight: 700; }

/* Semana (lista) */
.fn-weekday { margin-bottom: 8px; }
.fn-weekday h3 { font-size: .95rem; text-transform: capitalize; margin-bottom: 4px; }
.fn-weekday.is-today h3 { color: var(--accent); }

/* Planificador semanal (tabla) */
.fn-planner { overflow-x: auto; }
.fn-planner table { border-collapse: collapse; width: 100%; min-width: 460px; }
.fn-planner th, .fn-planner td { border: 1px solid var(--line); padding: 6px; text-align: center; font-size: .82rem; }
.fn-planner th { background: var(--surface-2); }

/* Barras (pantallas / equilibrio) */
.fn-bar { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; }
.fn-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.fn-bar.warn > span { background: var(--amber); }
.fn-bar.over > span { background: var(--red); }

/* Comentarios */
.fn-comment { padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.fn-comment .who { font-weight: 700; }
.fn-comment .when { color: var(--muted); font-size: .75rem; }

/* Sugerencias / ideas */
.fn-idea { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface); }
.fn-idea .badge { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.accepted { background: var(--green-soft); color: var(--green); }
.badge.discarded { background: var(--surface-2); color: var(--muted); }
.badge.done { background: var(--accent-soft); color: var(--accent); }

/* Compra */
.fn-shop-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.fn-shop-item.done span.name { text-decoration: line-through; color: var(--muted); }

/* FAB (crear rápido) */
.fn-fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 14px); z-index: 25; width: 56px; height: 56px; border-radius: 999px; border: none; background: var(--accent); color: #fff; font-size: 1.8rem; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }

/* Login / setup / who */
.fn-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.fn-gate-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 28px; max-width: 380px; width: 100%; text-align: center; }
.fn-gate-card h1 { font-size: 1.5rem; }
.fn-gate-card .sub { color: var(--ink-soft); margin: 4px 0 20px; }
.fn-who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fn-who { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 700; }
.fn-who .fn-avatar { width: 52px; height: 52px; font-size: 1.7rem; }

/* Modal / toast */
.fn-modal-overlay { position: fixed; inset: 0; background: rgba(30,30,45,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0; }
.fn-modal { background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); }
.fn-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; position: sticky; top: 0; background: var(--surface); }
.fn-modal-title { font-size: 1.1rem; }
.fn-modal-body { padding: 4px 16px 20px; }
.fn-toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%) translateY(16px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem; opacity: 0; transition: all .3s ease; z-index: 60; box-shadow: var(--shadow); }
.fn-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.fn-toast.error { background: var(--red); }
.fn-toast.ok { background: var(--green); }

.fn-pending-note { background: var(--amber-soft); color: var(--amber); border-radius: 10px; padding: 8px 12px; font-size: .85rem; font-weight: 600; }
.fn-muted { color: var(--ink-soft); }
.fn-linkrow { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }

/* ---------- Escritorio ---------- */
@media (min-width: 860px) {
  body { font-size: 16px; }
  .fn-bottomnav { display: none; }
  .fn-fab { bottom: 24px; }
  .fn-shell { display: grid; grid-template-columns: var(--side-w) 1fr; }
  .fn-sidebar {
    display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100vh; background: var(--surface);
  }
  .fn-sidebar .fn-brand { padding: 8px 12px 16px; }
  .fn-side-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; border: none; background: none; font-weight: 600; color: var(--ink-soft); text-align: left; width: 100%; font-size: .95rem; }
  .fn-side-item .ic { font-size: 1.15rem; width: 22px; text-align: center; }
  .fn-side-item.active { background: var(--accent-soft); color: var(--accent); }
  .fn-side-item:hover { background: var(--surface-2); }
  .fn-appbar { position: sticky; }
  .fn-main { padding-bottom: 40px; }
  .fn-modal-overlay { align-items: center; }
  .fn-modal { border-radius: 20px; }
  .fn-who-grid { grid-template-columns: repeat(4, 1fr); }
  .fn-daycell { min-height: 96px; }
  .fn-daycell .ev { font-size: .7rem; }
}

@media (min-width: 560px) and (max-width: 859px) {
  .fn-who-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Accesibilidad: menos animación */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
