/* =====================================================
   CALMACORE - Hoja de estilos principal
   Mobile-first. Oscuro por defecto, claro opcional.
   ===================================================== */

:root {
  /* Tema oscuro (por defecto) */
  --bg: #0e1622;
  --bg-soft: #121c2b;
  --surface: #17222f;
  --surface-2: #1e2c3d;
  --line: #263a4f;
  --text: #eef3f9;
  --dim: #9cb0c4;
  --faint: #6b8099;

  --aqua: #74d7c6;
  --aqua-deep: #3aa696;
  --blue: #85abdb;
  --purple: #ab9fe0;
  --green: #8fd6a8;
  --amber: #e3c07f;
  --danger: #e2685f;

  --on-accent: #0c1620;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 8px 28px rgba(3, 10, 20, .35);
  --nav-h: 66px;
}

html[data-theme="light"] {
  --bg: #f2f5f9;
  --bg-soft: #eaeff5;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --line: #dbe4ee;
  --text: #1d2b3a;
  --dim: #55677c;
  --faint: #8296ab;

  --aqua: #2d9e8e;
  --aqua-deep: #23806f;
  --blue: #4a7cc0;
  --purple: #7b6cc0;
  --green: #3f9d67;
  --amber: #b98b2f;
  --danger: #cf4f47;

  --on-accent: #ffffff;
  --shadow: 0 6px 22px rgba(30, 50, 75, .10);
}


/* ---------- IconSet local ---------- */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 1.22em;
  height: 1.22em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.inline-icon { width: 1.05em; height: 1.05em; }
.brand-mark {
  width: 30px;
  height: 30px;
  padding: 5px;
  border-radius: 11px;
  color: var(--aqua);
  background: linear-gradient(145deg, color-mix(in srgb, var(--aqua) 22%, transparent), color-mix(in srgb, var(--purple) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--aqua) 26%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--aqua) 10%, transparent);
}
.auth-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  padding: 14px;
  border-radius: 22px;
  color: var(--aqua);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--aqua) 22%, transparent), color-mix(in srgb, var(--purple) 12%, transparent));
  border: 1.5px solid color-mix(in srgb, var(--aqua) 38%, transparent);
  box-shadow: 0 0 0 9px color-mix(in srgb, var(--aqua) 10%, transparent), var(--shadow);
}
.btn .icon { width: 1.12em; height: 1.12em; }
.calm-link { display: inline-flex; align-items: center; gap: 7px; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.55;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}

body.no-nav { padding-bottom: 24px; }

/* ---------- Contenedor ---------- */
.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 20px 32px;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.topbar .spacer { flex: 1; }

/* Acceso rapido a calma en todas las pantallas */
.calm-link {
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  color: var(--purple);
  border: 1.5px solid color-mix(in srgb, var(--purple) 45%, transparent);
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.calm-link:active { background: color-mix(in srgb, var(--purple) 16%, transparent); }

/* ---------- Tipografia ---------- */
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; }
p  { margin: 0 0 12px; }

.eyebrow {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--aqua);
  margin-bottom: 8px;
}
.muted { color: var(--dim); }
.small { font-size: .88rem; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card + .card { margin-top: 0; }

/* ---------- Botones ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform .08s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary { background: var(--aqua); color: var(--on-accent); }
.btn-blue    { background: color-mix(in srgb, var(--blue) 22%, var(--surface)); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.btn-purple  { background: color-mix(in srgb, var(--purple) 22%, var(--surface)); border-color: color-mix(in srgb, var(--purple) 42%, transparent); }
.btn-ghost   { background: transparent; border-color: var(--line); }
.btn-danger  { background: var(--danger); color: #fff; }  /* solo emergencia real */
.btn-sm      { min-height: 42px; padding: 8px 14px; font-size: .92rem; width: auto; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-stack { display: grid; gap: 12px; }

/* ---------- Formularios ---------- */
label.field {
  display: block;
  margin-bottom: 16px;
}
label.field > span {
  display: block;
  font-size: .86rem;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 7px;
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  min-height: 52px;
  outline: none;
}
textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--aqua) 20%, transparent);
}
::placeholder { color: var(--faint); }

/* ---------- Chips (selectores de estado / filtros) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 42px;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.on {
  border-color: var(--aqua);
  color: var(--text);
  background: color-mix(in srgb, var(--aqua) 15%, var(--surface));
}
.chip.on-purple { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 15%, var(--surface)); color: var(--text); }

/* ---------- Etiquetas pequenas ---------- */
.tag {
  display: inline-block;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
}
.tag-alta  { color: var(--amber);  border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.tag-media { color: var(--blue);   border-color: color-mix(in srgb, var(--blue) 45%, transparent); }
.tag-baja  { color: var(--green);  border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.tag-done  { color: var(--green); }

/* ---------- Dashboard ---------- */
.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: .92rem;
  font-weight: 600;
}
.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--aqua); }
.status-pill.energia .dot { background: var(--blue); }

.next-action {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--aqua) 14%, var(--surface)),
    color-mix(in srgb, var(--blue) 10%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--aqua) 30%, var(--line));
}

.prio-list { list-style: none; margin: 0; padding: 0; }
.prio-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
}
.prio-list li + li { border-top: 1px solid var(--line); }
.prio-num {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .82rem;
  font-weight: 700;
  color: var(--aqua);
  border: 1.5px solid color-mix(in srgb, var(--aqua) 50%, transparent);
  margin-top: 1px;
}

/* ---------- Listas de tareas / rutinas ---------- */
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.item-head { display: flex; align-items: flex-start; gap: 12px; }
.item-title { font-weight: 650; flex: 1; }
.item-title.done { text-decoration: line-through; color: var(--faint); }
.item-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }

.steps { list-style: none; margin: 12px 0 0; padding: 0; }
.steps li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-top: 1px dashed var(--line);
  font-size: .95rem;
}
.steps .check {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: .9rem;
}
.steps .check.on { background: var(--aqua); border-color: var(--aqua); color: var(--on-accent); }
.steps .txt { flex: 1; }
.steps .txt.done { text-decoration: line-through; color: var(--faint); }
.steps .mini {
  background: none; border: none; color: var(--faint);
  font-size: 1.05rem; cursor: pointer; padding: 4px 8px;
}

/* ---------- Resultado de IA (orden mental) ---------- */
.ai-block { margin-bottom: 14px; }
.ai-block:last-child { margin-bottom: 0; }
.ai-list { margin: 6px 0 0; padding-left: 20px; }
.ai-list li { margin-bottom: 5px; }

/* ---------- Mensajes / avisos ---------- */
.notice {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: .93rem;
  margin-bottom: 16px;
  border: 1px solid;
}
.notice-err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.notice-ok  { color: var(--green);  border-color: color-mix(in srgb, var(--green) 45%, transparent);  background: color-mix(in srgb, var(--green) 10%, transparent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 26px);
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.toast.show { opacity: 1; }

/* ---------- Navegacion inferior ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-in {
  max-width: 560px;
  margin: 0 auto;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--faint);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 23px; height: 23px; }
.nav-item.active { color: var(--aqua); }

/* ---------- Modal simple ---------- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(5, 10, 18, .6);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
.modal h2 { margin-bottom: 16px; }

/* ---------- Auth (login / registro) ---------- */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 24px;
}
.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo h1 { font-size: 1.7rem; }
.auth-alt { text-align: center; margin-top: 20px; color: var(--dim); font-size: .93rem; }
.auth-alt a { color: var(--aqua); font-weight: 600; text-decoration: none; }


.safety-note {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  line-height: 1.45;
}

/* ---------- Utilidades ---------- */
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

a { color: var(--blue); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--aqua) 60%, transparent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
