body {
  font-family: Arial, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.list-group-item {
  cursor: pointer;
}

#shopping-list .list-group-item {
  padding-left: 1.5rem;
}

.bg-light {
  background-color: #f8f9fa !important;
}

.serving-size-container {
  display: flex;
  align-items: center;
  min-width: 180px;
  justify-content: flex-end;
}

.serving-size {
  min-width: 80px;
  width: auto;
}

#global-serving-size {
  width: 100px;
  text-align: center;
}

/* Optional: Add some responsive behavior */
@media (max-width: 576px) {
  #global-serving-size {
    width: 80px;
  }
}

/* Add Recipe Form */
#ingredients-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 10px;
  border: 1px solid #dee2e6;
  padding: 10px;
  border-radius: 4px;
}

.ingredient-item {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Ingredients List */
.toggle-ingredients {
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
}

.collapse:not(.show) {
  display: none;
}

.collapsing {
  transition: height 0.15s ease;
}

#recipe-list .list-group-item {
  padding: 1rem 1.5rem; /* 16px top/bottom, 24px left/right */
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
}

#recipe-list .list-group-item:hover {
  background-color: #f8f9fa;
}

#add-recipe {
  padding-top: 20px;
}

#add-recipe .card {
  border: none;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.tab-content > .tab-pane {
  display: block;
  height: 0;
  overflow: hidden;
}

.tab-content > .active {
  height: auto;
  overflow: visible;
}

.nav-tabs {
  margin-bottom: 1rem;
  border-bottom: 1px solid #dee2e6;
}

.nav-link.active {
  font-weight: bold;
  border-bottom: 2px solid #0d6efd;
}

:root {
  --category-protein: #D79B7C;
  --category-produce: #7BC57F;
  --category-grains: #E4C580;
  --category-pasta: #F4E4C9;
  --category-dairy: #F0EDE5;
  --category-canned: #58B2DC;
  --category-baking: #9E8FB2;
  --category-frozen: #7BD3DC;
  --category-condiments: #C45A5A;
  --category-oils: #B7BB66;
  --category-spices: #B5651D;
  --category-beverages: #4A90E2;

  /* Aliases for dropdown */
  --category-protein-color: var(--category-protein);
  --category-produce-color: var(--category-produce);
  --category-grains-color: var(--category-grains);
  --category-pasta-color: var(--category-pasta);
  --category-dairy-color: var(--category-dairy);
  --category-canned-color: var(--category-canned);
  --category-baking-color: var(--category-baking);
  --category-frozen-color: var(--category-frozen);
  --category-condiments-color: var(--category-condiments);
  --category-oils-color: var(--category-oils);
  --category-spices-color: var(--category-spices);
  --category-beverages-color: var(--category-beverages);    
}

/* Shopping List Category Headers - Enhanced Styles */
#shopping-list > li[class*="category-"] {
  padding: 12px 15px;
  margin: 2px 0;
  border-radius: 4px;
}

/* Specific category colors */
#shopping-list > li.category-produce {
  background-color: color-mix(in srgb, var(--category-produce) 15%, white);
  border-left: 5px solid var(--category-produce);
}

#shopping-list > li.category-protein {
  background-color: color-mix(in srgb, var(--category-protein) 15%, white);
  border-left: 5px solid var(--category-protein);
}

#shopping-list > li.category-dairy-alternatives {
  background-color: color-mix(in srgb, var(--category-dairy) 15%, white);
  border-left: 5px solid var(--category-dairy);
}

#shopping-list > li.category-grains-breads {
  background-color: color-mix(in srgb, var(--category-grains) 15%, white);
  border-left: 5px solid var(--category-grains);
}

#shopping-list > li.category-canned-jarred {
  background-color: color-mix(in srgb, var(--category-canned) 15%, white);
  border-left: 5px solid var(--category-canned);
}

#shopping-list > li.category-baking-dry-goods {
  background-color: color-mix(in srgb, var(--category-baking) 15%, white);
  border-left: 5px solid var(--category-baking);
}

#shopping-list > li.category-pasta-noodles {
  background-color: color-mix(in srgb, var(--category-pasta) 15%, white);
  border-left: 5px solid var(--category-pasta);
}

#shopping-list > li.category-condiments-sauces {
  background-color: color-mix(in srgb, var(--category-condiments) 15%, white);
  border-left: 5px solid var(--category-condiments);
}

#shopping-list > li.category-oils-vinegars {
  background-color: color-mix(in srgb, var(--category-oils) 15%, white);
  border-left: 5px solid var(--category-oils);
}

#shopping-list > li.category-spices-seasonings {
  background-color: color-mix(in srgb, var(--category-spices) 15%, white);
  border-left: 5px solid var(--category-spices);
}

#shopping-list > li.category-frozen-foods {
  background-color: color-mix(in srgb, var(--category-frozen) 15%, white);
  border-left: 5px solid var(--category-frozen);
}

#shopping-list > li.category-beverages {
  background-color: color-mix(in srgb, var(--category-beverages) 15%, white);
  border-left: 5px solid var(--category-beverages);
}

/* Additional styling for better visibility */
.rounded {
  border-radius: 4px;
}
.p-2 {
  padding: 0.5rem;
}
.mb-1 {
  margin-bottom: 0.25rem;
}

.category-select option {
  padding: 8px 12px;
  border-left: 7px solid transparent;
}

/* Highlight selected option */
.category-select option:checked {
  font-weight: bold;
  background-color: rgba(0,0,0,0.05);
}

/* Recipe Ingredients List - Category Labels */
#recipe-list .badge.bg-secondary {
  background-color: transparent !important;
  color: inherit;
  padding-left: 0.5rem;
  position: relative;
}

/* Recipe Ingredients List Items */
#recipe-list li[class*="category-"] {
  padding-left: 1rem;
  position: relative;
}

#recipe-list li[class*="category-"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  border-radius: 2px;
}

/* Apply category colors */
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-protein {
  background-color: color-mix(in srgb, var(--category-protein) 15%, white);
  border-right: 8px solid var(--category-protein);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-produce {
  background-color: color-mix(in srgb, var(--category-produce) 15%, white);
  border-right: 8px solid var(--category-produce);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-grains-breads {
  background-color: color-mix(in srgb, var(--category-grains) 15%, white);
  border-right: 8px solid var(--category-grains);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-pasta-noodles {
  background-color: color-mix(in srgb, var(--category-pasta) 15%, white);
  border-right: 8px solid var(--category-pasta);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-dairy-alternatives {
  background-color: color-mix(in srgb, var(--category-dairy) 15%, white);
  border-right: 8px solid var(--category-dairy);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-canned-jarred {
  background-color: color-mix(in srgb, var(--category-canned) 15%, white);
  border-right: 8px solid var(--category-canned);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-baking-dry-goods {
  background-color: color-mix(in srgb, var(--category-baking) 15%, white);
  border-right: 8px solid var(--category-baking);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-frozen-foods {
  background-color: color-mix(in srgb, var(--category-frozen) 15%, white);
  border-right: 8px solid var(--category-frozen);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-condiments-sauces {
  background-color: color-mix(in srgb, var(--category-condiments) 15%, white);
  border-right: 8px solid var(--category-condiments);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-oils-vinegars {
  background-color: color-mix(in srgb, var(--category-oils) 15%, white);
  border-right: 8px solid var(--category-oils);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-spices-seasonings {
  background-color: color-mix(in srgb, var(--category-spices) 15%, white);
  border-right: 8px solid var(--category-spices);
}
#recipe-list [id^="ingredients-"] > ul > li.p-2.mb-1.rounded.category-beverages {
  background-color: color-mix(in srgb, var(--category-beverages) 15%, white);
  border-right: 8px solid var(--category-beverages);
}


#recipe-list li.category-protein::before {
  background-color: var(--category-protein);
}
#recipe-list li.category-produce::before {
  background-color: var(--category-produce);
}
#recipe-list li.category-grains-breads::before {
  background-color: var(--category-grains);
}
#recipe-list li.category-pasta-noodles::before {
  background-color: var(--category-pasta);
}
#recipe-list li.category-dairy-alternatives::before {
  background-color: var(--category-dairy);
}
#recipe-list li.category-canned-jarred::before {
  background-color: var(--category-canned);
}
#recipe-list li.category-baking-dry-goods::before {
  background-color: var(--category-baking);
}
#recipe-list li.category-frozen-foods::before {
  background-color: var(--category-frozen);
}
#recipe-list li.category-condiments-sauces::before {
  background-color: var(--category-condiments);
}
#recipe-list li.category-oils-vinegars::before {
  background-color: var(--category-oils);
}
#recipe-list li.category-spices-seasonings::before {
  background-color: var(--category-spices);
}
#recipe-list li.category-beverages::before {
  background-color: var(--category-beverages);
}

/* Ingredients List Grid Layout */
.ingredient-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 20px;
  align-items: center;
}

.ingredient-amount {
    text-align: right;
    font-weight: 500;
    min-width: 120px; /* Prevents wrapping */
    white-space: nowrap; /* Keeps text on one line */
    font-size: 1rem; /* Slightly larger font */
    padding-right: 8px; /* Adds breathing room */
    padding-left: 8px;
}

.ingredient-category {
justify-self: end; /* Right-align category */
min-width: 120px; /* Prevent collapse */
text-align: right; /* Align text to the right edge */
padding-left: 10px; /* Add space between name and category */
}

.is-invalid {
border-color: #dc3545 !important;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
background-repeat: no-repeat;
background-position: right calc(0.375em + 0.1875rem) center;
background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

datalist {
position: absolute;
background: white;
border: 1px solid #ddd;
max-height: 200px;
overflow-y: auto;
}

/* Style the datalist dropdown */
option {
padding: 4px 8px;
}

/* Add category color hints */
option::before {
content: "";
display: inline-block;
width: 12px;
height: 12px;
margin-right: 8px;
background: var(--category-color);
border-radius: 2px;
}

/* Generate dynamic colors for each category */
option[data-category-class="protein"]::before {
background: var(--category-protein);
}
option[data-category-class="produce"]::before {
background: var(--category-produce);
}
option[data-category-class="grains"]::before {
background: var(--category-grains);
}
option[data-category-class="pasta"]::before {
background: var(--category-pasta);
}
option[data-category-class="dairy"]::before {
background: var(--category-dairy);
}
option[data-category-class="canned"]::before {
background: var(--category-canned);
}
option[data-category-class="baking"]::before {
background: var(--category-baking);
}
option[data-category-class="frozen"]::before {
background: var(--category-frozen);
}
option[data-category-class="condiments"]::before {
background: var(--category-condiments);
}
option[data-category-class="oils"]::before {
background: var(--category-oils);
}
option[data-category-class="spices"]::before {
background: var(--category-spices);
}
option[data-category-class="beverages"]::before {
background: var(--category-beverages);
}

/* Loading state styles */
datalist option[value=""] {
color: #6c757d;
font-style: italic;
padding: 8px 12px;
}

/* Error state */
datalist option[value=""]:contains("Error") {
color: #dc3545;
}

/* No results state */
datalist option[value=""]:contains("No matches") {
color: #6c757d;
}

.unit-highlight {
animation: highlight-fade 2s ease-out;
border-color: #28a745 !important;
box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

@keyframes highlight-fade {
0% { background-color: rgba(40, 167, 69, 0.2); }
100% { background-color: transparent; }
}

.amount-updated {
animation: amount-update-pulse 1s ease;
background-color: rgba(40, 167, 69, 0.1);
border-color: #28a745;
}

@keyframes amount-update-pulse {
0% { transform: scale(1); }
50% { transform: scale(1.02); box-shadow: 0 0 5px rgba(40, 167, 69, 0.5); }
100% { transform: scale(1); }
}

/* Ensure inputs can't go below 1 */
input[type="number"].serving-size {
min: 1;
}

.quantity-updated {
animation: quantity-update 0.5s ease;
color: #28a745;
font-weight: bold;
}

@keyframes quantity-update {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}

/* Shopping List Strikethrough Styles */
#shopping-list .list-group-item {
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

#shopping-list .list-group-item.struck {
  color: #6c757d;
  background-color: #f8f9fa;
}

#shopping-list .list-group-item.struck .badge {
  opacity: 0.7;
  background-color: #dc3545 !important;
}

#shopping-list .list-group-item.struck::after {
  content: "";
  position: absolute;
  left: 15px;
  right: 15px;
  top: 50%;
  height: 2px;
  background: red;
}

#shopping-list .list-group-item:hover {
  background-color: #f1f1f1;
}

/* Enhanced Recipe Checkbox Styles - Force override */
.form-check-input.recipe-checkbox {
    transform: scale(0.5) !important;
    margin-right: 0.75rem !important;
    cursor: pointer;
    border: 2px solid #6c757d !important;
}

/* Green checked state - using multiple selectors for specificity */
.form-check-input.recipe-checkbox:checked {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}

.form-check-input.recipe-checkbox:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.25) !important;
}

/* Remove Bootstrap's default padding that might interfere */
.form-check .form-check-input {
    margin-left: 0;
    float: none;
}

.unit-toggle .btn {
  min-width: 80px;
  padding: 0.375rem 0.5rem;
}

.unit-toggle .btn.active {
  background-color: #0d6efd;
  color: white;
  border-color: #0d6efd;
}

/* Mobile-first responsive styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  padding: 0.5rem;
}

/* Responsive typography */
@media (max-width: 768px) {
  body {
      font-size: 14px;
  }
  
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.3rem; }
  
  .card, .list-group-item {
      padding: 0.75rem;
  }
}

/* Responsive layout adjustments */
.nav-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.nav-link {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

/* Recipe list items */
.list-group-item {
  padding: 1rem 0.75rem;
}

.ingredient-item {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ingredient-item > * {
  flex: 1 1 45%;
  min-width: 120px;
}

/* Form controls */
.form-control, .form-select {
  font-size: inherit;
  padding: 0.375rem 0.75rem;
}

/* Shopping list items */
#shopping-list .list-group-item {
  padding: 0.75rem;
  flex-direction: column;
  align-items: flex-start;
}

/* Buttons */
.btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Tab content */
.tab-content {
  padding: 0.5rem 0;
}

/* Utility classes for mobile */
.mobile-stack {
  flex-direction: column !important;
  gap: 0.5rem !important;
}

.mobile-full-width {
  width: 100% !important;
  max-width: 100% !important;
}

/* @media (max-width: 576px) { */
  /* Stack elements on very small screens */
  /* .d-flex:not(.mobile-keep-row) {
      flex-direction: column;
      gap: 0.5rem;
  } */
  
/* Recipe checkboxes */
.recipe-checkbox {
    margin-right: 0.5rem;
    transform: scale(1.3);
    accent-color: #4CAF50;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Container for better spacing and hover effects */
.list-group-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.list-group-item:hover {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}

/* Selected recipe styling */
.list-group-item.selected {
    border-color: #4CAF50;
    background-color: #f8fff9;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.1);
}

.list-group-item.selected:hover {
    background-color: rgba(40, 167, 69, 0.15);
}

/* Checkbox container alignment */
.list-group-item .form-check {
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

/* Ensure the flex layout works well */
.list-group-item .d-flex {
    width: 100%;
    align-items: flex-start;
}

/* Make sure the checkbox is properly aligned */
.form-check-input {
    margin-top: 0.25rem;
}
  
/* Button groups */
.btn-group {
    width: 30%;
}  
  
.btn-group .btn {
    flex: 1;
}

.edit-recipe, .delete-recipe {
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s;
}

.edit-recipe:hover {
  color: var(--bs-primary) !important;
}

.delete-recipe:hover {
  color: var(--bs-danger) !important;
}

/* For mobile */
@media (max-width: 576px) {
  .edit-recipe, .delete-recipe {
      font-size: 0.7rem;
      padding: 0.2rem;
  }
}

.hover-bg-light:hover {
    background-color: #f8f9fa;
}

.btn-group .btn-outline-secondary:not(.active) {
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

.btn-group .btn-outline-primary:not(.active) {
    background-color: #f8f9fa !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}

.btn-group .btn.active {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

.amount.is-valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.amount.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6.4.4.4-.4'/%3e%3cpath d='M6 7v5'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.amount-hint {
    font-size: 0.875em;
}

.category-border-protein { border-left: 4px solid var(--category-protein) !important; }
.category-border-produce { border-left: 4px solid var(--category-produce) !important; }
.category-border-grains-breads { border-left: 4px solid var(--category-grains) !important; }
.category-border-pasta-noodles { border-left: 4px solid var(--category-pasta) !important; }
.category-border-dairy-alternatives { border-left: 4px solid var(--category-dairy) !important; }
.category-border-canned-jarred { border-left: 4px solid var(--category-canned) !important; }
.category-border-baking-dry-goods { border-left: 4px solid var(--category-baking) !important; }
.category-border-frozen-foods { border-left: 4px solid var(--category-frozen) !important; }
.category-border-condiments-sauces { border-left: 4px solid var(--category-condiments) !important; }
.category-border-oils-vinegars { border-left: 4px solid var(--category-oils) !important; }
.category-border-spices-seasonings { border-left: 4px solid var(--category-spices) !important; }
.category-border-beverages { border-left: 4px solid var(--category-beverages) !important; }

.category-select {
    transition: border-left-color 0.3s ease;
}

/* FORCE GREEN CHECKBOX */
input[type="checkbox"].recipe-checkbox {
    transform: scale(1.5) !important;
    margin-right: 0.75rem !important;
    cursor: pointer !important;
    border: 2px solid #6c757d !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 1.2em !important;
    height: 1.2em !important;
    border-radius: 0.25em !important;
    background-color: white !important;
}

input[type="checkbox"].recipe-checkbox:checked {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 75% 75% !important;
}

input[type="checkbox"].recipe-checkbox:focus {
    outline: none !important;
    box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.25) !important;
}

/* MOBILE INGREDIENT OVERFLOW FIX - FORCE OVERRIDE */
@media (max-width: 768px) {
    #recipe-list .list-group-item {
        padding: 0.75rem 1rem; /* 12px top/bottom, 16px left/right */
    }
    
    #recipe-list .list-group-item:hover {
        padding: 0.75rem 1rem; /* Keep same on hover */
    }

    #recipe-list .ingredient-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
        padding-left: 8px;
    }
    
    #recipe-list .ingredient-amount,
    #recipe-list .ingredient-name,
    #recipe-list .ingredient-category {
        text-align: left !important;
        min-width: auto !important;
        width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    
    #recipe-list .ingredient-amount {
        font-weight: bold;
        font-size: 1rem;
    }
    
    #recipe-list .ingredient-name {
        font-size: 1rem;
        padding: 0 !important;
    }
    
    #recipe-list .ingredient-category {
        font-size: 0.9rem;
        opacity: 0.7;
        padding: 0 !important;
    }
    
    /* Also fix the parent containers */
    #recipe-list .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    #recipe-list .flex-grow-1.ms-3 {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* PWA Install Button Styles */
#pwa-install-button {
  background: linear-gradient(135deg, #28a745, #20c997) !important;
  border: none !important;
  color: white !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  animation: pulse 2s infinite !important;
}

#pwa-install-button:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3) !important;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* PWA Standalone Mode */
.pwa-standalone .navbar-toggler,
.pwa-standalone .install-promo {
  display: none !important;
}

/* PWA Toast Notifications */
.pwa-toast {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  max-width: 300px;
  word-wrap: break-word;
}

.pwa-toast-success {
  background-color: #28a745 !important;
}

.pwa-toast-error {
  background-color: #dc3545 !important;
}

.pwa-toast-info {
  background-color: #17a2b8 !important;
}

/* iOS PWA Styles */
.ios-standalone {
  padding-top: env(safe-area-inset-top); /* Notch safe area */
  padding-bottom: env(safe-area-inset-bottom);
}

/* iOS Install Button */
#pwa-install-button.ios-install {
  background: linear-gradient(135deg, #007AFF, #5856D6) !important; /* iOS blue */
}

/* iOS Instructions Modal */
#ios-install-modal h3 {
  color: #007AFF;
  margin-bottom: 15px;
}

#ios-install-modal ol {
  text-align: left;
  margin: 15px 0;
  padding-left: 20px;
}

#ios-install-modal li {
  margin-bottom: 10px;
  line-height: 1.5;
}

/* Filter Styles - SIMPLIFIED */
#filter-container {
    transition: all 0.3s ease;
}

/* Mobile: hidden by default */
@media (max-width: 768px) {
    #filter-container {
        display: none;
    }
    
    #filter-container.visible {
        display: block;
    }
    
    #filter-toggle-btn {
        display: block !important;
    }
}

/* Desktop: always visible, hide toggle button */
@media (min-width: 769px) {
    #filter-container {
        display: block !important;
    }
    
    #filter-toggle-btn {
        display: none !important;
    }
}

/* Style for formatted instructions */
.instructions-content {
    padding-right: 10px;
    font-size: 1rem; /* Base size for desktop */
    counter-reset: step-counter;
}

.instruction-step {
    counter-increment: step-counter;
    margin-bottom: 12px;
    padding-left: 28px;
    position: relative;
    line-height: 1.5;
}

.instruction-step:before {
    content: counter(step-counter) ".";  /* Display counter */
    position: absolute;
    left: 0;
    color: #4CAF50;
    font-weight: 500;
    width: 24px;
    text-align: right;
    margin-right: 8px;
}

/* .step-number {
    position: absolute;
    left: 0;
    color: #4CAF50;
    font-weight: 500;
    width: 24px;
    text-align: right;
    margin-right: 8px;
} */

/* Mobile styles */
@media (max-width: 768px) {
    .instructions-content {
        font-size: 0.9rem; /* Smaller font on mobile */
    }
    
    .instruction-step {
        margin-bottom: 10px; /* Slightly less spacing on mobile */
        padding-left: 26px;
    }
    
    .step-number {
        width: 22px;
        font-size: 0.85rem; /* Slightly smaller numbers */
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .instructions-content {
        font-size: 0.85rem; /* Even smaller on very small screens */
    }
    
    .instruction-step {
        margin-bottom: 8px;
        padding-left: 24px;
    }
    
    .step-number {
        width: 20px;
        font-size: 0.8rem;
    }
}

/* Scrollbar styling (keep this for all devices) */
.instructions-content::-webkit-scrollbar {
    width: 6px;
}

.instructions-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.instructions-content::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 10px;
}

.instructions-content::-webkit-scrollbar-thumb:hover {
    background: #45a049;
}

/* Numbered steps style */
.step-list {
    counter-reset: step-counter;
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.step-item {
    position: relative;
    padding-left: 10px;
    margin-bottom: 12px;
    min-height: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.step-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Color code categories if desired */
.ingredient-item[data-category="Produce"] {
    border-left-color: var(--category-produce);
}

.ingredient-item[data-category="Protein"] {
    border-left-color: var(--category-protein);
}

.ingredient-item[data-category="Grains & Breads"] {
    border-left-color: var(--category-grains);
}

.ingredient-item[data-category="Dairy & Alternatives"] {
    border-left-color: var(--category-dairy);
}

.ingredient-item[data-category="Spices & Seasonings"] {
    border-left-color: var(--category-spices);
}

.ingredient-item[data-category="Condiments & Sauces"] {
    border-left-color: var(--category-condiments);
}

.ingredient-item[data-category="Pasta & Noodles"] {
    border-left-color: var(--category-pasta);
}

.ingredient-item[data-category="Canned & Jarred"] {
    border-left-color: var(--category-canned);
}

.ingredient-item[data-category="Baking & Dry Goods"] {
    border-left-color: var(--category-baking);
}

.ingredient-item[data-category="Frozen Foods"] {
    border-left-color: var(--category-frozen);
}

.ingredient-item[data-category="Beverages"] {
    border-left-color: var(--category-beverages);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Recent recipes styles */
.recent-recipe-card {
    transition: all 0.2s;
    border-left: 3px solid #4CAF50;
}

.recent-recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

.badge.category-badge,
.category-badge,
.badge.bg-secondary.category-badge {
    background-color: rgba(108, 117, 125, 0.08) !important;
    color: #5a6268 !important;
    border-radius: 10px !important;
    padding: 4px 10px !important;
    font-size: 0.75em !important;
    font-weight: 400 !important;
    border: 1px solid rgba(108, 117, 125, 0.1) !important;
}

/* Step editing styles */
.step-item-edit {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: all 0.2s;
}

.step-item-edit:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.step-text-input {
    resize: vertical;
    min-height: 80px;
}

.step-number-edit {
    font-size: 0.9em;
    font-weight: bold;
}

/* Auth styles */
.auth-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    margin-left: 10px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-status.authenticated {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-status.anonymous {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert {
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
}

.alert.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.auth-toggle {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.auth-toggle button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

#loginBtn {
    background: #667eea;
    color: white;
}

#logoutBtn {
    background: #f0f0f0;
    color: #333;
}

/* ai limits */
.ai-limit-banner {
    margin: 1rem 0;
    border-radius: 8px;
    padding: 1rem;
}

.ai-limit-banner.warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.ai-limit-banner.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.ai-limit-banner .upgrade-link {
    font-weight: bold;
    margin-left: 5px;
}

/* Make sure alerts look good */
.alert {
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* ============================================
   AI CHAT STYLES
   ============================================ */

/* Main chat container */
.chat-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    height: auto;
}

/* Messages container */
.messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 16px; /* Default font size for desktop */
    line-height: 1.5;
}

/* Message bubbles */
.message {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    width: auto;
    min-width: 20%;
}

/* AI message */
.ai-message {
    background: #e0e0e0;
    color: #333;
    margin-right: auto;
}

/* User message (you'll add this dynamically) */
.user-message {
    background: #4CAF50;
    color: white;
    margin-left: auto;
    text-align: right;
}

/* Welcome message */
.welcome-message {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    color: #666;
    font-style: italic;
}

/* Loading indicator */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: #666;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

/* Input area */
.input-area {
    display: flex;
    padding: 0;
    background: white;
    border-top: none;
    gap: 10px;
}

.ai-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 16px;
}

.ai-input:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
}

.send-ai-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.send-ai-btn:hover {
    background: #45a049;
}

/* Recent recipes section */
#recent-ai-recipes .card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

#recent-ai-recipes .card-body {
    max-height: 200px;
    overflow-y: auto;
}

/* AI recipes container */
#ai-recipes-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

/* Animation for loading spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   MOBILE OPTIMIZATIONS for AI Chat
   ============================================ */

@media (max-width: 768px) {
    /* 1. Reduce font size for better readability on mobile */
    .messages,
    .message,
    .ai-message,
    .user-message,
    .welcome-message,
    .ai-input {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    /* 2. Make messages stretch wider on mobile */
    .messages {
        padding: 12px !important;
        margin: 10px 0 !important;
        height: 350px !important; /* Slightly smaller on mobile */
    }
    
    .message {
        max-width: 92% !important;  /* Much wider on mobile */
        min-width: 85% !important;
        width: auto !important;
        margin-left: 2% !important;
        margin-right: 2% !important;
    }
    
    .ai-message {
        margin-right: auto;
        margin-left: 0 !important;
    }
    
    .user-message {
        margin-left: auto;
        margin-right: 0 !important;
    }
    
    /* 3. Adjust input area for mobile */
    .input-area {
        flex-direction: column;
        gap: 10px;
        padding: 10px 0 !important;
    }
    
    .ai-input {
        width: 100% !important;
        padding: 10px 15px !important;
        font-size: 16px !important; /* Keep input text readable */
        border-radius: 20px !important;
    }
    
    .send-ai-btn {
        width: 100% !important;
        justify-content: center;
        padding: 12px !important;
        border-radius: 20px !important;
    }
    
    /* 4. Adjust loading spinner */
    .loading-spinner {
        width: 25px !important;
        height: 25px !important;
    }
    
    /* 5. Recent recipes adjustments */
    #recent-ai-recipes .card-body {
        max-height: 150px !important; /* Smaller on mobile */
        font-size: 13px !important;
    }
    
    #recent-ai-recipes .card-header h5 {
        font-size: 16px !important;
    }
    
    /* 6. Remove unnecessary margins/padding */
    .chat-container {
        padding: 0 5px !important;
    }
    
    #ai-recipes-container {
        padding: 10px !important;
        margin-top: 15px !important;
    }
}

/* Extra small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    .messages {
        height: 300px !important;
        padding: 8px !important;
    }
    
    .message {
        padding: 8px 12px !important;
        max-width: 95% !important;
        min-width: 90% !important;
    }
    
    .ai-input {
        font-size: 15px !important;
    }
    
    .send-ai-btn span {
        font-size: 15px !important;
    }
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.category-count {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.btn.active .category-count {
    background-color: rgba(24, 209, 18, 0.393) !important;
}

#filter-indicator {
    font-size: 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem !important;
}

.update-banner.with-margin {
  margin-bottom: 20px;
}

/* El wrapper asegura que todo esté contenido */
.filters-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

/* El contenedor con scroll */
.filter-scroll-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Los botones en inline-flex para que no se rompan */
.filter-scroll-container .filter-buttons {
    display: inline-flex;
    flex-wrap: nowrap;
    min-width: min-content; /* Los botones ocupan su tamaño natural */
}

/* En desktop, volvemos al comportamiento normal */
@media (min-width: 768px) {
    .filter-scroll-container {
        overflow-x: visible;
    }
    
    .filter-scroll-container .filter-buttons {
        display: flex;
        flex-wrap: wrap;
    }
}

/* Opcional: estilizar scrollbar */
.filter-scroll-container::-webkit-scrollbar {
    height: 4px;
}

.filter-scroll-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Settings */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
}

.settings-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row label {
    font-weight: 600;
    color: #555;
}

.settings-value {
    color: #333;
}

.plan-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.plan-badge {
    text-align: center;
}

#current-plan-name {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

.plan-badge[data-plan="free"] #current-plan-name { background: #6c757d; color: white; }
.plan-badge[data-plan="starter"] #current-plan-name { background: #17a2b8; color: white; }
.plan-badge[data-plan="pro"] #current-plan-name { background: #ff9800; color: white; }
.plan-badge[data-plan="premium"] #current-plan-name { background: #9c27b0; color: white; }
.plan-badge[data-plan="lifetime"] #current-plan-name { background: #4caf50; color: white; }
.plan-badge[data-plan="family"] #current-plan-name { background: #e91e63; color: white; }

.btn-primary {
    background: #ff9800;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #e68900;
}

.btn-danger, .btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-danger { background: #dc3545; color: white; }
.btn-secondary { background: #6c757d; color: white; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.status-badge.active { background: #d4edda; color: #155724; }
.status-badge.cancelled { background: #f8d7da; color: #721c24; }

#next-billing-info, #cancel-info {
    margin: 8px 0;
    font-size: 0.9rem;
    color: #666;
}

.info-box {
    background: #e3f2fd;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-icon {
    font-size: 1.2rem;
}

/* Hide Google Anchor Ads for ALL plans except starter */
/* This targets pro, premium, lifetime, family, and free (if you choose) */
body.premium-user #anchor-ad,
body.premium-user [id*="anchor-ad"],
body.premium-user .adsbygoogle[data-ad-format="anchor"] {
    display: none !important;
}

/* Optional: Add bottom padding only for users who see ads (starter/free) */
body:not(.premium-user) {
    padding-bottom: 70px; /* Space for anchor ad on mobile */
}

@media (min-width: 768px) {
    body:not(.premium-user) {
        padding-bottom: 90px; /* Space for anchor ad on desktop */
    }
}