/* ===== CSS RESET & BASE ===== */
* {
  box-sizing: border-box;
}
/* Add this CSS to make the spinner arrows visible and functional */
.fractional-stepper {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.fractional-stepper::-webkit-outer-spin-button,
.fractional-stepper::-webkit-inner-spin-button {
    -webkit-appearance: inner-spin-button !important;
    opacity: 1 !important;
    height: 100% !important;
    cursor: pointer;
}

.fractional-stepper[readonly] {
    background-color: #f9f9f9;
    cursor: pointer;
}

.amount-input-container {
    position: relative;
    display: inline-block;
}
.fraction-btn,.suggestion-fraction-btn{
  padding: 10px !important;
}
.fraction-controls{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.amount-cell{
    padding: 16px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
}
.unit-select,.suggestion-unit-select{
    padding: 8px !important;
  border:1px solid black;
}


/* ===== CSS VARIABLES ===== */
:root {
  --primary-color: #4b6cff;
  --primary-dark: #3a5bef;
  --secondary-color: #2980b9;
  --secondary-dark: #1c5980;
  --danger-color: #e74c3c;
  --danger-dark: #c0392b;
  --success-color: #27ae60;
  --text-primary: #2c3e50;
  --text-secondary: #34495e;
  --text-muted: #666;
  --text-light: #999;
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-accent: #f8f9fa;
  --border-color: #9fbae4;
  --border-light: #f1f1f1;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

/* ===== MAIN CONTAINER ===== */
#meal-generator {
  max-width: 1200px;
  margin: var(--spacing-lg) auto;
  padding: 0 var(--spacing-md);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ===== SEARCH SECTION ===== */
.search-section {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  position: relative;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-lg);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.mg-input {
  padding: 12px var(--spacing-md);
  font-size: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
  font-family: inherit;
}

.mg-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(75, 108, 255, 0.1);
}

#meal-search {
  flex: 1;
}

#meal-filter-type {
  width: 160px;
  border:1px solid #ddd;
}

.mg-add-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border: none;
  padding: 14px var(--spacing-xl);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  white-space: nowrap;
}

.mg-add-btn:hover:not([disabled]) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.mg-add-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ===== TOOLTIP/DROPDOWN ===== */
.tooltip-list {
  display: none;
  position: absolute;
  top: calc(100% + var(--spacing-sm));
  left: var(--spacing-lg);
  right: var(--spacing-lg);
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
}

.tooltip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.tooltip-item:hover {
  background: var(--bg-secondary);
  transform: translateX(4px);
}

.tooltip-item.selected {
  background: linear-gradient(135deg, #eef7ff, #e3f2fd);
  border-left: 4px solid var(--primary-color);
  font-weight: 500;
}

.tooltip-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: var(--spacing-sm);
}

/* ===== LOADERS ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.mg-loader {
  position: absolute;
  right: 120px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(75, 108, 255, 0.1);
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
  z-index: 1001;
}

.btn-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.search-loader {
  position: absolute;
  right: var(--spacing-md);
  top: 29%;
  /* transform: translateY(-50%); */
  width: 16px;
  height: 16px;
  border: 2px solid rgba(75, 108, 255, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== TABLE SECTION ===== */
.table-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--border-color);
}

.table-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-section th,
.table-section td {
  padding: var(--spacing-md) 12px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.table-section thead th {
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-section tbody tr:hover {
  background: var(--bg-secondary);
}

.suggestion-section{
  max-width: 100vw;
  /* margin: 100px 0; */
  margin-bottom: var(--spacing-xl);
  background: var(--bg-primary);
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}
#dietary-select,#meal-source-select{
  border: 1px solid #ddd;
}
@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mg-contextual-message {
    z-index: 1000;
    position: relative;
}
.category-section:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.saved-meal:hover {
    background: #f0f0f0 !important;
    transition: background 0.3s ease;
}

.download-category-csv:hover{
    opacity: 0.8;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* NEW: Split Fraction Controls Styling */
.split-fraction-controls, .suggestion-split-fraction-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.whole-number-input, .suggestion-whole-number-input {
    width: 100px !important;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px;
}

.fraction-part, .suggestion-fraction-part {
    display: flex;
    align-items: center;
    gap: 2px;
}


.fraction-btn:hover, .suggestion-fraction-btn:hover {
    background: #e0e0e0;
}

.fraction-display, .suggestion-fraction-display {
    min-width: 20px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
}

.unit-display, .suggestion-unit-display {
    margin-left: 5px;
    font-size: 14px;
    color: #666;
}

/* ===== SAVE MEAL SECTION ===== */
#save-meal-section {
  max-width: 100vw;
  /* margin: 100px 0; */
  margin-bottom: var(--spacing-xl);
  background: var(--bg-primary);
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

#save-meal-section h3 {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary);
  font-weight: 700;
}

#save-meal-section label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--text-secondary);
  font-size: 14px;
}

#save-meal-section input[type="text"],
#save-meal-section select,
#save-meal-section textarea {
  width: 100%;
  padding: 12px var(--spacing-md);
  font-size: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-md);
  transition: all 0.3s ease;
  font-family: inherit;
  border: 1px solid var(--ast-border-color);
}
#meal-category{
  padding: 8px !important;
}
#meal-category option{
  font-size: 12px;
}

#save-meal-section input[type="text"]:focus,
#save-meal-section select:focus,
#save-meal-section textarea:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}

button.save-meal-btn {
  background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
  color: white;
  font-weight: 600;
  border: none;
  padding: 12px var(--spacing-lg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

button.save-meal-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ===== MENU SECTION ===== */
#menu {
  max-width: 100%;
  margin-top: var(--spacing-xl);
}

.menu-category {
  margin-bottom: var(--spacing-xl);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.menu-category > h4 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
  color: white;
  padding: var(--spacing-md) var(--spacing-lg);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.menu-category > h4::before {
  content: "🍽️";
  font-size: 1.1rem;
}

.menu-category .no-meals {
  font-style: italic;
  color: var(--text-light);
  padding: var(--spacing-lg);
  text-align: center;
}

.menu-category table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.menu-category table th {
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-weight: 600;
  padding: var(--spacing-md);
  border-bottom: 2px solid var(--border-color);
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.menu-category table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.menu-category table tbody tr:hover {
  background: var(--bg-secondary);
}

.menu-category .totals-row {
  font-weight: 700;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-top: 3px solid var(--secondary-color);
  color: var(--text-primary);
}

.menu-category button.remove-meal {
  background: var(--danger-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.menu-category button.remove-meal:hover {
  background: var(--danger-dark);
  transform: translateY(-1px);
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
  position: relative;
  width: 100%;
  height: 30px;
  background: #f0f0f0;
  border-radius: 15px;
  margin: 10px 0;
  cursor: pointer;
  border: 2px solid #ddd;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #8BC34A);
  border-radius: 13px;
  transition: width 0.3s ease, background 0.3s ease;
}
.progress-fill.over-target {
  background: linear-gradient(90deg, #ff9800, #f44336);
}
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: #333;
  font-size: 12px;
}
.progress-section {
  margin: 20px 0;
  padding: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f9f9f9;
}
.target-display {
  font-weight: bold;
  color: #666;
}
#suggestions-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}
#suggestions-table th, #suggestions-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: center;
}
#suggestions-table th {
  background: #f5f5f5;
}
#suggestion-totals, #suggestion-difference {
  margin: 10px 0;
  font-weight: bold;
}
.load-more-btn {
  background: #e3f2fd !important;
  border-top: 1px solid #ddd !important;
  font-style: italic;
  color: #1976d2 !important;
}
.load-more-btn:hover {
  background: #bbdefb !important;
}

/* ===== ACTIONS & BUTTONS ===== */
.table-actions,
.menu-actions {
  margin-top: var(--spacing-md);
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.table-actions button:hover,
.menu-actions button:hover {
  border-color: var(--secondary-color);
  color: var(--secondary-color);
  transform: translateY(-1px);
}

/* ===== TOAST NOTIFICATIONS ===== */
.mg-toast {
  position: relative;
  margin: var(--spacing-sm) 0;
  background: var(--text-primary);
  color: white;
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-weight: 500;
}

/* ===== UTILITIES ===== */
.no-results {
  color: var(--text-light);
  text-align: center;
  padding: var(--spacing-lg);
  font-style: italic;
}

#menu-totals {
  margin-top: var(--spacing-lg);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
  padding: 15px;
  background: var(--bg-accent);
  border-radius: var(--radius-md);
}

#suggestions-list {
  margin-top: var(--spacing-md);
}

#menu-display{
    max-width: 100vw;
  /* margin: 100px 0; */
  margin-bottom: var(--spacing-xl);
  background: var(--bg-primary);
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  #meal-generator {
    padding: 0 var(--spacing-sm);
  }
  
  .search-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  #meal-search,
  #meal-filter-type {
    width: 100%;
  }
  
  .mg-add-btn {
    justify-content: center;
  }
  
  .tooltip-list {
    left: var(--spacing-sm);
    right: var(--spacing-sm);
  }
  
  #save-meal-section,
  #menu {
    max-width: 100%;
  }
  
  .menu-actions,
  .table-actions {
    flex-direction: column;
  }
  
  .menu-category table th,
  .menu-category table td {
    padding: var(--spacing-sm);
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .menu-category > h4 {
    font-size: 1.1rem;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .table-section,
  .search-section,
  #save-meal-section {
    padding: var(--spacing-md);
  }
}
input,select,textarea{
    border:1px solid var(--border-color);
}
.delete-meal {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.delete-meal:hover {
  background: var(--danger-dark);
  transform: translateY(-1px);
}
button, .mg-add-btn, .delete-meal, .remove-meal {
  user-select: none;
}
input[type=range].mg-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #ddd; /* base color for empty part */
  outline: none;
}

/* WebKit (Chrome, Safari, Edge) */
input[type=range].mg-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #007bff var(--value, 50%), #ddd var(--value, 50%));
}

input[type=range].mg-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #007bff;
  cursor: pointer;
  margin-top: -5px; /* aligns thumb with track */
}

/* Firefox */
input[type=range].mg-range::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #ddd;
}

input[type=range].mg-range::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: #007bff; /* blue filled part */
}

input[type=range].mg-range::-moz-range-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #007bff;
  cursor: pointer;
}
.suggestion-amount-cell{
  display: flex;
}