: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;
}

/* ------------------------------------------------ */
/* BAS & TYPOGRAFI */
/* ------------------------------------------------ */

* {
  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;

  /* --- NY BAKGRUNDSSTYLING --- */
  background-color: var(--bg); /* Fallback-färg */
  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);
  opacity: 1;
}

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

/* ------------------------------------------------ */
/* KONTROLLKORT (index.html) */
/* ------------------------------------------------ */

.controls-card {
  /* Ren vit bakgrund för kontrast mot den kalla bakgrunden */
  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; /* Tydligare, kallare kant */
}

.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;
}

/* ------------------------------------------------ */
/* FORM-ELEMENT & 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; /* Renare kant */
  outline: none;
  background-color: var(--card-bg); /* Ren vit */
  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;
  transform: none; 
}

/* Satsräknare (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;
    /* Säkerställer att knapparna har samma höjd som input */
    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 (index.html) */
/* ------------------------------------------------ */

.recipe-card {
  /* Ren vit bakgrund */
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 2rem 2.2rem 2.2rem; 
  border: 1px solid #e0e5ea;
}

/* Receptbild */

.recipe-image-wrap {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 1.5rem; 
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15); 
  background: #f5e8dc;
}

.recipe-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 150px;
  object-fit: cover;
}

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

.recipe-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem); 
  font-weight: 700;
}

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

.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;
}

.badge-outline {
  background: transparent;
  border: 1px solid var(--accent-soft);
  color: var(--accent);
}

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

.section-title {
  margin-top: 0.1rem;
  margin-bottom: 0.8rem; 
  font-size: 1.2rem; 
  font-weight: 700;
  color: var(--accent-deep); 
}

.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;
}

/* ------------------------------------------------ */
/* LISTOR & TEXT (index.html) */
/* ------------------------------------------------ */

/* Ingredienslista */
.ingredient-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem; 
}

.ingredient-list li {
    font-family: var(--font-body); /* Brödtextfont för ingredienser */
    font-size: 1.05rem; 
    line-height: 1.35;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.05); 
    padding-bottom: 0.7rem;
}

/* Instruktioner (Använder nu <ol>) */
.instruction-list-ol {
    margin: 0;
    padding-left: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem; 
    list-style-position: outside;
}

.instruction-list-ol li {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
    padding-left: 0.5rem;
}

/* Tips-sektionen */
.tips-wrap {
    margin-top: 2rem;
    padding: 1rem;
    border-left: 4px solid var(--accent-soft);
    background: #fff8f5;
    border-radius: 0 12px 12px 0;
}
.tips-wrap .section-title {
    font-size: 1rem;
    margin-bottom: 0.2rem;
    color: var(--accent);
}
.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:
    background 0.18s ease,
    transform 0.1s ease,
    box-shadow 0.18s ease,
    border-color 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-LAYOUT (admin.html) */
/* ------------------------------------------------ */

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); 
  gap: 1.8rem;
}

.admin-card {
  /* Ren vit bakgrund */
  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-group textarea {
  border-radius: 12px;
}

.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;
}

/* Bildförhandsvisning i admin */

.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;
}

/* Listor i admin */

.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;
}

/* OCR-panel i admin */

.ocr-panel {
  background: #fff9f4;
  border-radius: 14px;
  border: 1px dashed rgba(201, 106, 61, 0.45); 
  padding: 0.7rem 1rem 1rem;
}

.ocr-panel[open] {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); 
}

.ocr-panel > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.1rem 0;
  color: var(--accent-deep);
}

.ocr-panel > summary::-webkit-details-marker {
  display: none;
}

.ocr-summary-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.ocr-upload-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0.8rem 0 0.8rem;
  flex-wrap: wrap;
}

.ocr-raw-wrap {
    margin-top: 1rem;
}

.ocr-textarea {
  width: 100%;
  margin-top: 0.5rem;
  font-family: monospace; /* Monospaced font för råtext */
  font-size: 0.95rem;
}

.ocr-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ------------------------------------------------ */
/* RESPONSIVITET */
/* ------------------------------------------------ */

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  body {
    padding: 1.1rem;
  }

  .controls-card {
    padding: 0.9rem 1rem;
  }

  .recipe-card {
    padding: 1.4rem 1.4rem 1.6rem;
  }

  .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;
  }
}