/*
 * BakerCalc design system.
 * Palette (brand): bg #FFF7F8 · primary #F7A8B8 · secondary #FBC4CF
 *                  light #FDE2E7 · pinkish white #FFF4F6
 * Deep rose tones are derived from the primary for text/buttons contrast.
 * Fonts: Fraunces (display) + Nunito (body), loaded in base.html.
 */

:root {
  --bg: #FFF7F8;
  --pink: #F7A8B8;
  --pink-2: #FBC4CF;
  --pink-light: #FDE2E7;
  --pink-white: #FFF4F6;

  --rose: #D9587B;        /* actionable: buttons, links */
  --rose-dark: #B83D5E;   /* hover / active */
  --ink: #46242E;         /* main text, warm dark plum */
  --ink-soft: #8A6470;    /* secondary text */
  --ink-faint: #B99AA3;   /* placeholders, hints */

  --ok: #4C9A6E;
  --ok-soft: #E3F2E9;
  --warn: #B7791F;
  --warn-soft: #FBEEDC;
  --bad: #C0392B;
  --bad-soft: #FBE3E0;

  --card: #FFFFFF;
  --border: #F5D4DC;
  --shadow: 0 4px 18px rgba(217, 88, 123, 0.10);
  --shadow-sm: 0 2px 8px rgba(217, 88, 123, 0.08);

  --radius: 16px;
  --radius-sm: 10px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 0.4em;
  text-wrap: balance;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
a { color: var(--rose); text-decoration: none; }
a:hover { color: var(--rose-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
}

.muted { color: var(--ink-soft); }
.hint { color: var(--ink-faint); font-size: 0.85rem; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.money-big { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.6rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 28px 0 22px;
}
.page-header .subtitle { color: var(--ink-soft); margin: 2px 0 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

@media (max-width: 860px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 244, 246, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 4px rgba(217, 88, 123, 0.25);
}
.brand:hover { color: var(--rose-dark); }
.nav-links { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.95rem;
}
.nav-links a:hover { background: var(--pink-light); color: var(--ink); }
.nav-links a.active { background: var(--pink); color: #fff; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-user .username { font-weight: 700; color: var(--ink-soft); font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 20px;
  border-radius: 999px;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--rose); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--rose-dark); color: #fff; }
.btn-soft { background: var(--pink-light); color: var(--rose-dark); }
.btn-soft:hover { background: var(--pink-2); color: var(--rose-dark); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--pink-light); color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: #F5CFCA; color: var(--bad); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform 0.12s ease, box-shadow 0.12s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-soft { background: var(--pink-white); border-color: var(--pink-light); box-shadow: none; }
.card h3 { margin-bottom: 6px; }

/* Stat card (dashboard) */
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat .stat-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.stat .stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat .stat-foot { font-size: 0.85rem; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Forms (all formatting lives in templates) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 800; font-size: 0.92rem; }
.field .help { font-size: 0.83rem; color: var(--ink-faint); }

input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="month"], select, textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-light);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Segmented control (radio pills, e.g. "¿cómo lo mides?") */
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.12s ease;
}
.segmented input:checked + label {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}
.segmented input:focus-visible + label { outline: 2px solid var(--rose); outline-offset: 2px; }

/* Live result box ("te cuesta $X por gramo") */
.live-box {
  background: var(--pink-white);
  border: 1.5px dashed var(--pink-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  color: var(--rose-dark);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); }
table.table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  background: var(--pink-white);
  padding: 10px 16px;
}
.table td { padding: 12px 16px; border-top: 1px solid var(--pink-light); vertical-align: middle; }
.table tbody tr:hover { background: var(--pink-white); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 800; background: var(--pink-white); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--pink-light);
  color: var(--rose-dark);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Messages / alerts ---------- */
.messages { margin: 18px 0 0; display: flex; flex-direction: column; gap: 10px; }
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #CBE7D7; }
.alert-error, .alert-danger { background: var(--bad-soft); color: var(--bad); border-color: #F2CDC8; }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: #F0DFC2; }
.alert-info { background: var(--pink-light); color: var(--rose-dark); border-color: var(--pink-2); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  background: var(--pink-white);
  border: 1.5px dashed var(--pink-2);
  border-radius: var(--radius);
}
.empty .empty-emoji { font-size: 2.6rem; display: block; margin-bottom: 10px; }
.empty h3 { color: var(--ink); }
.empty p { color: var(--ink-soft); max-width: 46ch; margin: 0 auto 18px; }

/* ---------- Auth pages (standalone, centered) ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, var(--pink-light) 0%, transparent 42%),
    radial-gradient(circle at 85% 80%, var(--pink-light) 0%, transparent 42%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  padding: 36px 34px;
}
.auth-card .auth-logo {
  text-align: center;
  font-size: 2.6rem;
  margin-bottom: 4px;
}
.auth-card .auth-logo img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 3px 12px rgba(217, 88, 123, 0.30);
}
.auth-card .auth-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 2px;
}
.auth-card .auth-sub {
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 24px;
  font-size: 0.95rem;
}
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.92rem; color: var(--ink-soft); }

/* ---------- Detail / breakdown lists ---------- */
.breakdown { display: flex; flex-direction: column; }
.breakdown .line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--pink-light);
}
.breakdown .line:last-child { border-bottom: none; }
.breakdown .line .lbl { color: var(--ink-soft); }
.breakdown .line.total {
  border-top: 2px solid var(--pink-2);
  margin-top: 4px;
  padding-top: 12px;
  font-weight: 800;
  font-size: 1.05rem;
}

/* ---------- Collapsible advanced section ---------- */
details.advanced {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pink-white);
  padding: 0;
  margin: 16px 0;
}
details.advanced summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--rose-dark);
  padding: 12px 18px;
  list-style: none;
}
details.advanced summary::before { content: "▸ "; }
details.advanced[open] summary::before { content: "▾ "; }
details.advanced .advanced-body { padding: 4px 18px 16px; }

/* ---------- Dynamic form rows (recipe builder, extras) ---------- */
.dyn-rows { display: flex; flex-direction: column; gap: 10px; }
.dyn-row {
  display: grid;
  gap: 10px;
  align-items: center;
  background: var(--pink-white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.dyn-row .remove-row {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.dyn-row .remove-row:hover { background: var(--bad-soft); color: var(--bad); }
.dyn-row .row-cost { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--rose-dark); white-space: nowrap; }

/* ---------- Recipe cards ---------- */
.recipe-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.recipe-card .recipe-photo {
  height: 150px;
  background: linear-gradient(135deg, var(--pink-light), var(--pink-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.recipe-card .recipe-photo img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .recipe-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.recipe-card .recipe-body .actions { margin-top: auto; padding-top: 12px; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.85rem;
  padding: 30px 20px 40px;
}
