* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--light);
  color: var(--dark);
  line-height: 1.6;
}

/* ===== HEADER ===== */

header {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  padding: 1.5rem 0;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== CONTAINER ===== */

.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

/* ===== SIDEBAR STYLES ===== */

.sidebar {
  width: 280px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 1rem 1.25rem;
  position: sticky;
  top: 1rem;
  height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
}

.sidebar-left { order: 1; }
.main-content { order: 2; flex: 1 1 auto; min-width: 0; }
.sidebar-right { order: 3; }

.sidebar h2 {
  margin-bottom: 1rem;
  color: var(--primary);
  font-size: 1.5rem;
}

.sidebar h3 {
  margin-bottom: 0.5rem;
  color: var(--dark);
}

/* ===== INGREDIENTS GRID ===== */

.ingredients-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  margin-top: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.5rem;
}

.ingredient-category {
  margin-bottom: 0.35rem;
  padding: 0.1rem 0;
}

.ingredient-category:last-child {
  border-bottom: none;
}

.category-title {
  font-weight: 600;
  color: var(--primary);
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.95rem;
}

.category-toggle {
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.35rem 0.25rem 0.35rem 0;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}

.category-toggle:focus {
  outline: 2px solid rgba(255, 94, 98, 0.6);
  outline-offset: 2px;
}
.category-toggle:hover {
  background: #f2f2f7;
}
.category-toggle[aria-expanded="true"] {
  background: #f7f7f9;
}
.category-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.category-toggle::before {
  content: '▸';
  line-height: 1;
  color: var(--primary);
  transform: rotate(0deg);
  transition: transform 0.2s ease;
  margin-right: 0.25rem;
}

.category-panel {
  padding-top: 0.35rem;
  padding-left: 0.75rem; /* indentation only, no borders */
  margin-top: 0.15rem;
}

.ingredient-category.collapsed .category-panel {
  display: none;
}

.ingredient-item {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.25rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.ingredient-item:hover {
  background-color: #f5f5f5;
}

.ingredient-item input {
  margin-right: 0.5rem;
}

.ingredient-item label {
  font-size: 0.875rem;
}

.deselect-btn {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s;
  width: 100%;
  margin-top: auto;
  align-self: flex-start;
}

.deselect-btn:hover {
  background-color: #5a6268;
}

/* ===== MAIN CONTENT ===== */

.main-content {
  flex: 1;
}

.recipe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.recipe-actions-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  background: #fff;
  border: none;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.view-btn + .view-btn {
  border-left: 1px solid #ddd;
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
}

.view-btn:focus {
  outline: 2px solid rgba(255, 94, 98, 0.6);
  outline-offset: 2px;
}

.recipe-count {
  background-color: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 1.1rem;
}

/* ===== RECIPE TABS ===== */

.recipe-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #ddd;
  flex-wrap: wrap;
}

.recipe-tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
}

.recipe-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: bold;
}

.recipe-tab:hover {
  background-color: rgba(255, 94, 98, 0.1);
}

/* ===== RECIPE GRID ===== */

.recipe-grid {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  overflow-anchor: none;
}

.recipe-card {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  position: relative;
  width: 100%;
}

.recipe-image {
  cursor: pointer;
}

.recipe-card:hover {
  transform: translateY(-5px);
}

.scroll-anchoring .recipe-card:hover {
  transform: none !important;
}

.recipe-categories {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: calc(100% - 20px);
  z-index: 10;
}

.recipe-category {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: bold;
  color: white;
  text-transform: capitalize;
}

.category-default {
  background-color: #6c757d;
}

.recipe-image {
  height: 200px;
  background-size: cover;
  background-position: center;
}

.recipe-content {
  padding: 1.5rem;
}

.recipe-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--dark);
}

.recipe-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #666;
}

.ingredients-list {
  margin-top: 1rem;
}

.ingredients-list h3,
.instructions-list h3 {
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.ingredients-list ul,
.instructions-list ol {
  margin-left: 1.5rem;
}

.instructions-list {
  margin-top: 1rem;
}

.recipe-details {
  display: none;
}

.recipe-card.expanded .recipe-details {
  display: block;
}

/* ===== LIST VIEW ===== */

.recipe-grid.list-view {
  display: block;
}

.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recipe-card.list-item {
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.recipe-card.list-item .recipe-image {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.recipe-card.list-item .recipe-content {
  padding: 0.75rem 1rem;
  flex: 1 1 auto;
}

.recipe-card.list-item .recipe-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #555;
}

.recipe-card.list-item .recipe-details {
  display: block;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform-origin: top;
  transition: max-height 220ms ease, opacity 180ms ease;
  margin-top: 0;
}

.recipe-card.list-item.expanded .recipe-details {
  max-height: 2000px;
  opacity: 1;
  margin-top: 0.5rem;
}

/* ===== NO RECIPES MESSAGE ===== */

.no-recipes {
  text-align: center;
  padding: 2rem;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.matching-count {
  display: inline-block;
  background-color: var(--primary);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.recipe-column {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-width: 0;
  overflow-anchor: none;
}

/* ===== FOOTER ===== */

footer {
  background-color: var(--dark);
  color: white;
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-copy {
  opacity: 0.9;
  font-size: 0.9rem;
  flex: 1 1 auto;
  text-align: left;
}

/* ===== LANGUAGE PICKER (SEGMENTED) ===== */

.language-picker {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  background: transparent;
  color: #ffffff;
  border: 0;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lang-btn + .lang-btn {
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.lang-btn[aria-pressed="true"] {
  background: #ffffff;
  color: #111111;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lang-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}


/* ===== RIGHT SIDEBAR (SHOPPING LIST) ===== */

.sidebar-right {
  display: flex;
  flex-direction: column;
}

.sidebar-right h2 {
  margin-bottom: 1rem;
  flex: 0 0 auto;
}

.cart-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

.copy-cart-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
  flex: 0 0 auto;
  transition: background-color 0.3s;
}

.copy-cart-btn:hover {
  filter: brightness(0.95);
}

.copy-cart-btn:focus {
  outline: 2px solid rgba(255, 94, 98, 0.6);
  outline-offset: 2px;
}

.cart-item-header {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

hr.cart-divider {
  border: 0;
  border-top: 1px solid #eee;
  margin: 0.35rem 0 0.35rem;
}

.cart-ingredients {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0.75rem;
}

.cart-ingredients li {
  padding: 0.125rem 0;
}

.cart-ingredients .amt {
  color: #555;
  margin-right: 0.35rem;
}

.cart-all-set {
  color: #888;
  font-style: italic;
}

.cart-empty {
  color: #888;
  font-style: italic;
  padding-top: 0.5rem;
}

/* Remove from cart button (red square with minus) */
.remove-from-cart-btn {
  background: #dc3545;
  color: white;
  border: 2px solid #dc3545;
  border-radius: 4px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1;
  transition: all 0.2s ease;
  position: relative;
}

.remove-from-cart-btn:hover {
  background: #c82333;
  border-color: #c82333;
}

.remove-from-cart-btn:focus {
  outline: none;
  border-color: #bd2130;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3);
}

/* SVG minus icon inside */
.remove-from-cart-btn .icon-minus {
  width: 16px;
  height: 16px;
  pointer-events: none;
  display: block;
}

/* ===== ADD TO CART BUTTON ===== */

.recipe-actions {
  margin-top: 1rem;
}

.add-to-cart-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.add-to-cart-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.add-to-cart-btn:focus {
  outline: 2px solid rgba(255, 94, 98, 0.6);
  outline-offset: 2px;
}

/* ===== TOAST ===== */

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== RECIPE META ROW ===== */

.recipe-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.recipe-meta-row .add-to-cart-btn {
  flex: 0 0 auto;
}

.recipe-meta-row .recipe-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0;
}

.recipe-grid:not(.list-view) .recipe-meta-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.recipe-grid:not(.list-view) .recipe-meta-row .recipe-meta {
  order: 1;
  gap: 1rem;
  margin-bottom: 0;
}

.recipe-grid:not(.list-view) .recipe-meta-row .add-to-cart-btn {
  order: 2;
  margin-top: 0.25rem;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .footer-copy {
    text-align: center;
  }

  .language-picker {
    align-self: center;
  }
}

@media (max-width: 480px) {
  .recipe-meta-row {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .recipe-meta-row .recipe-meta {
    width: 100%;
    justify-content: space-between;
  }
  
  .language-picker {
    font-size: 0.95rem;
  }
  
  .lang-btn {
    padding: 0.3rem 0.6rem;
  }
}