/* =========================================================
   NutriPlan — Design System
   Inspired by Lifesum + Huel + Yazio (real app references)
   ========================================================= */

:root {
  /* Warm cream backgrounds (Lifesum) */
  --cream: #faf5f0;
  --cream-2: #f5ebe1;
  --paper: #ffffff;

  /* Text (Lifesum + Yazio) */
  --ink: #0e0e0e;
  --ink-2: #2a2a2a;
  --muted: #5c5c5c;
  --muted-2: #767676;
  --hair: #ece5da;
  --hair-strong: #e0d9cc;

  /* Primary green (Lifesum #21BA3A, Huel #46BE6A) */
  --green: #21ba3a;
  --green-hover: #42c458;
  --green-dark: #1a952e;
  --green-soft: #e4f5e6;

  /* Warm accents */
  --orange: #f97316;
  --orange-soft: #ffe8d6;
  --yellow: #fbbf24;
  --yellow-soft: #fef3c7;
  --berry: #d946ef;
  --berry-soft: #fae8ff;
  --ocean: #0ea5e9;
  --ocean-soft: #dbeafe;

  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --r-sm: 8px;
  --r: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(14,14,14,.04);
  --shadow-sm: 0 2px 8px rgba(14,14,14,.06);
  --shadow: 0 8px 24px rgba(14,14,14,.08);
  --shadow-lg: 0 24px 48px -8px rgba(14,14,14,.15);
  --shadow-green: 0 8px 20px rgba(33, 186, 58, .25);

  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

h1, h2, h3, h4 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: 30px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }

a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }

/* Small label */
.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

/* =========================================================
   LOGIN — Split warm
   ========================================================= */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--cream);
}

.auth-hero {
  background: var(--cream-2);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: '';
  position: absolute;
  right: -15%; top: -10%;
  width: 60%; height: 60%;
  background: radial-gradient(circle, var(--green-soft) 0%, transparent 70%);
  pointer-events: none;
}
.auth-hero::after {
  content: '';
  position: absolute;
  left: -20%; bottom: -15%;
  width: 70%; height: 70%;
  background: radial-gradient(circle, var(--orange-soft) 0%, transparent 65%);
  opacity: .6; pointer-events: none;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  position: relative; z-index: 1;
}
.brand-logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--green);
  color: white;
}
.brand-logo svg { width: 22px; height: 22px; stroke-width: 2.5; }

.hero-main { max-width: 480px; position: relative; z-index: 1; }
.hero-main .eyebrow { color: var(--green-dark); margin-bottom: 20px; display: block; }
.hero-main h1 {
  color: var(--ink);
  margin-bottom: 18px;
}
.hero-main h1 .highlight {
  color: var(--green);
  position: relative;
}
.hero-main p {
  color: var(--muted);
  font-size: 17px;
  max-width: 420px;
  line-height: 1.55;
}

.hero-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 32px;
  position: relative; z-index: 1;
}
.hero-tile {
  background: var(--paper);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.hero-tile .tile-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.hero-tile .tile-icon.green { background: var(--green-soft); color: var(--green-dark); }
.hero-tile .tile-icon.orange { background: var(--orange-soft); color: var(--orange); }
.hero-tile .tile-icon.berry { background: var(--berry-soft); color: var(--berry); }
.hero-tile .tile-icon.ocean { background: var(--ocean-soft); color: var(--ocean); }
.hero-tile .tile-icon svg { width: 20px; height: 20px; stroke-width: 2; }
.hero-tile strong { display: block; font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.hero-tile span { font-size: 12px; color: var(--muted); }

.hero-footer {
  font-size: 13px;
  color: var(--muted-2);
  position: relative; z-index: 1;
}

.auth-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  background: var(--paper);
}
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 {
  font-size: 32px; font-weight: 800;
  margin-bottom: 8px; letter-spacing: -0.03em;
}
.auth-form > .muted { font-size: 15px; margin-bottom: 32px; }

label {
  display: block; margin: 16px 0 8px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--hair-strong);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
input::placeholder { color: var(--muted-2); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px 24px;
  margin-top: 24px;
  background: var(--green);
  color: white;
  border: 0;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: background .15s, transform .15s, box-shadow .15s;
}
button:hover, .btn:hover {
  background: var(--green-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-green);
}
button:active { transform: translateY(0); }
button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--hair-strong);
  box-shadow: none;
}
button.secondary:hover {
  background: var(--cream);
  border-color: var(--ink-2);
  box-shadow: none;
}
button.dark { background: var(--ink); color: var(--paper); }
button.dark:hover { background: var(--ink-2); box-shadow: 0 8px 20px rgba(14,14,14,.2); }
button.ghost {
  background: transparent; color: var(--ink); border: 0;
  padding: 10px 16px; min-height: auto; margin: 0;
  font-weight: 600;
  width: auto;
}
button.ghost:hover { background: var(--cream-2); transform: none; box-shadow: none; }
button.sm { padding: 8px 18px; min-height: 36px; font-size: 13px; margin: 0; width: auto; }

.error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  margin-top: 16px;
  font-size: 13px;
  font-weight: 500;
  display: none;
}
.error.show { display: block; }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--paper);
  border-right: 1px solid var(--hair);
  padding: 24px 16px;
  flex-shrink: 0;
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease);
}
.sidebar svg { flex-shrink: 0; }
.sidebar .brand { padding: 0 10px 24px; }

.sidebar nav {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  margin-top: 8px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: var(--cream); color: var(--ink); }
.sidebar nav a.active {
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 600;
}
.sidebar nav a.active svg { stroke: var(--green-dark); }
.sidebar nav a svg {
  width: 20px; height: 20px; stroke-width: 2;
  stroke: currentColor;
  flex-shrink: 0;
}

.sidebar-footer { padding-top: 16px; border-top: 1px solid var(--hair); }
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.sidebar-user .info { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar-user .info strong { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .info span { font-size: 11px; color: var(--muted); }
.signout {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  border-radius: var(--r-sm);
  transition: background .15s, color .15s;
}
.signout svg {
  width: 18px; height: 18px; stroke-width: 2;
  stroke: currentColor; flex-shrink: 0;
}
.signout:hover { background: var(--cream); color: var(--ink); }

.main {
  flex: 1; min-width: 0;
  padding: 36px 44px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.topbar .eyebrow { margin-bottom: 6px; display: block; }
.topbar h2 { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.topbar .subtitle { color: var(--muted); font-size: 15px; margin-top: 4px; }

.menu-toggle {
  display: none;
  width: 42px; height: 42px; padding: 0; margin: 0;
  background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--hair-strong);
  border-radius: var(--r-sm);
  min-height: auto;
  width: 42px;
}
.menu-toggle svg { width: 20px; height: 20px; }
.menu-toggle:hover { background: var(--cream-2); transform: none; box-shadow: none; }

.overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(14,14,14,.5); z-index: 90;
  backdrop-filter: blur(4px);
}
.overlay.active { display: block; }

/* =========================================================
   COMPONENTS — cards, stats, meals
   ========================================================= */
.card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--hair);
}

/* Stats — Yazio-style floating cards */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  background: var(--paper);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--hair);
  position: relative;
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 20px; height: 20px; stroke-width: 2; }
.stat-icon.green { background: var(--green-soft); color: var(--green-dark); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.berry { background: var(--berry-soft); color: var(--berry); }
.stat-icon.ocean { background: var(--ocean-soft); color: var(--ocean); }
.stat-icon.yellow { background: var(--yellow-soft); color: #b45309; }

.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
  display: flex; align-items: baseline; gap: 4px;
}
.stat-value .unit { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.stat-sub.up { color: var(--orange); }
.stat-sub.down { color: var(--green-dark); }

/* Next meal hero — Lifesum-style vibrant hero */
.next-hero {
  background: linear-gradient(135deg, #21ba3a 0%, #1a952e 100%);
  color: white;
  border-radius: var(--r-lg);
  padding: 32px 36px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-green);
}
.next-hero::before {
  content: '';
  position: absolute; right: -60px; top: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.next-hero::after {
  content: '';
  position: absolute; right: 20px; bottom: -80px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.next-hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; position: relative; z-index: 1; }
.next-hero .eyebrow { color: rgba(255,255,255,.85); margin-bottom: 8px; font-weight: 700; }
.next-hero h2 { color: white; font-size: 32px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; }
.next-hero .opcao-name { color: rgba(255,255,255,.9); font-size: 15px; }
.next-time-wrap {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  padding: 18px 24px;
  border-radius: var(--r);
  text-align: center;
  border: 1px solid rgba(255,255,255,.2);
}
.next-time {
  font-size: 40px; font-weight: 800;
  color: white;
  letter-spacing: -0.03em;
  line-height: 1;
}
.next-time-label { font-size: 11px; color: rgba(255,255,255,.8); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 6px; font-weight: 600; }

/* Meal card */
.meal {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--hair);
  transition: transform .15s, box-shadow .15s;
}
.meal:hover { box-shadow: var(--shadow-sm); }
.meal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.meal-title { flex: 1; min-width: 200px; display: flex; align-items: flex-start; gap: 14px; }
.meal-emoji {
  width: 48px; height: 48px;
  background: var(--cream-2);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.meal-title h3 { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.meal-title .opcao {
  font-size: 13px; color: var(--muted);
  font-weight: 500;
}
.meal-hora {
  background: var(--green-soft);
  color: var(--green-dark);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 14px; font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.foods-list { display: flex; flex-direction: column; gap: 8px; }
.food {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  background: var(--cream);
  border-radius: var(--r);
  gap: 12px; flex-wrap: wrap;
  transition: background .15s;
}
.food:hover { background: var(--cream-2); }
.food-info { flex: 1; min-width: 0; }
.food-info strong { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.food-info span { font-size: 12px; color: var(--muted); text-transform: capitalize; margin-top: 1px; display: block; }
.food-qty {
  background: var(--paper);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  border: 1px solid var(--hair-strong);
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.green { background: var(--green-soft); color: var(--green-dark); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.yellow { background: var(--yellow-soft); color: #b45309; }
.badge.ocean { background: var(--ocean-soft); color: var(--ocean); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1.5px solid var(--hair-strong);
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  background: var(--paper);
}

/* Tables */
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { padding: 14px 20px; text-align: left; font-size: 14px; }
th {
  background: var(--cream);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--hair);
}
tbody tr { border-bottom: 1px solid var(--hair); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--cream); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(14,14,14,.5);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 99; padding: 20px;
  animation: fadeIn .2s;
}
.modal-bg.active { display: flex; }
.modal {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 32px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s var(--ease);
}
.modal h3 { font-size: 24px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; }
.modal .muted { margin-bottom: 20px; font-size: 14px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Empty / loader */
.empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted); font-size: 15px;
  background: var(--paper);
  border-radius: var(--r-lg);
  border: 1px solid var(--hair);
}
.empty .big {
  font-size: 40px; margin-bottom: 12px;
}
.loader {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid var(--hair); border-top-color: var(--green);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 32px 0 16px;
}
.section-head h3 { font-size: 20px; font-weight: 700; }

/* =========================================================
   RESPONSIVO
   ========================================================= */
@media (max-width: 1024px) { .main { padding: 28px 24px; } }

@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form-wrap { padding: 48px 24px; min-height: 100vh; }
  .stats { grid-template-columns: 1fr 1fr; }
  .next-hero-grid { grid-template-columns: 1fr; }
  .next-time-wrap { justify-self: stretch; }
}

@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px 16px; }
  .topbar h2 { font-size: 26px; }
  .meal { padding: 20px; }
  .meal-title h3 { font-size: 17px; }
  .next-hero { padding: 24px; }
  .next-hero h2 { font-size: 24px; }
  .next-time { font-size: 32px; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  th, td { padding: 12px 14px; }
  .food { flex-direction: column; align-items: stretch; gap: 8px; }
  .food > div:last-child { display: flex; justify-content: space-between; }
}
