/* ==========================================================================
   Nourished & Simple — Whole Food Meal Planner Stylesheet
   ========================================================================== */

:root {
  --primary: #4a6741;         /* Deep Sage Green */
  --primary-light: #eef3eb;   /* Light Sage Tint */
  --primary-dark: #354c2e;
  --accent: #c46845;          /* Warm Terracotta */
  --accent-light: #fdf2ed;
  --bg-main: #fbfaf8;         /* Warm Off-White Cream */
  --bg-card: #ffffff;
  --text-dark: #222823;
  --text-muted: #667066;
  --border-color: #e5e4de;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== NAVBAR ==================== */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 2rem;
  line-height: 1;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--primary-dark);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
}

.nav-btn.active {
  color: var(--primary-dark);
  background: var(--primary-light);
}

/* ==================== BUTTONS & CONTROLS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  border-color: var(--border-color);
  background: #ffffff;
  color: var(--text-dark);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-dark);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.select-input, input[type="text"] {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.2s;
}

.select-input:focus, input[type="text"]:focus {
  border-color: var(--primary);
}

/* ==================== LAYOUT ==================== */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ==================== PLANNER TAB ==================== */
.generator-card {
  margin-bottom: 24px;
}

.generator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.generator-header h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--primary-dark);
}

.generator-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.generator-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-group.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title-row h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--text-dark);
}

.hint-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==================== PLANNED MEALS GRID ==================== */
.planned-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.meal-plan-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.meal-plan-card:hover {
  box-shadow: var(--shadow-md);
}

.meal-card-img-wrap {
  position: relative;
  width: 100%;
  height: 180px;
  background: #eee;
  overflow: hidden;
}

.meal-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.meal-plan-card:hover .meal-card-img {
  transform: scale(1.03);
}

.meal-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.meal-card-source {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(34, 40, 35, 0.85);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.meal-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.meal-card-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
  line-height: 1.3;
}

.meal-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.meal-card-actions {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== SHOPPING LIST SECTION ==================== */
.shopping-card {
  margin-top: 24px;
}

.shopping-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.shopping-header h3, .shopping-header h2 {
  font-family: var(--font-serif);
  color: var(--primary-dark);
}

.shopping-header-actions {
  display: flex;
  gap: 8px;
}

.shopping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.aisle-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.aisle-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ingredient-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.86rem;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.06);
  cursor: pointer;
  user-select: none;
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-item input[type="checkbox"] {
  margin-top: 4px;
  cursor: pointer;
  accent-color: var(--primary);
}

.ingredient-item.checked {
  color: #99a299;
  text-decoration: line-through;
}

/* ==================== CATALOG TAB ==================== */
.catalog-toolbar {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 1rem;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  font-size: 0.95rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
}

.clear-search-btn {
  position: absolute;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.catalog-results-header {
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.catalog-recipe-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.catalog-recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.catalog-img-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  background: #f0f0eb;
}

.catalog-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.catalog-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.catalog-footer {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
}

/* ==================== RECIPE MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  position: relative;
  padding: 30px;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.modal-meta {
  display: flex;
  gap: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-img-wrap {
  width: 100%;
  max-height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--primary-dark);
  margin: 18px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}

.modal-ingredients-list {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 18px;
}

.modal-ingredients-list li {
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.modal-instructions-list {
  list-style: decimal;
  padding-left: 20px;
  margin-bottom: 20px;
}

.modal-instructions-list li {
  margin-bottom: 12px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* ==================== PRINTABLE STYLES (@media print) ==================== */
.print-only {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .main-content {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .print-header {
    margin-bottom: 18px;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
  }

  .print-header h1 {
    font-size: 18pt;
    font-family: serif;
    margin-bottom: 4px;
  }

  .print-date {
    font-size: 9pt;
    color: #555;
  }

  /* Planned meals summary row */
  .planned-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
  }

  .meal-plan-card {
    border: 1px solid #999 !important;
    box-shadow: none !important;
    flex: 1 1 30%;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .meal-card-img-wrap, .meal-card-actions {
    display: none !important;
  }

  .meal-card-body {
    padding: 10px !important;
  }

  .meal-card-title {
    font-size: 11pt !important;
  }

  /* Shopping list print layout */
  .shopping-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 24px;
    page-break-after: always; /* Ensure recipe details start on next page */
    break-after: page;
  }

  .shopping-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .aisle-card {
    border: 1px solid #ccc !important;
    background: transparent !important;
    padding: 10px !important;
    page-break-inside: avoid;
  }

  .aisle-title {
    font-size: 10pt !important;
    font-weight: bold;
    border-bottom: 1px solid #000;
    padding-bottom: 4px;
  }

  .ingredient-item {
    font-size: 8.5pt !important;
    padding: 3px 0 !important;
    border-bottom: 0.5px solid #eee !important;
  }

  /* Printable Full Recipes */
  .recipe-instructions-print-section {
    margin-top: 20px;
  }

  .print-recipe-block {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 26px;
    border-bottom: 1px solid #bbb;
    padding-bottom: 18px;
  }

  .print-recipe-title {
    font-size: 14pt;
    font-family: serif;
    font-weight: bold;
    margin-bottom: 4px;
  }

  .print-recipe-meta {
    font-size: 9pt;
    color: #444;
    margin-bottom: 10px;
  }

  .print-recipe-cols {
    display: flex;
    gap: 20px;
  }

  .print-recipe-ing {
    flex: 1;
    font-size: 8.5pt;
  }

  .print-recipe-inst {
    flex: 2;
    font-size: 8.5pt;
  }
}
