/* ============================================================
   FOODINEAT CHEF DASHBOARD — SHARED STYLESHEET
   static/css/style.css

   Tokens are pulled from foodineat.com's live :root (HSL source
   converted to hex), with --secondary swapped from the site's
   lime to a warm roasted brown per product decision (green read
   wrong for a food-focused dashboard). Every page in this app
   must link this single file and reuse these classes — see
   CLAUDE.md "UI / CSS Conventions" for the rules.
   ============================================================ */

:root {
  /* --- Brand colors (source: foodineat.com :root, 2026-08-05) ------ */
  --primary:        #478D9A;  /* hsl(189 37% 44%) — teal, main brand color */
  --primary-lt:      #73B3BF; /* hsl(189 37% 60%) */
  --primary-hover:   #3A7681; /* derived, darker teal for hover states */
  --primary-tint:    #E3F0F2; /* derived, very light teal for tinted backgrounds */

  --secondary:       #A66F3F; /* CUSTOMIZED — warm roasted brown, swapped from site's lime (#A0C25B) */
  --secondary-tint:  #F4EAE1;

  --accent:          #E67EB1; /* hsl(331 68% 70%) — pink, use sparingly (alerts/highlights only) */
  --accent-tint:     #F9DDEA;

  --bg:              #FFFFFF; /* hsl(0 0% 100%) */
  --bg-muted:        #FDFAED; /* hsl(48 80% 96%) — warm cream page background */
  --card:            #FFFFFF;

  --fg:              #183439; /* hsl(189 40% 16%) — primary text, dark teal-ink */
  --fg-muted:        #628C93; /* hsl(189 20% 48%) — secondary text */
  --fg-faint:        #85A7AD; /* derived, hsl(189 20% 60%) — captions/placeholders */

  --border:          #DAE5E7; /* hsl(189 22% 88%) */
  --border-strong:   #BBCFD3; /* derived, hsl(189 22% 78%) */

  /* --- Type (matches foodineat.com exactly) ------------------------ */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace; /* dashboard-specific: numeric/stat data */

  /* --- Scale (radius values match foodineat.com's generous rounding) */
  --radius-sm: 12px;   /* site's --radius-sm: 0.75rem */
  --radius-md: 20px;   /* site's --radius: 1.25rem */
  --radius-lg: 32px;   /* site's --radius-lg: 2rem */

  /* --- Shadows (same hue-tinted approach as the site's shadow tokens) */
  --shadow-sm: 0 2px 12px hsl(189 37% 30% / .08);
  --shadow-md: 0 8px 32px hsl(189 37% 30% / .14);
  --shadow-lg: 0 20px 60px hsl(189 37% 30% / .18);

  --ease: cubic-bezier(.4,0,.2,1);
  --dur: .3s;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-muted);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, .display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; color: var(--fg); margin: 0; }
h1 { font-size: 34px; font-weight: 500; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 500;
}
.muted { color: var(--fg-muted); }
.faint { color: var(--fg-faint); font-size: 13px; }
.mono  { font-family: var(--font-mono); }

/* ============================================================
   LAYOUT SHELL — include on every logged-in page
   ============================================================
   <div class="shell">
     <aside class="sidebar">...</aside>
     <main class="main">...</main>
   </div>
*/
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  background: var(--fg);
  color: #DCEBEA;
  padding: var(--space-5) var(--space-4);
  flex-shrink: 0;
}
.sidebar .brand { font-family: var(--font-display); font-size: 20px; color: #fff; margin-bottom: var(--space-6); display: flex; align-items: center; gap: var(--space-2); }
.sidebar .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  color: #A9C6C4;
  text-decoration: none;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar a.active { background: hsla(28,45%,45%,0.18); color: #DCBDA3; font-weight: 600; }

.main { flex: 1; padding: var(--space-6) var(--space-7); max-width: 1180px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-6); flex-wrap: wrap; gap: var(--space-3); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .1s, box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn-accent { background: var(--secondary); color: #fff; }
.btn-accent:hover { filter: brightness(1.08); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--fg); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   STAT WIDGETS — analytics / stats page
   ============================================================ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12px; color: var(--fg-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; color: var(--fg); }
.stat-card .stat-delta { font-family: var(--font-mono); font-size: 12px; margin-top: 4px; }
.stat-delta.up { color: var(--primary); }
.stat-delta.down { color: var(--accent); }

/* ============================================================
   COOKBOOK CARD — signature element.
   The "tab" color should be set inline per cookbook from that
   cookbook's own CookbookProfile appearance fields, e.g.:
     <div class="tab" style="background: {{.IconBackgroundColor}}"></div>
   ============================================================ */
.cookbook-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-5); }

.cookbook-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-4) var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.cookbook-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.cookbook-card .tab {
  position: absolute;
  top: -9px;
  left: 20px;
  width: 44px;
  height: 18px;
  border-radius: 4px 4px 0 0;
  background: var(--primary); /* default; override inline per cookbook */
}
.cookbook-card .icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: var(--space-3);
  background: var(--primary-tint);
  color: var(--primary-hover);
  overflow: hidden;
}
.cookbook-card .icon img { width: 100%; height: 100%; object-fit: cover; }
.cookbook-card h3 { margin-bottom: 2px; }
.cookbook-card .meta { font-size: 12px; color: var(--fg-faint); margin-top: var(--space-2); display: flex; gap: 10px; flex-wrap: wrap; }
.cookbook-card .meta span { display: flex; align-items: center; gap: 4px; }

/* ============================================================
   RECIPE GRID — a cookbook's recipes on /cookbook?id=, styled with that
   cookbook's own selected colors (icon/text background/foreground)
   ============================================================ */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  max-height: 640px;
  overflow-y: auto;
  padding: 4px;
}
.recipe-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--card);
}
.recipe-card .recipe-card-tab {
  position: absolute;
  top: 0; left: 20px;
  width: 36px; height: 10px;
  border-radius: 0 0 4px 4px;
  z-index: 1;
}
.recipe-card .recipe-card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--border);
}
.recipe-card .recipe-card-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
}
.recipe-card .recipe-card-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0;
}
.recipe-card .recipe-card-actions button:hover { background: var(--primary-tint); color: var(--primary-hover); border-color: var(--primary); }
.recipe-card .recipe-card-actions button.danger:hover { background: var(--accent-tint); color: var(--accent); border-color: var(--accent); }
.recipe-card .recipe-card-actions svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.recipe-card .recipe-card-info { flex: 1; padding: var(--space-3) var(--space-4); }
.recipe-card .recipe-card-info h4 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.recipe-card .recipe-card-info .recipe-card-meta { font-size: 12px; opacity: .75; }

/* ============================================================
   TAGS
   ============================================================ */
.tag {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px;
  font-family: var(--font-mono);
}
.tag-primary   { background: var(--primary-tint);   color: var(--primary-hover); }
.tag-secondary { background: var(--secondary-tint); color: #6F4A2A; }
.tag-accent    { background: var(--accent-tint);    color: #A84E79; }

/* ============================================================
   TABLE — recipe / cookbook membership lists
   ============================================================ */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th {
  text-align: left; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--fg-muted); font-weight: 600; padding: 12px 16px;
  background: var(--primary-tint); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #FBFAF3; }
.recipe-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; vertical-align: middle; margin-right: 10px; background: var(--border); }

/* ============================================================
   PANEL / SECTION CARD — generic content container
   ============================================================ */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: var(--space-5); }

/* ============================================================
   BAR CHART — pure-CSS trend viz, no charting lib required
   ============================================================
   <div class="bar-chart">
     <div class="bar" style="height:40%"></div>
     ...
     <div class="bar today" style="height:90%"></div>
   </div>
*/
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: var(--space-3); }
.bar-chart .bar { flex: 1; background: var(--primary-lt); border-radius: 4px 4px 0 0; opacity: 0.9; }
.bar-chart .bar.today { background: var(--primary); opacity: 1; }

/* ============================================================
   FORMS — profile editing, login
   ============================================================ */
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--fg-muted); margin-bottom: 6px; }
.field-input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
}
.field-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.field-group { margin-bottom: var(--space-4); }
.color-input {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}
.color-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.icon-preview {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  background: var(--primary-tint);
  color: var(--primary-hover);
  overflow: hidden;
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   MODAL — centered card over a dim backdrop (icon crop tool, etc.)
   <div class="modal-backdrop" id="...">
     <div class="modal-card">
       <div class="modal-header"><h3>Title</h3><button>✕</button></div>
       <div class="modal-body">...</div>
     </div>
   </div>
   Toggle open with .open on .modal-backdrop.
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: hsl(189 40% 16% / .45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: 100%;
  max-height: 85vh;
}
.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.modal-body { padding: var(--space-4) var(--space-5); overflow-y: auto; }

/* Icon crop viewport — a fixed-size square window the chef pans/zooms an
   uploaded image inside (static/js/cookbook.js's icon-crop-* handlers) before
   it's rendered to a canvas and uploaded as the actual icon. */
.icon-crop-viewport {
  width: 280px;
  height: 280px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg-muted);
  cursor: grab;
  touch-action: none;
}
.icon-crop-viewport.dragging { cursor: grabbing; }
.icon-crop-viewport img {
  position: absolute;
  top: 0; left: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: var(--space-8) var(--space-5); color: var(--fg-muted); }
.empty-state h3 { color: var(--fg-muted); margin-bottom: var(--space-2); }

/* ============================================================
   READ-ONLY SESSION — body.read-only is set by static/js/shell.js
   for a chefReadOnly (lapsed chef) session. Hide any write action
   with [data-requires-write] rather than duplicating the check in
   every page's own script.
   ============================================================ */
.read-only [data-requires-write] { display: none !important; }
.read-only-notice { display: none; }
.read-only .read-only-notice { display: block; }
/* .stats-full-access gates the whole /stats dashboard — analytics is a paid
   feature, not just a write action, for a lapsed (chefReadOnly) chef. */
.read-only .stats-full-access { display: none; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-muted); padding: var(--space-5); }
.login-panel { width: 100%; max-width: 380px; }
.login-panel .brand { font-family: var(--font-display); font-size: 22px; display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); color: var(--fg); }
.login-panel .brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary); }
.login-panel p.muted { margin-bottom: var(--space-5); }
.login-error { color: var(--accent); font-size: 13px; margin-top: var(--space-2); min-height: 18px; }

/* ============================================================
   TOAST — lightweight transient feedback for async actions
   ============================================================ */
.toast {
  position: fixed; bottom: var(--space-6); left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--fg); color: #fff; padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--accent); }
