/* Import Lato Font */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

/* General Reset */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* Ensure full viewport height */
  background-color: #121212;
  /* Global dark background */
  color: #e0e0e0;
  /* Light text for readability */
  font-family: 'Lato', sans-serif;
  /* Updated font to Lato */
  display: flex;
  flex-direction: column;
}

body {
  background-color: #121212 !important;
  /* Matches your desired dark theme */
  margin: 0;
  padding: 0;
  color: #e0e0e0;
  /* Ensures readability */
}

/* Sticky Navbar */
.navbar {
  background-color: #1e1e1e !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(0, 0, 0, 0.55);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-brand {
  display: flex;
  align-items: center;
  color: #22c55e !important;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.navbar-logo {
  width: auto;
  height: 40px;
  border-radius: 6px;
}

.nav-link {
  position: relative;
  color: #a6f4c5;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.5rem 0.75rem;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0.35rem;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.9), rgba(45, 212, 191, 0.9));
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.nav-link:hover,
.nav-link:focus {
  color: #c8f9da;
  text-decoration: none;
}

.nav-link:hover::before,
.nav-link:focus::before,
.nav-link.active::before {
  width: 100%;
  opacity: 1;
}

.nav-link.active {
  color: #c8f9da;
}

.nav-link:focus {
  outline: none;
}

.navbar .nav-item.dropdown {
  position: relative;
}

.nav-avatar {
  padding: 0;
  margin-left: 0.75rem;
}

.nav-avatar::before {
  content: none;
}

.nav-avatar.dropdown-toggle::after {
  border-top-color: rgba(166, 244, 197, 0.7);
}

.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.35), rgba(34, 197, 94, 0.15));
  color: #0f1f0f;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.nav-avatar:hover .avatar-placeholder,
.nav-avatar:focus .avatar-placeholder {
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

/* Profile Avatar Image (navbar) */
.profile-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(34, 197, 94, 0.4);
  transition: all 0.3s ease;
}

.nav-avatar:hover .profile-avatar-img,
.nav-avatar:focus .profile-avatar-img {
  border-color: rgba(34, 197, 94, 0.7);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

/* Profile Picture Preview (profile page) */
.profile-picture-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(34, 197, 94, 0.3);
}

.profile-picture-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.35), rgba(34, 197, 94, 0.15));
  color: #0f1f0f;
  font-weight: 700;
  font-size: 2.5rem;
  letter-spacing: 0.03em;
  border: 3px solid rgba(34, 197, 94, 0.3);
}

/* Dropdown menus - apply dark theme globally */
.dropdown-menu {
  background-color: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.5rem 0;
  min-width: 12rem;
}

.navbar .dropdown-menu {
  background-color: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.5rem 0;
  min-width: 12rem;
  position: absolute;
  top: 100%;
}

.navbar .dropdown-header {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.7);
  padding: 0.25rem 1rem;
}

/* Dropdown items - apply dark theme globally */
.dropdown-item {
  color: #e0e0e0;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(34, 197, 94, 0.12);
  color: #c8f9da;
}

.navbar .dropdown-item {
  color: #e0e0e0;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.navbar .dropdown-item:hover,
.navbar .dropdown-item:focus {
  background-color: rgba(34, 197, 94, 0.12);
  color: #c8f9da;
}

.navbar .dropdown-item.active {
  background-color: rgba(34, 197, 94, 0.18);
  color: #c8f9da;
}

.navbar .dropdown-item.text-danger {
  color: #f28b82;
}

.navbar .dropdown-item.text-danger:hover,
.navbar .dropdown-item.text-danger:focus {
  background-color: rgba(242, 139, 130, 0.12);
  color: #ffb4ab;
}

.navbar .dropdown-divider {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.navbar-toggler {
  border-color: rgba(166, 244, 197, 0.35);
}

/* Hide Navbar on Mobile 
@media (max-width: 768px) {
  .navbar {
    display: none;
  }
}
*/
/* Remove Bullet Points */
ul.navbar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Main Content Styling */
main.container {
  background-color: #1e1e1e;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  /*margin: 3rem auto;*/
  /*max-width: 960px;*/
}

body>main {
  flex: 1;
  background-color: #121212;
  /* Ensure no white gaps */
}

/* Dashboard Cards */
.card {
  background-color: #1e1e1e !important;
  /* Dark card background */
  color: #e0e0e0 !important;
  /* Light text */
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
  border: none !important;
  /* Removes the border */
  padding: 0 !important;
  /* Removes the padding */
  text-align: center;
}

.card h5 {
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.macro-graphics {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6) !important;
  /* Removes the box shadow */
  padding: 0 !important;
  /* Removes padding */
  /* Added */
  min-height: 125px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.habit-grid {
  justify-content: center;
}

.habit-card-column {
  display: flex;
}

.habit-card-column .card {
  min-height: 230px;
}

.macro-graphics h4 {
  /* Use clamp for fluid font sizes */
  font-size: clamp(1.25rem, 2.5vw, 2rem);
}

.gauge-holder {
  width: min(160px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Grid Layout */
.row {
  display: flex;
  gap: 1.5rem;
  justify-content: space-around;
}

.col-md-6 {
  flex: 1;
  max-width: 48%;
}

/* Form Styling */
.form-control,
.form-select {
  background-color: #2a2a2a;
  /* Dark input background */
  border: none;
  color: #e0e0e0 !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.form-control:focus,
.form-select:focus {
  background-color: #333;
  box-shadow: 0 0 4px #28a745;
  outline: none;
}

/* Buttons */
.btn-primary,
.btn-success {
  background-color: rgb(40, 167, 69) !important;
  border: none;
  color: #fff !important;
  font-weight: bold;
  text-transform: uppercase;
}

/* Hover styling */
.btn-primary:hover,
.btn-success:hover {
  background-color: #22c55e !important;
  /* Same green hover color */
  color: #ffffff !important;
  /* Explicitly keep text white */
  transform: scale(1.02);
  transition: all 0.2s ease-in-out;
}

/* Links */
a {
  color: #28a745 !important;
  text-decoration: none;
  font-weight: bold;
}

a:hover {
  color: #22c55e !important;
}

/* Footer */
footer {
  background-color: #1e1e1e;
  color: #b3b3b3;
  text-align: center;
  padding: 1rem 0;
  margin-top: auto;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.4);
}

/* Full Height Background Fix */
body>footer {
  background-color: #121212;
}

/* Profile Page */
.profile-header h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

.profile-sections .card {
  min-height: 100%;
}

.profile-sections .card-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.profile-sections .card-body form {
  flex-grow: 1;
}

.habit-table {
  width: 100%;
  color: #e0e0e0;
}

.habit-goal-inputs .form-control-sm {
  min-width: 90px;
}

.habit-goal-inputs .input-group-text {
  background-color: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
  color: #a6f4c5;
}

.habit-range-summary {
  letter-spacing: 0.01em;
}

.habit-range-editor {
  margin-top: 0.25rem;
}

.habit-range-editor summary {
  cursor: pointer;
}

.habit-table .form-control-sm,
.habit-table .custom-control-label::before,
.habit-table .custom-control-label::after {
  background-color: #2a2a2a;
}

.habit-table .custom-control-input:checked~.custom-control-label::before {
  background-color: #22c55e;
}

@media (max-width: 576px) {
  .profile-header .badge {
    align-self: flex-start;
  }

  .habit-table td {
    white-space: normal;
  }
}

/* Adjustments for Smaller Screens */
@media (max-width: 768px) {
  .col-md-6 {
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .navbar-collapse {
    text-align: center;
  }

  .navbar-nav {
    margin: 0 auto;
  }

  #logFoodButtonContainer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
    padding: 0 16px;
    margin: 0;
    z-index: 1050;
    pointer-events: none;
  }

  #logFoodButtonContainer .btn {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    pointer-events: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
    font-weight: 700;
  }

  .dashboard-content {
    padding-bottom: calc(128px + env(safe-area-inset-bottom, 0));
  }
}

.form-control {
  color: #f5f5f5 !important;
  /* Brighter text */
  background-color: #2a2a2a !important;
  /* Darker background */
  font-weight: 600;
  /* Slightly bolder text */
}

.form-control:focus {
  background-color: #333 !important;
  /* Even darker focus state */
  border-color: #28a745 !important;
  /* Green border for focus */
  color: #ffffff !important;
  /* Keep text bright */
}

.status-indicator {
  display: inline-block;
  width: 10px;
  /* Adjust size as needed */
  height: 10px;
  margin-left: 0.5rem;
  /* Space between text and circle */
  border-radius: 50%;
  /* Makes it circular */
}

/* Example color classes */
.bg-green {
  background-color: #28a745;
}

.bg-yellow {
  background-color: #ffc107;
}

.bg-red {
  background-color: #dc3545;
}

@media (min-width: 992px) {
  .list-lg-margin {
    margin: 0 11%;
    /* 15% margin on the left and right only on large screens */
  }
}

.bg-gray {
  background-color: #6c757d;
}

.binary-indicator {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  line-height: 1;
}

.binary-indicator.completed {
  color: #28a745;
}

.binary-indicator.pending {
  color: #dc3545;
}

.status-dot-large {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin: 0.5rem auto;
}

.gauge-placeholder {
  font-size: 1.5rem;
  color: #6c757d;
  line-height: 1;
}

/* Saved Foods Quick Add */
.saved-foods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.saved-food-item {
  padding: 0.5rem;
  background-color: rgba(42, 42, 42, 0.5);
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.saved-food-item:hover {
  background-color: rgba(42, 42, 42, 0.8);
}

.saved-food-item .custom-control-input:checked~.custom-control-label {
  color: #22c55e;
  font-weight: 600;
}

.saved-food-name {
  display: block;
  font-size: 0.95rem;
}

.saved-food-calories {
  display: block;
  font-size: 0.85rem;
}

@media (max-width: 576px) {
  .saved-foods-grid {
    grid-template-columns: 1fr;
  }
}

/* Quick-Add Meal Logging Styles */
.selected-foods-panel {
  position: sticky;
  top: 15px;
  background-color: #2a2a2a;
  border: 2px solid #22c55e;
  border-radius: 6px;
  padding: 0;
  margin-bottom: 15px;
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.2);
  z-index: 100;
}

.selected-foods-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.selected-foods-panel .panel-header h5 {
  color: #22c55e;
  font-weight: 600;
  margin: 0;
  font-size: 0.95rem;
}

.selected-foods-list {
  max-height: 120px;
  overflow-y: auto;
  padding: 6px 12px;
}

.selected-food-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.selected-food-item .food-name {
  flex: 1;
  color: #e0e0e0;
  font-weight: 500;
  font-size: 0.9rem;
}

.selected-food-item .food-macros-small {
  color: #9ca3af;
  font-size: 0.85rem;
  margin-right: 8px;
}

.panel-footer {
  padding: 10px 12px;
  background-color: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.running-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 8px;
  background-color: rgba(34, 197, 94, 0.1);
  border-radius: 4px;
}

.running-totals .total-item {
  color: #e0e0e0;
  font-size: 0.85rem;
}

.running-totals .total-item:first-child {
  font-weight: 600;
  color: #22c55e;
}

.quick-add-btn {
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-add-btn.btn-success {
  background-color: #22c55e;
  border-color: #22c55e;
  color: white;
}

.quick-add-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

/* Responsive adjustments for selected panel */
@media (max-width: 768px) {
  .selected-foods-panel {
    position: relative;
    top: 0;
  }

  .running-totals {
    gap: 8px;
  }

  .running-totals .total-item {
    font-size: 0.85rem;
  }

  .selected-foods-list {
    max-height: 150px;
  }
}

/* ============================================================================
   MEAL PLANNING STYLES (PREMIUM REDESIGN)
   ============================================================================ */

/* --- Layout & Grid --- */
.meal-plan-container {
  max-width: 1600px;
  margin: 0 auto;
  padding-bottom: 4rem;
}

.meal-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #22c55e;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
}

.meal-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.3), transparent);
  margin-left: 1rem;
}

/* --- Cards (Glassmorphism) --- */
.premium-card {
  background: rgba(30, 30, 30, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

.premium-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(35, 35, 35, 0.7);
}

/* --- Planned Meal Card Specifics --- */
.planned-meal-card {
  display: flex;
  flex-direction: column;
  position: relative;
}

.planned-meal-card .card-body {
  padding: 1.25rem;
}

.pm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.pm-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.3;
}

.pm-macros {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #a0a0a0;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  width: fit-content;
}

.pm-macro-item strong {
  color: #fff;
}

.pm-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 0.5rem;
}

.pm-qty-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #a0a0a0;
  transition: all 0.2s;
  padding: 0;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-icon.remove:hover {
  background: rgba(220, 53, 69, 0.2);
  color: #ff6b6b;
  border-color: rgba(220, 53, 69, 0.4);
  min-width: 1.5rem;
}

/* --- Weekly Projection Bar (Slim Redesign) --- */
/* --- Weekly Projection Bar (Slim Redesign) --- */
.projection-bar-container {
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  /* Rounded corners for static bar */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.projection-bar-content {
  padding: 0.75rem 1.5rem;
}

.slim-stat-group {
  gap: 3rem !important;
  /* Increased spacing between macros */
}

.section-counts {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding-right: 2rem;
}

.count-item {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
}

.slim-stat-item {
  display: flex;
  align-items: baseline;
}

.stat-label {
  font-size: 0.75rem;
  opacity: 0.7;
}

.stat-value {
  font-size: 1rem;
}

.stat-pct {
  font-size: 0.75rem;
  opacity: 0.9;
}

/* Mobile Styles */
@media (max-width: 991px) {
  .projection-bar-container {
    margin: 0 0.5rem;
  }

  .slim-stat-group {
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem !important;
    /* Increased gap for mobile wrapping */
  }

  .section-counts {
    border-right: none;
    padding-right: 0;
    margin-bottom: 1rem;
  }
}

.projection-header {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  margin-bottom: 1.5rem;
  text-align: center;
}

.macro-ring-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  position: relative;
}

/* Custom Circular Progress (CSS only implementation) */
.circular-chart {
  display: block;
  margin: 0 auto;
  max-width: 80%;
  max-height: 250px;
}

.circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 2.5;
}

.circle {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dasharray 1s ease-out;
}

.circle.calories {
  stroke: #22c55e;
}

.circle.protein {
  stroke: #3b82f6;
}

.circle.carbs {
  stroke: #f59e0b;
}

.circle.fats {
  stroke: #ef4444;
}

.percentage-label {
  fill: #fff;
  font-family: 'Lato', sans-serif;
  font-weight: bold;
  font-size: 0.5em;
  text-anchor: middle;
}

.macro-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.legend-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.legend-label {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.legend-sub {
  font-size: 0.7rem;
  color: #666;
}

/* --- Available Meals List --- */
.available-meals-container {
  height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Custom Scrollbar */
.available-meals-container::-webkit-scrollbar {
  width: 6px;
}

.available-meals-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.available-meals-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.available-meals-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.search-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem 1rem 1rem 3rem;
  color: #fff;
  font-size: 1rem;
  transition: all 0.2s;
}

.search-input:focus {
  background: rgba(0, 0, 0, 0.5);
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  pointer-events: none;
}

.saved-meal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  transition: all 0.2s;
  cursor: pointer;
}

.saved-meal-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.sm-info h6 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  color: #e0e0e0;
}

.sm-macros {
  font-size: 0.8rem;
  color: #888;
}

.btn-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.btn-add:hover {
  background: #22c55e;
  color: #fff;
}

/* --- Empty State --- */
.empty-plan-state {
  text-align: center;
  padding: 4rem 2rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.1);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* --- Week Navigation --- */
.week-nav {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 100px;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
}

.week-nav-btn {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  text-decoration: none;
}

.week-nav-btn:hover {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
  text-decoration: none;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.week-display {
  padding: 0 1.5rem;
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
}


.control-label {
  font-size: 0.875rem;
  color: #adb5bd;
  text-align: center;
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Control Buttons - Touch Friendly */
.btn-control {
  min-width: 48px;
  min-height: 48px;
  font-size: 1.5rem;
  font-weight: 600;
  border: 2px solid #28a745;
  background: transparent;
  color: #28a745;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-control:hover:not(:disabled) {
  background: rgba(40, 167, 69, 0.2);
}

.btn-control:active:not(:disabled) {
  background: rgba(40, 167, 69, 0.3);
}

.btn-control:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #6c757d;
  color: #6c757d;
}

/* Quantity Display */
.quantity-display {
  min-width: 48px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}

/* Remove Button - Full Width on Mobile */
.btn-remove {
  width: 100%;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 500;
  border: 2px solid #dc3545;
  background: transparent;
  color: #dc3545;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.btn-remove:hover {
  background: rgba(220, 53, 69, 0.2);
}

.btn-remove:active {
  background: rgba(220, 53, 69, 0.3);
}

/* HTMX Loading Indicator */
.recipe-card.htmx-request,
.meal-card.htmx-request {
  opacity: 0.7;
  pointer-events: none;
}

.recipe-card.htmx-request::after,
.meal-card.htmx-request::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border: 2px solid #28a745;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Desktop Styles (≥768px) ===== */
@media (min-width: 768px) {

  .recipe-card .card-body,
  .meal-card .card-body {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .recipe-header,
  .meal-header {
    flex: 1;
    text-align: left;
    min-width: 200px;
  }

  .recipe-control,
  .meal-control {
    flex-direction: row;
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
  }

  .btn-control {
    min-width: 40px;
    min-height: 40px;
    font-size: 1.25rem;
  }

  .btn-remove {
    width: auto;
    min-width: auto;
    padding: 0.5rem 1rem;
    margin-top: 0;
  }
}

/* ===== END HTMX CARD STYLES ===== */

/* Meal group headers */
.meal-group-header {
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding-bottom: 8px;
  border-bottom: 2px solid #28a745;
  margin-bottom: 12px !important;
}

#planned-meals-container .meal-group {
  padding-bottom: 12px;
  border-bottom: 1px solid #343a40;
  margin-bottom: 1rem;
  clear: both;
  overflow: hidden;
}

#planned-meals-container .meal-group:last-child {
  border-bottom: none;
}

#saved-meals-container .meal-group {
  margin-bottom: 1.5rem;
}

#saved-meals-container .meal-group:last-child {
  margin-bottom: 0;
}

/* Weekly Projection Styles */
.projection-header {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #28a745;
}

.projection-section {
  margin-bottom: 1.5rem;
}

.projection-section-title {
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #adb5bd;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #495057;
}

/* Progress Bars */
.progress-bar-container {
  background-color: #343a40;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  margin: 0.5rem 0;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.75rem;
  font-weight: bold;
}

.progress-bar-fill.success {
  background: linear-gradient(90deg, #28a745 0%, #34ce57 100%);
  color: white;
}

.progress-bar-fill.warning {
  background: linear-gradient(90deg, #ffc107 0%, #ffcd38 100%);
  color: #212529;
}

.progress-bar-fill.danger {
  background: linear-gradient(90deg, #dc3545 0%, #e4606d 100%);
  color: white;
}

.progress-bar-fill.info {
  background: linear-gradient(90deg, #17a2b8 0%, #3ab0c3 100%);
  color: white;
}

/* Macro Line Item */
.macro-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.macro-line-label {
  font-weight: 500;
  min-width: 80px;
}

.macro-line-values {
  flex: 1;
  margin: 0 1rem;
}

.macro-line-gap {
  font-size: 0.85rem;
  min-width: 120px;
  text-align: right;
}

.gap-positive {
  color: #28a745;
}

.gap-negative {
  color: #ffc107;
}

.gap-warning {
  color: #dc3545;
}

/* Meal Coverage Badge */
.coverage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #343a40;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.coverage-badge .coverage-number {
  font-size: 1.5rem;
  font-weight: bold;
  margin-right: 0.5rem;
  color: #28a745;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

  /* Stack week navigation vertically on mobile */
  .week-navigation {
    flex-direction: column;
    text-align: center;
  }

  .week-navigation h4 {
    margin: 1rem 0;
  }

  /* Adjust planned meal card layout for mobile */
  .planned-meal-card .d-flex {
    flex-direction: column;
  }

  .planned-meal-card .quantity-controls {
    margin-top: 1rem;
    justify-content: center;
  }

  /* Modal full-width on mobile */
  .modal-dialog {
    margin: 0.5rem;
  }

  /* Saved meals grid - 1 column on mobile */
  #saved-meals-grid .col-md-4 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Touch-friendly button sizes */
  .increment-btn,
  .decrement-btn,
  .remove-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2rem;
  }

  /* Recipe Card Controls Stacking */
  .pm-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .pm-qty-control {
    justify-content: space-between;
    width: 100%;
  }

  .btn-remove {
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* Meal Planning - Sticky Sidebar Layout */
/* Meal Planning - Single Column Layout */
/* Removed sticky-sidebar-container styles as we are now using a single flow */

.projection-widget {
  /* Widget adapts to container width */
  width: 100%;
  margin-bottom: 1.5rem;
}

.available-meals-wrapper {
  /* Wrapper adapts to container width */
  width: 100%;
}

/* Custom Scrollbar removed as container handles scrolling */

/* Remove old container styles that might conflict */
.available-meals-container {
  height: auto;
  /* Let wrapper control height */
  overflow-y: visible;
}

.sticky-saved-meals {
  position: static;
  max-height: none;
  width: 100%;
}

/* Mobile adjustments */
@media (max-width: 991px) {
  .sticky-sidebar-container {
    position: relative;
    top: 0;
    height: auto;
    display: block;
  }

  .available-meals-wrapper {
    height: 500px;
    /* Fixed height on mobile or auto? */
    overflow-y: auto;
  }
}