:root {
  --primary: #4caf50;
  --primary-dark: #388e3c;
  --primary-light: #c8e6c9;
  --secondary: #2196f3;
  --light: #f5f5f5;
  --dark: #333;
  --gray: #e0e0e0;
  --gray-light: #f5f7fa;
  --danger: #f44336;
  --warning: #ff9800;
  --breakfast: #ffe082;
  --lunch: #81c784;
  --dinner: #64b5f6;
  --snack: #ba68c8;
  --carbs: #ff9800;
  --protein: #2196f3;
  --fat: #f44336;
  --background: #f8fafc;
  --card-bg: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--background);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
.top-bar {
  background-color: var(--card-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 12px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--gray);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 15px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo i {
  color: var(--primary);
  font-size: 1.8rem;
}

.app-title h1 {
  font-size: 1.6rem;
  color: var(--dark);
  font-weight: 700;
}

.app-title .subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
}

.app-controls {
  display: flex;
  gap: 15px;
  align-items: center;
}

.settings-btn {
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 3px 8px rgba(76, 175, 80, 0.2);
}

.settings-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.plan-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--light);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.action-btn:hover {
  background-color: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.action-btn:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.tooltip {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background-color: var(--dark);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 10;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent var(--dark) transparent;
}

.total-calories-display {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  text-align: center;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.total-calories-display .value {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.total-calories-display .label {
  font-size: 0.85rem;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.week-view-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.week-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gray-light);
}

.week-nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

.week-nav-btn {
  background-color: var(--card-bg);
  border: 2px solid var(--gray);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text);
  font-size: 1.1rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.week-nav-btn:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(76, 175, 80, 0.2);
}

.week-view {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  gap: 20px;
  padding: 10px 5px 25px 5px;
}

.day-column {
  min-width: 400px;
  width: 400px;
  background-color: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.day-column:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.day-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 18px;
  text-align: center;
  font-weight: 700;
  font-size: 1.3rem;
  position: relative;
  overflow: hidden;
}

.day-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(40px, -40px);
}

.day-content {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.day-total {
  text-align: center;
  margin-bottom: 20px;
  padding: 15px;
  background-color: rgba(76, 175, 80, 0.05);
  border-radius: 10px;
  border: 2px solid rgba(76, 175, 80, 0.1);
}

.day-total .calories {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 5px;
}

.day-total .target {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.day-total .remaining {
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 5px;
}

.remaining-positive {
  background-color: rgba(76, 175, 80, 0.15);
  color: var(--primary-dark);
}

.remaining-negative {
  background-color: rgba(244, 67, 54, 0.15);
  color: var(--danger);
}

.day-macros {
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background-color: var(--gray-light);
  margin: 0 0 20px 0;
  border-radius: 10px;
  border: 1px solid var(--gray);
}

.day-macro-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.day-macro-value {
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 3px;
}

.day-macro-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.carbs-value {
  color: var(--carbs);
}

.protein-value {
  color: var(--protein);
}

.fat-value {
  color: var(--fat);
}

.progress-bar {
  height: 8px;
  background-color: #e9ecef;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.calories-fill {
  background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.meal-section {
  margin-bottom: 25px;
}

.meal-header {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.meal-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 5px;
}

.breakfast-header {
  background-color: var(--breakfast);
  color: #5d4037;
  border-left: 5px solid #ffa000;
}

.breakfast-header::before {
  background-color: #ffa000;
}

.lunch-header {
  background-color: var(--lunch);
  color: #1b5e20;
  border-left: 5px solid #388e3c;
}

.lunch-header::before {
  background-color: #388e3c;
}

.dinner-header {
  background-color: var(--dinner);
  color: #0d47a1;
  border-left: 5px solid #1976d2;
}

.dinner-header::before {
  background-color: #1976d2;
}

.snack-header {
  background-color: var(--snack);
  color: #4a148c;
  border-left: 5px solid #7b1fa2;
}

.snack-header::before {
  background-color: #7b1fa2;
}

.meal-calories {
  font-size: 0.95rem;
  font-weight: 700;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 5px 10px;
  border-radius: 6px;
  backdrop-filter: blur(5px);
}

.food-list {
  min-height: 80px;
}

.food-item {
  background-color: var(--card-bg);
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  cursor: grab;
  transition: all 0.3s ease;
  position: relative;
  border: 1px solid #f0f0f0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.04);
}

.food-item:hover {
  background-color: #f8fdf8;
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.food-item.dragging {
  opacity: 0.7;
  transform: scale(0.98);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.food-name {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 1rem;
  color: var(--text);
}

.food-details {
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.food-portion {
  font-weight: 700;
  color: var(--primary);
}

.food-calories {
  font-weight: 700;
  color: var(--text);
}

.food-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-end;
}

.food-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #888;
  padding: 5px 10px;
  border-radius: 5px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.food-action-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--primary);
}

.clone-btn {
  color: var(--secondary);
}

.clone-btn:hover {
  color: #0b7dda;
  background-color: rgba(33, 150, 243, 0.1);
}

.delete-btn {
  color: var(--danger);
}

.delete-btn:hover {
  color: #d32f2f;
  background-color: rgba(244, 67, 54, 0.1);
}

.add-food-btn {
  width: 100%;
  padding: 12px;
  background-color: var(--card-bg);
  border: 2px dashed #d1d9e6;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 12px;
  color: #777;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.add-food-btn:hover {
  background-color: #f5f9ff;
  border-color: var(--primary);
  color: var(--primary);
}

.drop-zone {
  min-height: 70px;
  border: 2px dashed #e2e8f0;
  border-radius: 10px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a0aec0;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background-color: #fcfdfe;
}

.drop-zone.active {
  border-color: var(--primary);
  background-color: rgba(76, 175, 80, 0.1);
  color: var(--primary);
  border-style: solid;
}

.drag-handle {
  position: absolute;
  top: 12px;
  right: 12px;
  color: #d1d9e6;
  cursor: grab;
  font-size: 1rem;
}

.food-item:hover .drag-handle {
  color: #a0aec0;
}

/* Modali */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
  backdrop-filter: blur(5px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: var(--card-bg);
  margin: 50px auto;
  width: 90%;
  max-width: 850px;
  border-radius: 16px;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
}

.modal-header h3 {
  font-size: 1.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.close-modal {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.modal-body {
  padding: 30px;
  flex-grow: 1;
  overflow-y: auto;
}

/* Modal per impostazioni */
.settings-modal {
  max-width: 700px;
}

.settings-tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-light);
  margin-bottom: 30px;
  gap: 5px;
}

.settings-tab {
  padding: 14px 24px;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  border-radius: 8px 8px 0 0;
}

.settings-tab:hover {
  color: var(--primary);
  background-color: rgba(76, 175, 80, 0.05);
}

.settings-tab.active {
  color: var(--primary);
}

.settings-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: var(--primary);
  border-radius: 3px 3px 0 0;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-panel h4 {
  font-size: 1.3rem;
  margin-bottom: 25px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gray-light);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.setting-item {
  display: flex;
  flex-direction: column;
}

.setting-item label {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
}

.setting-item .calories-info {
  font-weight: normal;
  color: var(--text-light);
  font-size: 0.9rem;
}

.setting-item input {
  padding: 14px;
  border: 2px solid var(--gray);
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: var(--light);
}

.setting-item input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  outline: none;
  background-color: white;
}

.snacks-control {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  padding: 20px;
  background-color: var(--gray-light);
  border-radius: 10px;
  border-left: 5px solid var(--primary);
}

.snacks-control label {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.snacks-control input {
  width: 100px;
  padding: 12px;
  border: 2px solid var(--gray);
  border-radius: 10px;
  font-size: 1rem;
  background-color: var(--light);
}

.plan-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.plan-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 25px 20px;
  background-color: var(--gray-light);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text);
}

.plan-control-btn:hover {
  background-color: var(--primary-light);
  transform: translateY(-5px);
  color: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.15);
}

.plan-control-btn i {
  font-size: 2rem;
  margin-bottom: 12px;
  color: var(--primary);
}

.plan-control-btn span {
  font-weight: 600;
  font-size: 1rem;
}

.settings-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid var(--gray-light);
}

.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.btn-primary {
  background-color: var(--secondary);
  color: white;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-primary:hover {
  background-color: #0b7dda;
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(33, 150, 243, 0.4);
}

.btn-success {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-success:hover {
  background-color: var(--primary-dark);
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(76, 175, 80, 0.4);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.btn-danger:hover {
  background-color: #d32f2f;
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(244, 67, 54, 0.4);
}

.btn-warning {
  background-color: var(--warning);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.btn-warning:hover {
  background-color: #e68900;
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(255, 152, 0, 0.4);
}

.hidden {
  display: none !important;
}

footer {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  font-size: 0.85rem;
  background-color: var(--card-bg);
  border-top: 1px solid var(--gray);
  margin-top: 20px;
}

.empty-meal {
  text-align: center;
  color: #a0aec0;
  padding: 25px;
  font-style: italic;
  font-size: 0.95rem;
  border: 2px dashed #e2e8f0;
  border-radius: 10px;
  background-color: #fcfdfe;
}

.meal-selection {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.meal-btn {
  padding: 12px 22px;
  background-color: var(--gray-light);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  color: var(--text);
}

.meal-btn.active {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}

.search-container {
  margin-bottom: 25px;
}

.search-container input {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--gray);
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background-color: var(--light);
}

.search-container input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  outline: none;
  background-color: white;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
  font-size: 1.1rem;
}

.loading i {
  margin-right: 12px;
}

/* Modal per dettaglio alimento */
.food-detail-modal .modal-content {
  max-width: 600px;
}

.food-detail-view {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.food-detail-header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--gray-light);
}

.food-detail-info h4 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 700;
}

.food-detail-brand {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 5px;
}

.food-detail-location {
  font-size: 0.95rem;
  color: var(--text-light);
  background-color: var(--gray-light);
  padding: 8px 15px;
  border-radius: 8px;
  display: inline-block;
}

.food-detail-macros {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 10px;
}

.macro-detail-card {
  background-color: var(--gray-light);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.macro-detail-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-light);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.macro-detail-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 5px;
}

.macro-detail-label {
  font-size: 0.9rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.calories-card {
  grid-column: span 2;
  background: linear-gradient(135deg, #f6fcf6, #e8f5e9);
  border-color: var(--primary-light);
}

.portion-control {
  background-color: var(--gray-light);
  padding: 25px;
  border-radius: 12px;
  border-left: 5px solid var(--primary);
}

.portion-control h5 {
  margin-bottom: 15px;
  color: var(--text);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.portion-input-group {
  display: flex;
  align-items: center;
  gap: 15px;
}

.portion-input-group input {
  width: 120px;
  padding: 14px;
  border: 2px solid var(--gray);
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  background-color: white;
}

.portion-input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
  outline: none;
}

.portion-input-group span {
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.food-detail-modal .modal-footer {
  padding: 25px 30px;
  background-color: var(--gray-light);
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

/* Scrollbar styling */
.week-view::-webkit-scrollbar {
  height: 12px;
}

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

.week-view::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.week-view::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

.day-content::-webkit-scrollbar {
  width: 10px;
}

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

.day-content::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 10px;
}

.day-content::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .day-column {
    min-width: 380px;
    width: 380px;
  }
}

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .app-header {
    width: 100%;
    justify-content: space-between;
  }

  .app-controls {
    width: 100%;
    justify-content: space-between;
  }

  .week-view {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .day-column {
    width: 100%;
    min-width: 100%;
  }

  .modal-content {
    margin: 20px auto;
    width: 95%;
  }

  .settings-grid,
  .plan-controls {
    grid-template-columns: 1fr;
  }
}

/* Stili specifici per il modal di aggiunta alimenti */
.food-modal .modal-content {
  max-width: 850px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.food-modal .modal-header {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  padding: 24px 30px;
  position: relative;
  overflow: hidden;
}

.food-modal .modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23000000' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
  opacity: 0.1;
}

.food-modal .modal-header h3 {
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.food-modal .modal-header h3 i {
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.2);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.food-modal .close-modal {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(5px);
}

.food-modal .close-modal:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg) scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.food-modal .modal-body {
  padding: 0;
  background: #f8fafc;
}

/* Sezione selezione pasto */
.meal-selection-section {
  padding: 25px 30px 20px;
  background: white;
  border-bottom: 1px solid #e2e8f0;
}

.meal-selection-section h4 {
  font-size: 1.1rem;
  color: #2d3748;
  margin-bottom: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.meal-selection {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.meal-btn {
  padding: 14px 24px;
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.meal-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.meal-btn i,
.meal-btn span {
  position: relative;
  z-index: 1;
}

.meal-btn i {
  font-size: 1.1rem;
}

.meal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  border-color: #cbd5e0;
  color: #2d3748;
}

.meal-btn.active {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: white;
  border-color: #4caf50;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.25);
}

.meal-btn.active::before {
  opacity: 1;
}

.meal-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.35);
}

.breakfast-btn i {
  color: #ff9800;
}
.lunch-btn i {
  color: #4caf50;
}
.dinner-btn i {
  color: #2196f3;
}
.snack-btn i {
  color: #9c27b0;
}

.meal-btn.active i {
  color: white;
}

/* Sezione ricerca */
.search-section {
  padding: 25px 30px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.search-container {
  position: relative;
}

.search-container i {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #a0aec0;
  font-size: 1.2rem;
  z-index: 2;
}

.search-container input {
  width: 100%;
  padding: 18px 20px 18px 55px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  font-size: 1.05rem;
  transition: all 0.3s ease;
  background: white;
  color: #2d3748;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.search-container input:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.15);
  background: white;
}

.search-container input::placeholder {
  color: #a0aec0;
  font-weight: 500;
}

/* Sezione risultati ricerca */
.results-section {
  padding: 0 30px 25px;
  background: #f8fafc;
  max-height: 400px;
  overflow-y: auto;
}

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

.product-card {
  background: white;
  border: 2px solid #edf2f7;
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.product-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(76, 175, 80, 0.1),
    rgba(46, 125, 50, 0.1)
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.product-card:hover {
  transform: translateY(-5px);
  border-color: #4caf50;
  box-shadow: 0 12px 30px rgba(76, 175, 80, 0.15);
}

.product-card:hover::before {
  opacity: 1;
}

.product-card.selected {
  border-color: #4caf50;
  background: linear-gradient(
    135deg,
    rgba(76, 175, 80, 0.05),
    rgba(46, 125, 50, 0.05)
  );
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.1);
  transform: translateY(-3px);
}

.product-card.selected::after {
  content: '✓';
  position: absolute;
  top: 15px;
  right: 15px;
  width: 28px;
  height: 28px;
  background: #4caf50;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  z-index: 1;
}

.product-info {
  position: relative;
  z-index: 1;
}

.product-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
  line-height: 1.4;
}

.product-brand {
  font-size: 0.95rem;
  color: #718096;
  margin-bottom: 15px;
  font-weight: 500;
}

.product-macros {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.macro-tag {
  background: #edf2f7;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.product-card:hover .macro-tag {
  background: #e2f3e5;
  color: #2e7d32;
}

.macro-tag.calories {
  background: #fff3e0;
  color: #f57c00;
}

.macro-tag.carbs {
  background: #fff8e1;
  color: #ff9800;
}

.macro-tag.protein {
  background: #e3f2fd;
  color: #1976d2;
}

.macro-tag.fat {
  background: #fce4ec;
  color: #c2185b;
}

/* Sezione prodotto selezionato */
.selected-product-section {
  padding: 25px 30px;
  background: white;
  border-top: 2px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  display: none;
}

.selected-product-section.show {
  display: block;
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.selected-product-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.selected-product-header i {
  font-size: 1.5rem;
  color: #4caf50;
  background: #e8f5e9;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.selected-product-header h4 {
  font-size: 1.4rem;
  color: #2d3748;
  font-weight: 700;
}

.selected-product-details {
  background: #f8fafc;
  border-radius: 14px;
  padding: 25px;
  margin-bottom: 25px;
  border: 1px solid #e2e8f0;
}

.selected-product-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 8px;
}

.selected-product-brand {
  font-size: 1.05rem;
  color: #718096;
  margin-bottom: 20px;
  font-weight: 500;
}

.selected-macros-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.selected-macro-card {
  background: white;
  padding: 18px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.selected-macro-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.selected-macro-value {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 5px;
}

.selected-macro-label {
  font-size: 0.85rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.calories-card .selected-macro-value {
  color: #f57c00;
}
.carbs-card .selected-macro-value {
  color: #ff9800;
}
.protein-card .selected-macro-value {
  color: #1976d2;
}
.fat-card .selected-macro-value {
  color: #c2185b;
}

.portion-control-section {
  padding: 20px;
  background: #f1f8e9;
  border-radius: 14px;
  border-left: 5px solid #4caf50;
}

.portion-control-section h5 {
  font-size: 1.2rem;
  color: #2d3748;
  margin-bottom: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.portion-control-section h5 i {
  color: #4caf50;
}

.portion-control {
  display: flex;
  align-items: center;
  gap: 20px;
}

.portion-input-group {
  display: flex;
  align-items: center;
  gap: 15px;
}

.portion-input-group input {
  width: 120px;
  padding: 16px;
  border: 2px solid #c8e6c9;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  background: white;
  color: #2d3748;
  transition: all 0.3s ease;
}

.portion-input-group input:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.portion-unit {
  font-size: 1.1rem;
  color: #2d3748;
  font-weight: 600;
}

.portion-slider {
  flex: 1;
  margin: 0 20px;
}

.portion-slider input[type='range'] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: linear-gradient(to right, #c8e6c9, #4caf50);
  border-radius: 4px;
  outline: none;
}

.portion-slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4caf50;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Sezione loading */
.loading-section {
  padding: 60px 30px;
  text-align: center;
  background: #f8fafc;
  display: none;
}

.loading-section.show {
  display: block;
}

.loading-spinner {
  display: inline-block;
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
}

.loading-spinner i {
  font-size: 3rem;
  color: #4caf50;
  animation: spin 1.5s linear infinite;
}

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

.loading-text {
  font-size: 1.1rem;
  color: #718096;
  font-weight: 600;
}

/* Messaggio vuoto */
.empty-results {
  padding: 60px 30px;
  text-align: center;
  background: #f8fafc;
  display: none;
}

.empty-results.show {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.empty-results i {
  font-size: 3.5rem;
  color: #cbd5e0;
  margin-bottom: 20px;
}

.empty-results h4 {
  font-size: 1.3rem;
  color: #a0aec0;
  margin-bottom: 10px;
  font-weight: 700;
}

.empty-results p {
  font-size: 1rem;
  color: #a0aec0;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Modal footer */
.food-modal .modal-footer {
  padding: 25px 30px;
  background: white;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

.add-food-btn {
  padding: 16px 32px;
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
  letter-spacing: 0.5px;
}

.add-food-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(76, 175, 80, 0.4);
  background: linear-gradient(135deg, #43a047, #1b5e20);
}

.add-food-btn:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* Scrollbar personalizzata */
.results-section::-webkit-scrollbar {
  width: 10px;
}

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

.results-section::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.results-section::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
