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

:root {
  --primary:    #0891B2;
  --primary-dk: #0E7490;
  --bg:         #F0FBFF;
  --surface:    #FFFFFF;
  --text:       #0C1A20;
  --muted:      #64748B;
  --border:     #BAE6FD;
  --topbar-bg:  #D4A017;
  --topbar-text:#3D2800;
  --highlight:  #FEF3C7;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(8,145,178,.1);
  --star:       #F59E0B;
  --danger:     #EF4444;
}

html.dark {
  --bg:         #0F172A;
  --surface:    #1E293B;
  --text:       #F1F5F9;
  --muted:      #94A3B8;
  --border:     #334155;
  --shadow:     0 2px 12px rgba(0,0,0,.4);
  --topbar-bg:  #B8860B;
  --highlight:  #2D3F55;
}

html { font-size: 16px; }

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

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; }
input, textarea, select { font: inherit; }
img { max-width: 100%; display: block; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
#app { max-width: 680px; margin: 0 auto; padding-top: 96px; padding-bottom: 80px; }

/* ─── Top bar ───────────────────────────────────────────────────────────────── */
.topbar-wrapper {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
}

.topbar {
  background: var(--topbar-bg);
  padding: 0 16px;
  height: 52px;
  display: flex; align-items: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(180,130,0,.3);
}

.topbar-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-weight: 800; font-size: 1.15rem; color: var(--topbar-text);
  white-space: nowrap; cursor: pointer;
}

.topbar-search {
  display: flex; align-items: center;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  padding: 8px 16px; gap: 8px;
}

.topbar-search input {
  border: none; background: none; outline: none; flex: 1;
  font-size: 16px; color: var(--text);
}
.topbar-search input::placeholder { color: var(--muted); }

.topbar-search .icon { font-size: 1rem; opacity: .6; }

.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ─── Hamburger dropdown ─────────────────────────────────────────────────────── */
.hamburger-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 190px; z-index: 200; overflow: hidden;
}

.hamburger-item {
  padding: 12px 16px; font-size: .92rem; cursor: pointer;
  transition: background .12s; white-space: nowrap;
  color: var(--text);
}
.hamburger-item:hover { background: var(--bg); }
.hamburger-item-danger { color: var(--danger); }
.hamburger-item-danger:hover { background: #FEE2E2; }

.hamburger-sep { border-top: 1px solid var(--border); margin: 4px 0; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 18px; border-radius: 999px; border: none;
  font-size: .9rem; font-weight: 600; transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-icon {
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.35);
  font-size: 1.1rem; color: var(--topbar-text);
}
.btn-icon:hover { background: rgba(255,255,255,.35); }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}

.recipe-card {
  display: grid; grid-template-columns: 88px 1fr;
  gap: 0; cursor: pointer; transition: transform .15s;
}
.recipe-card:hover { transform: translateY(-2px); }

.recipe-card-img {
  width: 88px; height: 88px; object-fit: cover;
  background: var(--border);
}
.recipe-card-img-placeholder {
  width: 88px; height: 88px; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--muted);
  flex-shrink: 0;
}

.recipe-card-body { padding: 12px 14px; min-width: 0; }
.recipe-card-title {
  font-weight: 700; font-size: .98rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recipe-card-desc {
  color: var(--muted); font-size: .82rem; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card-meta {
  margin-top: 6px; display: flex; align-items: center; gap: 10px;
  font-size: .8rem; color: var(--muted);
}

/* ─── Stars ─────────────────────────────────────────────────────────────────── */
.stars { display: flex; gap: 2px; }
.star { font-size: 1rem; color: var(--border); cursor: pointer; transition: color .1s; }
.star.filled, .star.active { color: var(--star); }
.star-display { font-size: .85rem; }
.stars-interactive .star:hover,
.stars-interactive .star:hover ~ .star { color: var(--star); }

/* ─── Section headers ───────────────────────────────────────────────────────── */
.section-header {
  padding: 20px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title { font-size: 1.05rem; font-weight: 700; }

/* ─── List ───────────────────────────────────────────────────────────────────── */
.recipe-list { display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }

/* ─── Recipe detail ──────────────────────────────────────────────────────────── */
/* ─── Wake lock knop ─────────────────────────────────────────────────────────── */
.wake-btn { transition: all .2s; }
.wake-btn .wake-icon { font-size: 1rem; }
.wake-btn.wake-active {
  background: #FEF3C7;
  border-color: #F59E0B;
  color: #92400E;
}
.wake-btn.wake-active .wake-icon { animation: pulse-sun 2s ease-in-out infinite; }

@keyframes pulse-sun {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

/* ─── Photo upload preview ───────────────────────────────────────────────────── */
.photo-preview {
  width: 100%; min-height: 160px; background: var(--surface);
  border-radius: var(--radius); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-top: 6px;
}
.photo-preview:empty::before {
  content: '🖼'; font-size: 3rem; opacity: .4;
}
.photo-preview-img {
  width: 100%; max-height: 280px; object-fit: cover; display: block;
}

.recipe-hero { position: relative; height: 240px; background: var(--border); }
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }
.recipe-hero-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 5rem; color: var(--muted);
}

.recipe-body { padding: 16px; }
.recipe-title { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.recipe-subtitle { color: var(--muted); margin-top: 4px; font-size: .95rem; }

.recipe-meta-row {
  display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap;
}
.recipe-meta-item { display: flex; align-items: center; gap: 5px; font-size: .88rem; color: var(--muted); }
.country-flag { height: 16px; width: auto; display: inline-block; vertical-align: middle; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; font-size: .78rem; color: var(--muted);
}
.tag.category { background: #E0F2FE; border-color: #7DD3FC; color: #0369A1; }

.section-label {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: 8px;
}

.ingredients-list { list-style: none; display: grid; gap: 0; }
.ing-row {
  display: grid;
  grid-template-columns: 3.5rem 4.5rem 1fr;
  align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.ing-row:last-child { border-bottom: none; }
.ing-qty  { font-weight: 600; text-align: right; padding-right: 6px; }
.ing-unit { color: var(--muted); font-size: .85rem; }
.ing-name { }

.description-text {
  white-space: pre-wrap; font-size: .95rem; line-height: 1.7; color: var(--text);
}

/* ─── Rating block ───────────────────────────────────────────────────────────── */
.rating-block {
  background: var(--bg); border-radius: var(--radius);
  padding: 16px; margin-top: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.rating-block .stars { font-size: 1.6rem; gap: 4px; }

/* ─── Comments ───────────────────────────────────────────────────────────────── */
.comment-form textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 14px; resize: vertical; min-height: 80px; outline: none;
  font-size: .92rem;
}
.comment-form textarea:focus { border-color: var(--primary); }

.comment-item {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }
.comment-author { font-weight: 700; font-size: .88rem; }
.comment-date { color: var(--muted); font-size: .78rem; margin-left: 8px; }
.comment-text { margin-top: 4px; font-size: .92rem; line-height: 1.5; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .88rem; font-weight: 600; }
.form-input, .form-select, .form-textarea {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 14px; outline: none; font-size: 16px;
  background: var(--surface); color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: .82rem; }

.form-page { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.form-page h2 { font-size: 1.3rem; font-weight: 800; }

/* ─── Ingredient rows ────────────────────────────────────────────────────────── */
.ing-row {
  display: grid; grid-template-columns: 70px 90px 1fr 36px;
  gap: 6px; align-items: center;
}
.ing-row input[type="number"], .ing-row input[type="text"] {
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none; font-size: 16px; width: 100%;
}
.ing-row input[type="number"]:focus, .ing-row input[type="text"]:focus { border-color: var(--primary); }

.unit-wrap { position: relative; }
.unit-input {
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none; font-size: 16px;
  width: 100%; cursor: pointer;
}
.unit-input:focus { border-color: var(--primary); }
.unit-dropdown {
  display: none;
  position: absolute; top: calc(100% + 2px); left: 0;
  min-width: 140px; max-height: 200px; overflow-y: auto;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
  z-index: 300;
}
.unit-option {
  padding: 8px 12px; font-size: .88rem; cursor: pointer;
  color: var(--text); white-space: nowrap;
}
.unit-option:hover, .unit-option-active { background: var(--highlight); }

/* ─── Chips (multi-select) ───────────────────────────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ─── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 24px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 20px;
}
.auth-title { font-size: 1.5rem; font-weight: 800; }
.auth-subtitle { color: var(--muted); font-size: .9rem; }
.auth-switch { text-align: center; font-size: .88rem; color: var(--muted); }
.auth-switch a { color: var(--primary); font-weight: 600; }

/* ─── Divider ────────────────────────────────────────────────────────────────── */
.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin: 16px 0;
}
.pagination-info {
  font-size: .85rem; color: var(--muted);
  min-width: 60px; text-align: center;
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: #1a1a1a; color: #fff; padding: 10px 20px;
  border-radius: 999px; font-size: .88rem; font-weight: 500;
  animation: slideUp .25s ease;
  white-space: nowrap;
}
.toast.error { background: var(--danger); }

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

/* ─── Loading ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Back button ────────────────────────────────────────────────────────────── */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: .9rem; color: var(--muted);
  background: none; border: none;
}
.back-btn:hover { color: var(--text); }

/* ─── Confirm dialog ─────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 0 16px;
}
.dialog {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px; width: 100%; max-width: 500px;
  display: flex; flex-direction: column; gap: 16px;
}
.dialog h3 { font-size: 1.1rem; font-weight: 700; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ─── About pagina ───────────────────────────────────────────────────────────── */
.about-card {
  padding: 24px; display: flex; flex-direction: column;
  align-items: center; text-align: center; gap: 6px;
}
.about-logo { font-size: 3.5rem; line-height: 1; }
.about-title { font-size: 1.6rem; font-weight: 800; }
.about-sub { color: var(--muted); font-size: .95rem; max-width: 320px; }
.about-features {
  list-style: none; display: flex; flex-direction: column;
  gap: 8px; text-align: left; width: 100%;
}
.about-features li { font-size: .92rem; }
.about-login-note {
  font-size: .9rem; color: var(--muted); padding: 12px 0;
}
.about-login-note a { color: var(--primary); font-weight: 600; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 500px) {
  .recipe-card-img, .recipe-card-img-placeholder { width: 110px; height: 110px; }
  .recipe-hero { height: 300px; }
}
