:root {
  --bg: #f0f3f6; 
  --bg-accent: #f8f9fb;
  --card-bg: #ffffff;
  --accent: #c96a3d;
  --accent-soft: #f3d6c2;
  --accent-deep: #8d4120;
  --text-main: #2f2924;
  --text-muted: #6b625b;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.12); 
  --shadow-card: 0 8px 20px rgba(0, 0, 0, 0.08); 

  --font-ui: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Merriweather', serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui); 
  color: var(--text-main);
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow-x: hidden;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1.5;
  background-color: var(--bg);
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.5), rgba(240, 243, 246, 0.9)),
    url('../img/background.png'); 
  background-attachment: fixed; 
  background-size: cover;
  background-position: center center;
}

.admin-body { padding-bottom: 3rem; }
.page { width: 100%; max-width: 980px; }

/* HEADER */
header { margin-bottom: 1.5rem; }

header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(2rem, 3.5vw, 2.8rem); 
  letter-spacing: 0.03em;
  position: relative;
  font-weight: 700;
}

header h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 65px;
  height: 4px; 
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #ffb88c);
}

header p { margin: 0; color: var(--text-muted); font-size: 1rem; }

/* KONTROLLKORT */
.controls-card {
  background: var(--card-bg); 
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); 
  padding: 1rem 1.25rem;
  margin-bottom: 1.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.3rem;
  align-items: center;
  border: 1px solid #e0e5ea;
}

.control-group { display: flex; flex-direction: column; gap: 0.25rem; min-width: 170px; }
.search-group { min-width: 210px; }
.admin-link-wrap { margin-left: auto; }

label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* INPUTS */
select, input[type="number"], input[type="text"], textarea, input[type="file"] {
  padding: 0.5rem 0.8rem; 
  font-size: 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid #d4d8de;
  outline: none;
  background-color: var(--card-bg);
  color: var(--text-main);
  transition: border-color 0.16s, box-shadow 0.16s, background-color 0.16s;
}

textarea { border-radius: 12px; resize: vertical; font-family: var(--font-ui); }
input[type="file"] { padding: 0.35rem 0.8rem; font-size: 0.9rem; }

select:focus, input[type="number"]:focus, input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(201, 106, 61, 0.15); 
  background-color: #fff;
}

/* Batch control */
.batch-input-group { display: flex; align-items: center; }
.batch-input-group input {
    text-align: center; border-radius: 0; width: 80px; 
    padding-left: 0.4rem; padding-right: 0.4rem; border-left: none; border-right: none; font-weight: 600;
}
.batch-input-group .batch-btn {
    padding: 0.5rem 0.7rem; font-size: 1.1rem; font-weight: 400; min-width: 40px; line-height: 1; 
}
.batch-input-group .batch-btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.batch-input-group .batch-btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* RECEPTKORT (DESIGN-LYFT) */
.recipe-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 1px solid #e0e5ea;
  overflow: hidden; /* Viktigt för Hero-bilden */
  padding: 0; /* Padding flyttad till inner-content */
}

/* Hero-bild som går kant-i-kant */
.hero-image-wrap {
  width: 100%;
  height: 300px; /* Fast höjd för snyggare layout */
  background: #f5e8dc;
  position: relative;
  overflow: hidden;
}

.hero-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Utility bar (knappar under bilden/titeln) */
.utility-bar {
  display: flex;
  gap: 0.8rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.icon-btn {
  background: transparent;
  border: 1px solid #d4d8de;
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: #f8f9fb;
  border-color: var(--accent);
  color: var(--accent-deep);
}

.icon-btn.active {
  background: #fff8f5;
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn.favorite-btn.active {
  color: #e63946; /* Rött hjärta */
  border-color: #e63946;
  background: #fff0f1;
}

/* Innehålls-wrapper (för att återfå paddingen vi tog bort från kortet) */
.recipe-content-padding {
  padding: 2rem 2.2rem 2.2rem;
}

.recipe-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.recipe-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem); 
  font-weight: 700;
  line-height: 1.2;
}

.badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

/* Klickbara taggar */
.badge {
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer; /* Indikerar klickbarhet */
  transition: transform 0.1s;
}
.badge:hover { transform: translateY(-1px); filter: brightness(0.95); }

.badge-outline {
  background: transparent;
  border: 1px solid var(--accent-soft);
  color: var(--accent);
  cursor: default; /* Ugnstiden är inte klickbar */
}
.badge-outline:hover { transform: none; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr);
  gap: 2.5rem; 
  margin-top: 1rem;
}

.section-title {
  margin-top: 0.1rem;
  margin-bottom: 0.8rem; 
  font-size: 1.2rem; 
  font-weight: 700;
  color: var(--accent-deep); 
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
}

.note { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.35rem; margin-bottom: 0.8rem; line-height: 1.4; }
.note.small { font-size: 0.8rem; }

/* INGREDIENSER (ZEBRA-RÄNDER) */
.ingredient-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.ingredient-list li {
    font-family: var(--font-body);
    font-size: 1.05rem; 
    line-height: 1.4;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    border-bottom: none; /* Tog bort strecket */
}

/* Varannan rad färgad */
.ingredient-list li:nth-child(odd) {
    background-color: #f7f9fb;
}

/* INSTRUKTIONER (COOKING MODE) */
.instruction-list-ol {
    margin: 0;
    padding-left: 0; /* Tar bort standard padding */
    list-style: none; /* Tar bort standard siffror för vi gör egna snygga */
    display: flex;
    flex-direction: column;
    gap: 0.8rem; 
}

.instruction-step {
    display: flex;
    gap: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, opacity 0.2s;
    border: 1px solid transparent;
}

.instruction-step:hover {
    background: #fffbf7;
    border-color: #f3d6c2;
}

/* "Bocka av" status */
.instruction-step.checked {
    opacity: 0.5;
    text-decoration: line-through;
    background: #f4f4f4;
    border-color: transparent;
}

.step-number {
    font-weight: 700;
    color: var(--accent);
    font-size: 1.1rem;
    min-width: 24px;
}

.step-text {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
}


/* TIPS */
.tips-wrap {
    margin-top: 2rem;
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--accent-soft);
    background: #fff8f5;
    border-radius: 8px;
}
.tips-content { font-family: var(--font-body); font-size: 0.95rem; color: var(--text-main); }


/* KNAPPAR */
.pill-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  padding: 0.5rem 1.1rem; border-radius: var(--radius-pill); text-decoration: none;
  border: 1px solid rgba(201, 106, 61, 0.4); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; background: #fff7f0; color: var(--accent-deep);
  transition: all 0.18s ease;
}
.pill-button.primary {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent)); 
  color: #fff; border-color: transparent; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}
.pill-button.secondary { background: rgba(255, 247, 240, 0.8); }
.pill-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18); }
.pill-button:active:not(:disabled) { transform: translateY(0); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12); }


/* ADMIN & RESPONSIVT */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.8rem; }
.admin-card { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 1.6rem 1.8rem 1.7rem; border: 1px solid #e0e5ea; }
.admin-card h2 { margin-top: 0; margin-bottom: 1.2rem; font-size: 1.8rem; }
.admin-subsection { padding-top: 0.8rem; border-top: 1px dashed rgba(0, 0, 0, 0.08); }
.admin-subsection:first-of-type { border-top: none; padding-top: 0; }
.admin-subsection h3, .admin-subsection h4 { margin-top: 0.5rem; margin-bottom: 0.5rem; color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.form-full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #eee; }
.image-preview-wrap { width: 100%; border-radius: 12px; overflow: hidden; background: #f5e8dc; border: 1px dashed rgba(0, 0, 0, 0.12); margin-top: 0.5rem; }
.image-preview-wrap img { display: block; width: 100%; height: auto; min-height: 40px; object-fit: cover; }
.admin-recipe-list, .admin-backup-list { list-style: none; padding-left: 0; margin: 0.5rem 0 0.8rem; font-size: 0.95rem; }
.admin-recipe-list li, .admin-backup-list li { padding: 0.3rem 0.1rem; border-bottom: 1px dashed rgba(0, 0, 0, 0.06); }
.admin-recipe-list li { cursor: pointer; transition: background 0.1s, padding 0.1s; }
.admin-recipe-list li:hover { background: rgba(255, 247, 240, 0.8); padding-left: 0.4rem; }

@media (max-width: 900px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  body { padding: 1rem; }
  .controls-card { padding: 0.9rem 1rem; }
  .recipe-content-padding { padding: 1.4rem 1.4rem 1.6rem; }
  .hero-image-wrap { height: 220px; }
  .content-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-link-wrap { margin-left: 0; }
  .control-group { min-width: 100%; }
  .batch-control-wrap .batch-input-group input { width: auto; flex-grow: 1; }
}

/* Bekräftelse-text */
.note.success {
  color: #15803d; /* En fin mörkgrön färg */
  background-color: #dcfce7; /* Ljusgrön bakgrund */
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  font-weight: 600;
  display: inline-block;
  margin-top: 1rem;
}
/* Snyggare bilduppladdning */
.image-upload-card {
  border: 2px dashed #d4d8de; /* Streckad kant */
  border-radius: 12px;
  background-color: #fafbfc;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.image-upload-card:hover {
  border-color: var(--accent);
  background-color: #fffbf7;
}

/* Bilden i förhandsvisningen */
.preview-img-styled {
  max-width: 100%;
  max-height: 250px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  object-fit: cover;
  display: none; /* Döljs om ingen bild finns */
}

/* Ikon/text när ingen bild är vald */
.placeholder-content {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.placeholder-icon {
  font-size: 2.5rem;
  opacity: 0.3;
}

/* Inledningstext i receptet */
.recipe-intro-text {
  width: 100%;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-style: italic;
  color: #555;
  line-height: 1.6;
}

/* Fix för mobila webbläsare som inte gillar display:none på inputs */
#ocrCameraInput, 
#ocrGalleryInput,
#recipeImageFile {
  display: block !important;
  opacity: 0;
  position: absolute;
  z-index: -1;
  width: 1px;
  height: 1px;
}