/* ────────────────────────────────────────────────────────────
   Despensa · Design System · Mobile-first
   ──────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --green:       #16a34a;
  --green-dark:  #15803d;
  --green-dim:   #166534;
  --green-light: #dcfce7;
  --green-pale:  #f0fdf4;
  --bg:          #faf9f6;
  --surface:     #f3f2ee;
  --card:        #ffffff;
  --text:        #111827;
  --text-2:      #374151;
  --muted:       #9ca3af;
  --border:      #e5e7eb;
  --border-2:    #f3f4f6;
  --warn:        #f59e0b;
  --warn-light:  #fffbeb;
  --warn-dark:   #92400e;
  --danger:      #ef4444;
  --danger-light:#fef2f2;
  --radius:      18px;
  --radius-sm:   12px;
  --radius-xs:   8px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 2px 8px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.10), 0 4px 10px rgba(0,0,0,.05);
  --trans:       .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 82px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

/* ── Topbar ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, var(--green-dim) 0%, var(--green) 100%);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(21,128,61,.25);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.topbar .topbar-sub {
  font-size: .72rem;
  font-weight: 500;
  opacity: .7;
  letter-spacing: .02em;
}
.logout, .btn-icon-ghost {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 600;
  background: rgba(255,255,255,.15);
  padding: 7px 14px;
  border-radius: 20px;
  transition: background var(--trans);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.logout:active, .btn-icon-ghost:active { background: rgba(255,255,255,.25); }

/* ── Main content ── */
main {
  padding: 20px 16px;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Greeting ── */
.greeting { padding: 4px 0 18px; }
.greeting h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
}
.greeting p { color: var(--muted); font-size: .875rem; margin-top: 4px; }

/* ── Section label ── */
.section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.015em;
}
.card-link {
  font-size: .8rem;
  color: var(--green);
  text-decoration: none;
  font-weight: 600;
}
.card-link:active { opacity: .7; }

/* ── Meal rows ── */
.meal-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-2);
}
.meal-row:last-child { border: 0; padding-bottom: 0; }
.meal-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 13px;
  background: var(--surface);
  flex-shrink: 0;
}
.meal-info { flex: 1; min-width: 0; }
.meal-info strong {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-info small { color: var(--muted); font-size: .75rem; }
.meal-tag {
  display: inline-flex;
  align-items: center;
  background: var(--green-light);
  color: var(--green-dim);
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: capitalize;
  margin-top: 3px;
}

/* ── Stock/Product grid ── */
.grid-prod {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.prod-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 12px 8px;
  border-radius: 13px;
  border: 1.5px solid var(--border-2);
  font-size: .72rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--trans);
}
.prod-mini:active { transform: scale(.95); }
.prod-mini img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--border);
}
.prod-mini .warn-qty {
  color: var(--warn);
  font-weight: 700;
  font-size: .68rem;
}

/* ── Quick actions grid ── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: var(--card);
  color: var(--text-2);
  text-decoration: none;
  padding: 18px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: .82rem;
  transition: transform var(--trans), box-shadow var(--trans);
  text-align: center;
  border: 1.5px solid transparent;
}
.action-btn .action-icon { font-size: 1.6rem; line-height: 1; }
.action-btn:active { transform: scale(.96); box-shadow: var(--shadow-sm); }
.action-btn.primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dim) 100%);
  color: #fff;
  border-color: transparent;
}
.action-btn.accent {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}

/* ── Alert strip ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 12px;
  line-height: 1.4;
}
.alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-warn { background: var(--warn-light); color: var(--warn-dark); border-left: 3px solid var(--warn); }
.alert-green { background: var(--green-pale); color: var(--green-dim); border-left: 3px solid var(--green); }
.alert-danger { background: var(--danger-light); color: #991b1b; border-left: 3px solid var(--danger); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.3;
}
.badge-green  { background: var(--green-light); color: var(--green-dim); }
.badge-warn   { background: var(--warn-light);  color: var(--warn-dark); }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-gray   { background: var(--surface); color: var(--muted); }

/* ── Chips / filter tabs ── */
.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  margin-bottom: 14px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 7px 15px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--trans);
  text-decoration: none;
  white-space: nowrap;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.chip:active { opacity: .75; }

/* ── Form components ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
}
.form-control {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--trans), background var(--trans);
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--green); background: #fff; }
.form-control::placeholder { color: var(--muted); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans), transform var(--trans);
  text-decoration: none;
  letter-spacing: -.01em;
  border: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dim) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(22,163,74,.3);
}
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-2);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  color: var(--green);
  padding-left: 0; padding-right: 0;
}
.btn-sm { padding: 8px 14px; font-size: .82rem; border-radius: var(--radius-xs); }

/* ── List items (shopping / ingredients) ── */
.list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-2);
}
.list-item:last-child { border: 0; padding-bottom: 0; }
.list-check {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans);
  background: var(--bg);
}
.list-check.checked {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.list-item-info { flex: 1; min-width: 0; }
.list-item-name {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-name.done {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 400;
}
.list-item-meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.list-item-qty {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}

/* ── Number stepper ── */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.stepper-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: background var(--trans);
  font-weight: 600;
}
.stepper-btn:active { background: var(--border); }
.stepper-val {
  width: 40px;
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
  border: none;
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  background: var(--card);
  padding: 8px 0;
  color: var(--text);
}

/* ── Calendar / Planificador ── */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.week-nav h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  flex: 1;
}
.week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 16px;
}
.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--trans);
  text-decoration: none;
  color: var(--text);
}
.day-pill .day-name {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.day-pill .day-num {
  font-size: .95rem;
  font-weight: 700;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.day-pill.active .day-num {
  background: var(--green);
  color: #fff;
}
.day-pill.has-plan .day-name { color: var(--green); }
.day-pill.today .day-num {
  background: var(--green-light);
  color: var(--green-dim);
}

/* ── Recipe cards ── */
.recipe-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform var(--trans);
}
.recipe-card:active { transform: scale(.98); }
.recipe-thumb {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}
.recipe-info { flex: 1; min-width: 0; }
.recipe-title {
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.recipe-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border-2); margin: 14px 0; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}
.empty-state .ei { font-size: 2.8rem; margin-bottom: 10px; opacity: .55; }
.empty-state p { font-size: .875rem; line-height: 1.5; }
.empty-state .btn { margin-top: 18px; }

/* ── FAB (Floating Action Button) ── */
.fab {
  position: fixed;
  bottom: 90px;
  right: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dim) 100%);
  color: #fff;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(22,163,74,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform var(--trans), box-shadow var(--trans);
  z-index: 90;
}
.fab:active { transform: scale(.92); box-shadow: 0 3px 10px rgba(22,163,74,.3); }

/* ── Bottom navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: .63rem;
  font-weight: 600;
  transition: color var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-item.active { color: var(--green); }
.nav-item:active { opacity: .6; }

/* ── Ticket / upload ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  background: var(--bg);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--green);
  background: var(--green-pale);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: .6; }
.upload-zone p { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.upload-zone strong { color: var(--green); }
#file-input { display: none; }

/* ── Progress bar ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
  border-radius: 3px;
  transition: width .4s ease;
}

/* ── Modals / bottom sheets ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.bottom-sheet {
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-overlay.open .bottom-sheet { transform: translateY(0); }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 18px;
}
.sheet-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 18px;
}

/* ── Utility ── */
.muted { color: var(--muted); font-size: .875rem; }
.err   { color: var(--danger); font-size: .85rem; margin: 6px 0; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: .85rem; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; gap: 8px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Login ── */
body.login-body {
  padding-bottom: 0;
  background: linear-gradient(160deg, #f0fdf4 0%, #dcfce7 45%, #a7f3d0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
}
.login-card {
  background: #fff;
  padding: 36px 28px 32px;
  border-radius: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dim) 100%);
  border-radius: 22px;
  font-size: 2rem;
  margin-bottom: 14px;
  box-shadow: 0 8px 20px rgba(22,163,74,.28);
}
.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
}
.login-logo p {
  font-size: .825rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Responsive ── */
@media (min-width: 480px) {
  main { padding: 24px 20px; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
