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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f5f4f0;
  color: #222;
  direction: rtl;
  font-size: 15px;
  line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ───────────────────────────────────────────────────────── */
.topnav {
  background: #1e1e1e;
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-logo { color: #fff; font-weight: 700; font-size: 1.05rem; }
.nav-link  { color: #bbb; font-size: 0.9rem; }
.nav-link:hover { color: #fff; text-decoration: none; }

main { padding: 1.5rem; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
}
.btn-primary:hover  { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  display: inline-block;
}
.btn-secondary:hover { background: #f0f0f0; text-decoration: none; }

.btn-text {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0;
}
.btn-text:hover { text-decoration: underline; }
.btn-text--danger { color: #dc2626; }

.btn-add, .btn-add-section {
  background: none;
  border: 1px dashed #aaa;
  color: #555;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  margin-top: 0.4rem;
}
.btn-add:hover, .btn-add-section:hover { background: #eee; }

.btn-remove {
  background: none;
  border: none;
  color: #b91c1c;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.3rem;
  line-height: 1;
  font-family: inherit;
}
.btn-move {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.2rem;
  display: block;
  font-family: inherit;
}
.btn-move:hover { color: #222; }

/* ── Feedback ──────────────────────────────────────────────────── */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  padding: 0.6rem 1rem;
  border-radius: 5px;
  margin: 0.75rem 0;
}
.info-banner {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  padding: 0.6rem 1rem;
  border-radius: 5px;
  margin-bottom: 1rem;
}
.hidden { display: none !important; }
.loader { text-align: center; padding: 3rem; color: #888; font-size: 1.1rem; }

/* ── Card ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── Import page ───────────────────────────────────────────────── */
.container { max-width: 760px; margin: 0 auto; }

.page-title { font-size: 1.4rem; margin-bottom: 1rem; }

#raw-text {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  resize: vertical;
  direction: rtl;
}
#raw-text:focus { outline: none; border-color: #2563eb; }

.form-actions { margin-top: 0.75rem; display: flex; gap: 0.75rem; align-items: center; }

/* Questions */
.section-title { font-size: 1.1rem; margin-bottom: 0.75rem; }

.question-block {
  background: #fafaf8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.9rem;
}
.q-issue {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.q-quote {
  background: #f3f4f6;
  border-right: 3px solid #aaa;
  padding: 0.3rem 0.6rem;
  font-size: 0.88rem;
  color: #555;
  margin: 0.4rem 0;
  direction: rtl;
}
.q-text { margin-bottom: 0.5rem; }
.radio-label { display: block; margin: 0.3rem 0; cursor: pointer; font-size: 0.9rem; }
.other-input { margin-right: 0.5rem; padding: 0.25rem 0.5rem; border: 1px solid #ccc; border-radius: 3px; font-family: inherit; font-size: 0.9rem; direction: rtl; }
.text-input { width: 100%; padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 0.9rem; direction: rtl; }

/* Recipe list */
.recipe-list { list-style: none; }
.recipe-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #eee;
}
.recipe-list-item:last-child { border-bottom: none; }
.recipe-list-title { font-weight: 500; flex: 1; }
.recipe-list-date { color: #999; font-size: 0.82rem; }

/* ── Edit page ─────────────────────────────────────────────────── */
.edit-wrap { max-width: 1200px; margin: 0 auto; }

.edit-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #ddd;
}
.title-input {
  flex: 1;
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  direction: rtl;
  font-family: inherit;
}
.title-input:focus { outline: none; border-color: #2563eb; }
.edit-header-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* RTL flex: first child is on the right */
.edit-panels {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
.panel-editor { flex: 1; min-width: 0; }
.panel-raw    { width: 260px; flex-shrink: 0; position: sticky; top: 1rem; }

.editor-section { margin-bottom: 1.75rem; }
.editor-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #444;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
}

/* Review banner */
.review-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Ingredient sections */
.ing-section-block { margin-bottom: 1rem; }
.ing-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.ing-section-name {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  direction: rtl;
  font-family: inherit;
  background: #f9f9f9;
}

/* Ingredient table */
.ing-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.ing-table th {
  text-align: right;
  padding: 0.25rem 0.35rem;
  color: #888;
  font-weight: 500;
  font-size: 0.78rem;
  border-bottom: 1px solid #eee;
}
.ing-table td { padding: 0.2rem 0.25rem; vertical-align: middle; }
.ing-table td:last-child { width: 48px; text-align: center; }
.ing-input {
  width: 100%;
  padding: 0.28rem 0.4rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.87rem;
  direction: rtl;
  font-family: inherit;
}
.ing-input:focus { outline: none; border-color: #2563eb; }

/* Needs review highlight */
.needs-review .ing-input { background: #fffbeb; }
tr.needs-review { border-right: 3px solid #f59e0b; }

/* Raw source tooltip */
.raw-badge {
  display: inline-block;
  font-size: 0.75rem;
  color: #aaa;
  cursor: help;
  margin-right: 2px;
}

/* Steps */
.step-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
}
.step-move-col { display: flex; flex-direction: column; flex-shrink: 0; }
.step-num { min-width: 20px; font-weight: 700; color: #999; font-size: 0.82rem; padding-top: 0.35rem; flex-shrink: 0; }
.step-text {
  flex: 1;
  padding: 0.3rem 0.4rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  direction: rtl;
  min-height: 42px;
}
.step-text:focus { outline: none; border-color: #2563eb; }
.step-row.needs-review .step-text { background: #fffbeb; border-color: #f59e0b; }
.step-actions { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }

/* Notes */
.note-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.note-input {
  flex: 1;
  padding: 0.32rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  direction: rtl;
}
.note-input:focus { outline: none; border-color: #2563eb; }

/* Unclassified */
.unclassified-line {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 3px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  color: #78350f;
}

/* Raw text panel */
.raw-text-pre {
  font-family: inherit;
  font-size: 0.83rem;
  line-height: 1.7;
  color: #666;
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 5px;
  padding: 0.75rem;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  direction: rtl;
}

/* ── Recipe page ───────────────────────────────────────────────── */
.recipe-page {
  max-width: 720px;
  margin: 0 auto;
}

/* Hero image */
.recipe-hero {
  position: relative;
  width: 100%;
  margin-bottom: 1.75rem;
  border-radius: 14px;
  overflow: hidden;
  background: #ede9e1;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
}

.recipe-hero-img {
  display: block;
  width: 100%;
  height: 400px;
  object-fit: cover;
}

/* Image placeholder */
.recipe-hero-placeholder {
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: #aaa;
}
.placeholder-icon { width: 60px; height: 60px; opacity: 0.5; }
.placeholder-text { font-size: 0.9rem; }

.btn-find-image {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-find-image:hover { background: #f3f4f6; }
.btn-find-image:disabled { opacity: 0.5; cursor: not-allowed; }

/* Image action overlay — appears on hover */
.image-actions-overlay {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.recipe-hero:hover .image-actions-overlay { opacity: 1; }

.image-action-btn {
  background: rgba(0,0,0,0.50);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
}
.image-action-btn:hover { background: rgba(0,0,0,0.70); }
.image-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.image-upload-label { display: inline-block; }

/* Title row */
.recipe-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.recipe-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1a1a1a;
}
.btn-edit-recipe {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 0.45rem 1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-edit-recipe:hover {
  background: #f9f9f9;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-decoration: none;
}
.btn-delete-recipe {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 0.45rem 1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-delete-recipe:hover {
  background: #fef2f2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Recipe body */
.recipe-body { display: flex; flex-direction: column; gap: 1.25rem; }

/* Cards */
.recipe-card {
  background: #fff;
  border: 1px solid #ebe8e2;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.recipe-card--notes {
  background: #fdfcf8;
  border-color: #e8e4d8;
}

.recipe-card-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #3d3530;
  margin-bottom: 1.1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #ede9e1;
}

.subsection-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b7280;
  margin: 1rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed #e5e7eb;
}

/* Ingredients */
.ingredients-list { list-style: none; }
.ingredient-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f4f1ec;
}
.ingredient-item:last-child { border-bottom: none; }
.ing-name   { font-size: 0.97rem; font-weight: 500; color: #1f2937; }
.ing-divider {
  flex: 1;
  height: 1px;
  border-bottom: 1px dotted #d1cec7;
  min-width: 1rem;
  margin: 0 0.25rem;
  align-self: center;
}
.ing-amount { font-size: 0.92rem; color: #4b5563; white-space: nowrap; }
.ing-notes  { font-size: 0.82rem; color: #9ca3af; }

/* Steps */
.steps-list { list-style: none; padding: 0; }
.step-item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid #f4f1ec;
  line-height: 1.7;
  align-items: flex-start;
}
.step-item:last-child { border-bottom: none; }
.step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: #f3ede3;
  color: #8a7f6e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.15rem;
}
.step-text { flex: 1; color: #1f2937; font-size: 0.97rem; }

/* Notes */
.notes-list { list-style: none; padding: 0; }
.notes-list li {
  padding: 0.35rem 0;
  color: #6b7280;
  font-size: 0.92rem;
  border-bottom: 1px solid #f4f1ec;
}
.notes-list li:last-child { border-bottom: none; }
