/* ═══════════════════════════════════════════════════════════════
   Recipe Scale — style.css
   Dark/light via [data-theme="dark"] on <html>
═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:          #f8f7f4;
  --bg-card:     #ffffff;
  --bg-input:    #ffffff;
  --bg-hover:    #f2f1ee;
  --border:      #e0ddd8;
  --border-focus:#c8a96e;
  --text:        #1c1c1c;
  --text-muted:  #6b6560;
  --accent:      #c8783c;
  --accent-dark: #a85e28;
  --accent-light:#fdf0e7;
  --success:     #3d9970;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --radius:      10px;
  --radius-sm:   6px;
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:   'Cascadia Code', 'Consolas', monospace;
}

[data-theme="dark"] {
  --bg:          #1a1917;
  --bg-card:     #242220;
  --bg-input:    #2c2a28;
  --bg-hover:    #302e2b;
  --border:      #3a3835;
  --border-focus:#c8a96e;
  --text:        #e8e4de;
  --text-muted:  #928e87;
  --accent:      #d98c52;
  --accent-dark: #e8a070;
  --accent-light:#2d2218;
  --success:     #4db882;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,.4);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2 { font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.5rem; line-height: 1.2; }
h2 { font-size: 1rem; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-icon { font-size: 2rem; }
.app-title  { font-size: 1.25rem; color: var(--accent); }
.app-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }

.header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Main ───────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Input Panel ────────────────────────────────────────────── */
.input-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.ingredient-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.6;
}
.ingredient-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(200, 120, 60, 0.12);
}

.input-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ── Controls Bar ───────────────────────────────────────────── */
.controls-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.serving-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.serving-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.serving-field input[type="number"] {
  width: 70px;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s;
}
.serving-field input[type="number"]:focus {
  outline: none;
  border-color: var(--border-focus);
}

.serving-arrow {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
}

.factor-display {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  margin-top: 1.1rem;
}

.unit-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}
.control-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-toggle {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-toggle:not(:last-child) {
  border-right: 1px solid var(--border);
}
.btn-toggle:hover { background: var(--bg-hover); color: var(--text); }
.btn-toggle.active {
  background: var(--accent);
  color: #fff;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.btn-save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-save:hover { background: var(--accent-dark); }
.btn-cancel {
  background: transparent;
  color: var(--text-muted);
}
.btn-cancel:hover { background: var(--bg-hover); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover { opacity: 1; background: var(--bg-hover); }

.btn.copied {
  background: var(--success);
  color: #fff;
}

/* ── Lists Section ──────────────────────────────────────────── */
.lists-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.list-column {
  padding: 1rem;
  min-width: 0;
}

.column-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.list-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  color: var(--text-muted);
  font-size: 1.25rem;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.ingredient-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ingredient-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  min-height: 36px;
}
.ingredient-row:hover { background: var(--bg-hover); }

.ing-text {
  flex: 1;
  font-size: 0.9rem;
  word-break: break-word;
}

.no-scale-note {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.empty-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: 0.5rem;
}

/* ── Edit Form ──────────────────────────────────────────────── */
.edit-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}
.edit-form input {
  padding: 0.25rem 0.4rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
}
.edit-form input:focus {
  outline: none;
  border-color: var(--border-focus);
}
.edit-qty  { width: 60px; }
.edit-unit { width: 80px; }
.edit-name { flex: 1; min-width: 100px; }

/* ── Copy row ───────────────────────────────────────────────── */
.copy-row {
  display: flex;
  justify-content: flex-end;
}
#copy-btn {
  min-width: 180px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app-header { padding: 0.75rem 1rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .app-main { padding: 1rem; }

  .controls-bar { flex-direction: column; align-items: flex-start; }
  .unit-control  { margin-left: 0; }

  .lists-section {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .list-divider {
    padding: 0.5rem 1rem;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 1rem;
  }
}
