/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:   #e67e22;
  --accent2:  #d35400;
  --bg:       #faf9f7;
  --surface:  #ffffff;
  --border:   #e5e1dc;
  --text:     #2c2c2c;
  --muted:    #777;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,.08);
  --transition: .18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

img { max-width: 100%; display: block; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.nav-links { display: flex; gap: .5rem; flex-wrap: wrap; }

.nav-links a {
  padding: .35rem .75rem;
  border-radius: 20px;
  font-size: .9rem;
  color: var(--text);
  transition: background var(--transition);
}
.nav-links a:hover, .nav-links a.active { background: var(--accent); color: #fff; }

.nav-search {
  flex: 1;
  min-width: 200px;
}

.nav-search form { display: flex; gap: .5rem; }

.nav-search input {
  flex: 1;
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition);
}
.nav-search input:focus { border-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d0cbc5; }
.btn-danger   { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #128C7E; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Hero / Header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: center;
}

.filter-bar select, .filter-bar input {
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .85rem;
  background: var(--surface);
  cursor: pointer;
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--accent); }

.tag-pill {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: #fef3e2;
  color: var(--accent2);
  border: 1px solid #f5d5a0;
  cursor: pointer;
  transition: all var(--transition);
}
.tag-pill:hover, .tag-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Recipe Grid ──────────────────────────────────────────────────────────── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.recipe-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }

.card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #f0ede8;
}

.card-img-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, #f5f0ea, #ede8e0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #c5bdb4;
}

.card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .4rem; }
.card-title { font-size: 1rem; font-weight: 700; line-height: 1.3; }
.card-meta { font-size: .8rem; color: var(--muted); display: flex; gap: .75rem; flex-wrap: wrap; }
.card-category { font-size: .75rem; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card-tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: auto; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.empty-state .icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: .5rem; color: var(--text); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.pagination button {
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  transition: all var(--transition);
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Recipe Detail ────────────────────────────────────────────────────────── */
.recipe-detail { max-width: 780px; margin: 0 auto; padding: 1.5rem 1rem; }

.recipe-hero {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  background: #f0ede8;
  max-height: 380px;
}
.recipe-hero img { width: 100%; max-height: 380px; object-fit: cover; }

.recipe-title { font-size: 2rem; font-weight: 800; margin-bottom: .5rem; line-height: 1.2; }

.recipe-meta-bar {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.meta-item { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.meta-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.meta-value { font-size: 1rem; font-weight: 700; }

.recipe-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1.25rem 0; }

.recipe-section { margin: 1.75rem 0; }
.recipe-section h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 2px solid var(--border); }

.ingredients-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.ingredients-list li {
  display: flex;
  gap: .75rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.ingredients-list li:hover { background: #f5f0ea; }
.ing-amount { font-weight: 700; min-width: 60px; color: var(--accent); }
.ing-unit   { min-width: 40px; color: var(--muted); }
.ing-notes  { font-size: .85rem; color: var(--muted); margin-left: .25rem; }

.steps-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.steps-list li { display: flex; gap: 1rem; }
.step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  margin-top: .1rem;
}
.step-text { flex: 1; line-height: 1.7; }

/* ── Shopping list modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.modal h3 { margin-bottom: 1rem; font-size: 1.15rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }

.servings-control {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .75rem 0;
}
.servings-control button {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.servings-control button:hover { border-color: var(--accent); color: var(--accent); }
.servings-control span { font-weight: 700; min-width: 2rem; text-align: center; }

/* ── Form styles ──────────────────────────────────────────────────────────── */
.form-container { max-width: 780px; margin: 0 auto; padding: 1.5rem 1rem; }

.tab-bar { display: flex; gap: .25rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); }
.tab-btn {
  padding: .6rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .95rem;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.form-control {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }

.ingredient-row {
  display: grid;
  grid-template-columns: 70px 70px 1fr 120px auto;
  gap: .5rem;
  align-items: start;
  margin-bottom: .5rem;
}

.step-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  margin-bottom: .5rem;
  align-items: start;
}

.remove-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid #e74c3c;
  border-radius: var(--radius);
  background: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  margin-top: .1rem;
}
.remove-btn:hover { background: #e74c3c; color: #fff; }

.tag-selector { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-check { display: none; }
.tag-check + label {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.tag-check:checked + label { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── URL parse result box ─────────────────────────────────────────────────── */
.parse-box {
  background: #f0f8f0;
  border: 1px solid #c3e6cb;
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  font-size: .9rem;
}
.parse-box.error { background: #fff5f5; border-color: #f5c6cb; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #333;
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-size: .9rem;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transform: translateY(20px);
  opacity: 0;
  transition: all .25s ease;
  pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: #27ae60; }
#toast.error   { background: #e74c3c; }

/* ── Loading spinner ──────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .recipe-title { font-size: 1.5rem; }
  .ingredient-row { grid-template-columns: 60px 60px 1fr auto; }
  .ingredient-row .ing-notes-input { grid-column: 1 / -1; }
  .nav-inner { gap: .5rem; }
  .recipe-meta-bar { gap: .75rem; }
}
