.calendar-days div[style*="font-weight: bold"], .calendar-days .calendar-weekday {
  color: var(--color-primary);
  font-weight: bold;
  background: transparent !important;
}
.calendar-day.selected {
  background: var(--color-primary);
  color: #fff;
}
body.dark-mode .calendar-day.selected {
  background: var(--color-primary);
  color: #fff;
  border: none;
}
/* Calendar Modal Overlay and Window Styling */
.calendar-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  backdrop-filter: blur(5px);
}
.calendar-modal-overlay.active {
  display: flex;
}
.calendar-modal {
  background: var(--color-surface);
  margin: 5% auto;
  padding: 32px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
  width: 92%;
  max-width: 420px;
  position: relative;
  animation: modalSlideIn 0.4s ease-out;
  max-height: 85vh;
  overflow-y: auto;
  color: var(--color-text);
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.calendar-arrow {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--color-primary);
  padding: 4px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}
.calendar-arrow:hover {
  background: var(--color-surface-alt);
}
.calendar-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #888;
  margin-left: 8px;
}
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.calendar-day {
  padding: 8px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-weight: 500;
}
.calendar-day:hover {
  background: var(--color-primary);
  color: #fff;
}
.calendar-day.selected {
  background: var(--color-primary);
  color: #fff;
}
.calendar-day.inactive {
  color: #bbb;
  background: var(--color-surface);
}
body.dark-mode .calendar-modal {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 20px 40px rgba(0,0,0,0.7), 0 10px 20px rgba(0,0,0,0.4);
  border: 1px solid #333;
}
body.dark-mode .calendar-day {
  background: #23272a;
  color: var(--color-text);
}
body.dark-mode .calendar-day.inactive {
  background: #181a1b;
  color: #555;
}
/* Remove white row borders in nutrient table for dark mode */
body.dark-mode th,
body.dark-mode td {
    border-bottom: 1px solid #333 !important;
}
/* Remove white row borders in profile popup menu for dark mode */
body.dark-mode .profile-popup th,
body.dark-mode .profile-popup td {
    border-bottom: 1px solid #333 !important;
}
/* Dark mode: macronutrient tiles in food details window */
body.dark-mode .food-details-content .macro-item {
    background: #23272a !important;
    border: 1px solid #333;
    color: var(--color-text);
}

body.dark-mode .food-details-content .macro-value {
    color: var(--color-text) !important;
}

body.dark-mode .food-details-content .macro-label {
    color: #aaa !important;
}
/* Brighter blue for food details headings in dark mode */
body.dark-mode .food-details-content h2,
body.dark-mode .food-details-content h3,
body.dark-mode .food-details-content .food-details-name {
    color: #4285f4 !important;
}
/* Dark mode for modals and popups */
body.dark-mode .modal-content,
body.dark-mode #setupModal .modal-content {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 20px 40px rgba(0,0,0,0.7), 0 10px 20px rgba(0,0,0,0.4);
    border: 1px solid #333;
}

body.dark-mode .food-details-content,
body.dark-mode .modal-content.food-details-content {
    background: #23272a;
    color: var(--color-text);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.2);
    border: 1px solid #444;
}

body.dark-mode .modal-content label,
body.dark-mode .modal-content input,
body.dark-mode .modal-content select,
body.dark-mode .modal-content button,
body.dark-mode .modal-content h2,
body.dark-mode .modal-content span,
body.dark-mode .modal-content .close-btn {
    color: var(--color-text);
    background: transparent;
}

body.dark-mode .modal-content input,
body.dark-mode .modal-content select {
    background: #23272a;
    border: 1px solid #444;
    color: var(--color-text);
}

body.dark-mode .modal-content button {
    background: var(--color-primary);
    color: #fff;
}

body.dark-mode .modal-content .close-btn {
    color: var(--color-text);
}

/* Profile details page dark mode */
body.dark-mode .profile-page-container,
body.dark-mode .profile-card,
body.dark-mode .profile-details-grid,
body.dark-mode .profile-avatar-large,
body.dark-mode .profile-info-section {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: #333;
}
:root {
    --color-bg: #f5f6fa;
    --color-surface: #fff;
    --color-surface-alt: #f1f3f4;
    --color-primary: #4285f4;
    --color-accent: #34a853;
    --color-fat: #fbbc04;
    --color-carb: #ff7043;
    --color-text: #222;
    --color-muted: #757575;
    --bar-height: 18px;
    --bar-radius: 9px;
    --shadow: 0 2px 8px rgba(60, 64, 67, 0.08), 0 1.5px 4px rgba(60, 64, 67, 0.08);
}

body.dark-mode {
    --color-bg: #181a1b;
    --color-surface: #23272a;
    --color-surface-alt: #22262a;
    --color-primary: #4285f4;
    --color-accent: #57e690;
    --color-fat: #ffd166;
    --color-carb: #ff9776;
    --color-text: #f1f1f1;
    --color-muted: #b0b0b0;
}

body.dark-mode {
    background: var(--color-bg);
    color: var(--color-text);
}

body.dark-mode .profile-popup {
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
    border: 1px solid #333;
}

body.dark-mode .profile-menu-btn, body.dark-mode .sign-out-btn {
    color: var(--color-text);
}

body.dark-mode .profile-menu-btn:hover, body.dark-mode .sign-out-btn:hover {
    background: #23272a;
}

body {
    margin: 0;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    /* Ensure no conflicting positioning */
    position: relative;
}

header {
    margin-top: 0;
    margin-bottom: 32px;
    position: relative; /* Ensure it doesn't create stacking context issues */
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: var(--color-primary);
}

#calendarBar {
    position: static; /* Changed from sticky */
    z-index: 1000;
    background: var(--color-surface);
    box-shadow: 0 2px 8px rgba(60, 64, 67, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    width: 100%;
    box-sizing: border-box;
    margin-top: 80px;
    margin-bottom: 32px;
    /* Add backdrop for better visibility */
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(224, 224, 224, 0.3);
}

body.dark-mode #calendarBar {
    border-bottom: 1px solid #222;
}

#calendarBar>button {
    font-size: 22px;
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#calendarBar>button:hover {
    background: var(--color-surface-alt);
}

#calendarBar>span#currentDate {
    flex: 0 1 auto;
    min-width: 180px;
    text-align: center;
    font-weight: 600;
    font-size: 1.1em;
    color: var(--color-primary);
    letter-spacing: 0.5px;
}

.progress-container {
    background: var(--color-surface);
    box-shadow: var(--shadow);
    border-radius: 14px;
    padding: 18px 20px 12px 20px;
    margin-bottom: 18px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-muted);
    margin-bottom: 6px;
}

.progress-bar {
    height: var(--bar-height);
    background: var(--color-surface-alt);
    border-radius: var(--bar-radius);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    transition: width 0.4s cubic-bezier(.4, 0, .2, 1);
    border-radius: var(--bar-radius);
}

.protein-fill {
    background: var(--color-primary);
}

.fat-fill {
    background: var(--color-fat);
}

.carb-fill {
    background: var(--color-carb);
}

#caloriesProgress {
    background: #ea4335;
}

#addFoodBtn,
#setupBtn {
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.18);
    background: #4285f4;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

@media (max-width: 600px) {

    #addFoodBtn,
    #setupBtn {
        width: 48px !important;
        height: 48px !important;
        font-size: 24px !important;
        margin: 0 !important;
    }
}

/* Make the button row tight */
.button-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 20px;     /* Decreased to move button up */
    margin-bottom: 32px;  /* Increased to move button away from tabs */
}

@media (max-width: 600px) {
    .button-row {
        gap: 32px;
        margin-top: 32px;     /* Decreased for mobile */
        margin-bottom: 40px;  /* Increased for mobile */
        justify-content: center;
    }

    #addFoodBtn,
    #setupBtn {
        width: 48px !important;
        height: 48px !important;
        font-size: 24px !important;
        margin: 0 !important;
    }
}

#foodList {
    list-style: none;
    padding: 0;
    margin: 0 auto 32px auto;
    max-width: 420px;
}

#foodList li {
    background: var(--color-surface);
    box-shadow: var(--shadow);
    border-left: 5px solid var(--color-primary);
    padding: 14px 18px;
    margin-bottom: 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.04em;
    gap: 12px;
}

#foodList li span:first-child {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

#foodList li span:last-child {
    flex: 0 0 auto;
    margin-left: 16px;
    font-weight: 500;
    color: var(--color-muted);
    text-align: right;
    width: 70px;
    /* Fixed width for weight */
}

#foodList li button {
    background: none;
    border: none;
    color: #ea4335;
    font-size: 22px;
    cursor: pointer;
    margin-left: 10px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#foodList li button:hover {
    background: var(--color-surface-alt);
}

table {
    width: 100%;
    max-width: 420px;
    margin: 0 auto 32px auto;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

th,
td {
    padding: 12px 10px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
    font-size: 15px;
}

td:first-child,
th:first-child {
    text-align: left;
}

th {
    background: var(--color-surface-alt);
    color: var(--color-primary);
    text-align: left;
    font-weight: 700;
}

caption {
    font-weight: 700;
    text-align: left;
    padding: 12px 0 8px 0;
    color: var(--color-primary);
    font-size: 1.1em;
}

tr[style*="color"] td:first-child {
    color: inherit;
}

/* Modal styling */
#addFoodModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

#addFoodModal.active {
    display: flex;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
    width: 92%;
    max-width: 540px;
    position: relative;
    animation: modalSlideIn 0.4s ease-out;
    max-height: 85vh;
    overflow-y: auto;
}

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

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

/* Small loading spinner for search suggestions */
.search-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid currentColor;
    border-top: 1px solid #4285f4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0.5;
    margin-right: 8px;
    vertical-align: middle;
}

.modal-content h2 {
    color: #2c3e50;
    margin-bottom: 24px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-top: 0;
    padding-bottom: 12px;
}

/* Modal inner content container */
.modal-inner-content {
    padding: 30px;
    text-align: left;
}

.modal-content label {
    display: block;
    margin-bottom: 8px;
    margin-top: 20px;
    color: #2c3e50;
    font-weight: 600;
    text-align: left;
    font-size: 15px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 16px;
    background-color: #f8f9fa;
    box-sizing: border-box;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    color: var(--color-text);
    outline: none;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
}

.modal-content input:focus,
.modal-content select:focus {
    border-color: #4285f4;
    background-color: white;
    box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.1);
    transform: translateY(-1px);
}

.modal-content input::placeholder {
    color: #94a3b8;
    font-style: normal;
    font-weight: 400;
}

.modal-content button {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 12px;
    margin-top: 24px;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    letter-spacing: 0.5px;
}

.modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(66, 133, 244, 0.3);
    background: linear-gradient(135deg, #3367d6 0%, #2d8f47 100%);
}

.modal-content button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.2);
}

.modal-content .close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 32px;
    font-weight: bold;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
    background: none;
    border: none;
    padding: 4px;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content .close-btn:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    transform: scale(1.1);
}

/* Modal inner content container - removed duplicate styles */

#suggestions {
    background: #f8f9fa;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.12);
}
/* Dark mode for food suggestions dropdown */
body.dark-mode #suggestions {
    background: var(--color-surface);
    border: 2px solid #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

body.dark-mode #suggestions div {
    color: var(--color-text);
    background: transparent;
    border-bottom: 1px solid #333;
}

body.dark-mode #suggestions div:last-child {
    border-bottom: none;
}

body.dark-mode #suggestions div:hover,
body.dark-mode #suggestions div:focus {
    background: #2a2d30;
    color: var(--color-text);
}

body.dark-mode #suggestions div[style*="italic"] {
    background: linear-gradient(135deg, rgba(138,180,248,0.05) 0%, rgba(156, 163, 175, 0.05) 100%) !important;
    color: #b0b0b0 !important;
}

#suggestions div {
    padding: 16px 20px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(224, 224, 224, 0.4);
    color: var(--color-text);
    font-weight: 500;
    background: transparent;
}

#suggestions div:last-child {
    border-bottom: none;
}

#suggestions div:hover,
#suggestions div:focus {
    background: var(--color-surface-alt);
    color: var(--color-primary);
    transform: translateX(4px);
}

/* Enhanced loading and error states for suggestions */
#suggestions div[style*="italic"] {
    text-align: center;
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.05) 0%, rgba(156, 163, 175, 0.05) 100%) !important;
    color: #6b7280 !important;
    cursor: default;
    border-bottom: none;
    font-style: italic;
    padding: 20px;
    border-radius: 8px;
    margin: 8px;
}

#suggestions div[style*="italic"]:hover {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.05) 0%, rgba(156, 163, 175, 0.05) 100%) !important;
    color: #6b7280 !important;
    transform: none;
}

/* Loading animation for suggestions */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#suggestions div[style*="Searching"] {
    animation: pulse 2s infinite;
}

#mealTabs {
    display: flex;
    justify-content: center;
    gap: 8px; /* Reduced from 14px */
    margin: 0 auto 24px auto;
    max-width: 420px;
    padding: 0 16px; /* Add horizontal padding to create space from edges */
    box-sizing: border-box;
    width: 100%;
}

.meal-tab {
    background: var(--color-surface);
    color: var(--color-primary);
    border: none;
    padding: 10px 16px; /* Reduced horizontal padding from 28px to 16px */
    border-radius: 24px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(60, 64, 67, 0.06);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    outline: none;
    letter-spacing: 0.5px;
    margin-bottom: 0;
    margin-top: 0;
    position: relative;
    flex: 1; /* Make tabs grow equally to fill available space */
    min-width: 0; /* Allow shrinking below content size */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure the existing active and hover states still work */
.meal-tab.active {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.10);
    z-index: 1;
}

.meal-tab:hover,
.meal-tab:focus {
    background: var(--color-surface-alt);
    color: var(--color-primary);
}

.meal-tab.active:hover,
.meal-tab.active:focus {
    background: var(--color-primary);
    color: #fff;
}

::-webkit-scrollbar {
    width: 8px;
    background: #f1f3f4;
}

::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 4px;
}

#modalFoodName {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    margin-bottom: 20px;
}

/* When suggestions are visible, adjust the food name input */
#modalFoodName.has-suggestions {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
}

#suggestions {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
    margin-bottom: 20px;
    position: relative;
    top: -2px;
    z-index: 10;
}

#modalFoodWeight,
#modalFoodUnit {
    margin-bottom: 20px !important;
    height: auto;
    font-size: 16px;
    padding: 16px 20px;
    box-sizing: border-box;
}

#modalFoodWeight {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

#modalFoodUnit {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
}

.weight-row {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
}

.weight-row>input,
.weight-row>select {
    flex: 1;
    margin-bottom: 0 !important;
}

.top-right-buttons {
    position: absolute; /* Changed back from fixed */
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2000; /* Higher than calendar bar */
}

.cloud-sync-status {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
    cursor: help;
    transition: all 0.2s ease;
}

/* Dark mode for cloud sync status indicator */
body.dark-mode .cloud-sync-status {
    background: #23272a;
    border: 1px solid #333;
    color: var(--color-text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.cloud-sync-status:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

#profileBtn {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(60, 64, 67, 0.12);
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
    padding: 0;
    position: relative; /* Add this for fallback positioning */
}

#profileBtn:hover {
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.18);
    border-color: var(--color-primary);
}

#profileImage {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Fallback when image fails to load */
#profileBtn.no-image {
    background: var(--color-primary);
    color: white;
    font-size: 18px;
    font-weight: 600;
}

#profileBtn.no-image #profileImage {
    display: none;
}

#setupBtn,
#menuBtn {
    position: static;
    background: #4285f4;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(60, 64, 67, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
}

#setupBtn:hover,
#menuBtn:hover {
    background: #3367d6;
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.18);
}

/* Invert the settings icon to make it white on blue background */
#setupIcon {
    filter: invert(1) brightness(100%);
}

/* Dark mode styles for top-right buttons */
body.dark-mode #setupBtn,
body.dark-mode #menuBtn {
    background: var(--color-primary);
    color: #fff;
    border: 1px solid #333;
}

body.dark-mode #setupBtn:hover,
body.dark-mode #menuBtn:hover {
    background: #3367d6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

@media (max-width: 600px) {
    .top-right-buttons {
        position: absolute; /* Keep as absolute on mobile too */
        top: 16px;
        right: 8px;
        gap: 6px;
    }
    
    #calendarBar {
        padding: 8px 4px;
        gap: 8px;
        margin-top: 72px;
        z-index: 1000;
        width: 100%;
    }
}

/* Prevent horizontal scroll on all elements */
html,
body {
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ensure all major containers don't overflow */
#calendarBar,
header,
.progress-container,
#foodList,
table,
#mealTabs,
.modal-content,
.setup-content {
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Mobile-specific adjustments */
@media (max-width: 600px) {
    #mealTabs {
        gap: 6px; /* Further reduced gap for mobile */
        padding: 0 12px; /* Reduced padding for mobile */
        max-width: 100vw;
        margin-left: 0;
        margin-right: 0;
    }

    .meal-tab {
        padding: 10px 8px; /* Further reduced horizontal padding for mobile */
        font-size: 14px; /* Slightly smaller font on mobile */
        min-width: 70px; /* Set minimum width to ensure readability */
        max-width: none; /* Remove max-width constraint */
        flex: 1; /* Equal distribution */
    }

    .progress-container {
        max-width: 98vw;
        padding-left: 2vw;
        padding-right: 2vw;
    }

    table {
        max-width: 98vw;
        margin-left: 1vw;
        margin-right: 1vw;
    }

    .modal-content,
    .setup-content {
        max-width: 98vw;
        width: 98vw;
        padding-left: 2vw;
        padding-right: 2vw;
    }
}

@media (max-width: 400px) {
    #mealTabs {
        gap: 4px;
        padding: 0 8px;
    }
    
    .meal-tab {
        padding: 8px 6px;
        font-size: 13px;
        min-width: 60px;
        border-radius: 20px; /* Slightly smaller border radius for compact look */
    }
}

@media (max-width: 375px) {
    #mealTabs {
        gap: 3px;
        padding: 0 6px;
    }
    
    .meal-tab {
        padding: 8px 4px;
        font-size: 12px;
        min-width: 55px;
        letter-spacing: 0.3px;
    }
}

/* Remove extra padding/margin that could cause overflow */
body {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

#setupModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

#setupModal.active {
    display: flex;
}

/* Also update other modals to have consistent high z-index */
#addFoodModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

#addFoodModal.active {
    display: flex;
}

#foodDetailsModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(60, 64, 67, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000; /* Increased from 2000 to match others */
    padding: 20px;
    box-sizing: border-box;
}

/* Hide scrollbars everywhere */
html, body, * {
  scrollbar-width: none;         /* Firefox */
  -ms-overflow-style: none;      /* IE and Edge */
}
html::-webkit-scrollbar, 
body::-webkit-scrollbar, 
*::-webkit-scrollbar {
  display: none;                 /* Chrome, Safari, Opera */
}

/* Prevent background scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    height: 100vh;
}

.profile-popup {
    position: absolute;
    top: 56px; /* Position below the profile button */
    right: 0px; /* Move a little to the left */
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(60, 64, 67, 0.15);
    border: 1px solid #e0e0e0;
    min-width: 160px;
    z-index: 1000;
    overflow: hidden;
}

.profile-menu-btn, .sign-out-btn {
    width: 100%;
    background: none;
    border: none;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    box-sizing: border-box;
    border-radius: 0;
}

.profile-menu-btn:hover, .sign-out-btn:hover {
    background: var(--color-surface-alt);
}

.profile-menu-btn {
    border-bottom: 1px solid #e0e0e0;
}

/* Remove extra margin/padding from sign-out button to match menu */
.sign-out-btn {
    margin: 0;
    padding: 12px 16px;
    border-top: none;
    border-bottom: none;
    border-radius: 0;
}

.food-details-content {
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.food-details-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
}

.food-details-name {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.food-details-weight {
    font-size: 1.1em;
    color: var(--color-muted);
    font-weight: 500;
}

.nutrition-section {
    margin-bottom: 24px;
}

.nutrition-section h3 {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-surface-alt);
}

body.dark-mode .nutrition-section h3 {
    border-bottom: 1px solid #4285f4;
}

.macro-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.macro-item {
    background: var(--color-surface-alt);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.macro-value {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--color-text);
}

.macro-label {
    font-size: 0.9em;
    color: var(--color-muted);
    margin-top: 2px;
}

.micro-list {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px 16px;
    align-items: center;
}

.micro-name {
    font-weight: 500;
    color: var(--color-text);
}

.micro-value {
    font-weight: 600;
    color: var(--color-text);
    text-align: right;
}

.micro-percent {
    font-weight: 600;
    text-align: right;
    min-width: 50px;
}

.micro-percent.good {
    color: #4caf50;
}

.micro-percent.moderate {
    color: #ff9800;
}

.micro-percent.low {
    color: var(--color-muted);
}

/* Food Details Modal */
#foodDetailsModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(5px);
}

#foodDetailsModal.active {
    display: flex;
}

.food-details-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.4s ease-out;
}

.food-details-header {
    text-align: center;
    padding: 30px 30px 20px 30px;
    flex-shrink: 0;
}

.food-details-name {
    font-size: 1.4em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
}

.food-details-weight {
    font-size: 1.1em;
    color: #757575;
    font-weight: 500;
}

#foodDetailsContent {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    padding-top: 0;
}

.nutrition-section {
    margin-bottom: 24px;
    margin-top: 24px;
}

.nutrition-section:first-child {
    margin-top: 24px;
}

.nutrition-section h3 {
    font-size: 1.1em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #2c3e50;
}

.macro-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.macro-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

.macro-value {
    font-size: 1.3em;
    font-weight: 700;
    color: #2c3e50;
}

.macro-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 2px;
}

.micro-list {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px 16px;
    align-items: center;
}

.micro-name {
    font-weight: 500;
    color: var(--color-text);
}

.micro-value {
    font-weight: 600;
    color: var(--color-text);
    text-align: right;
}

.micro-percent {
    font-weight: 600;
    text-align: right;
    min-width: 50px;
}

.micro-percent.good {
    color: #4caf50;
}

.micro-percent.moderate {
    color: #ff9800;
}

.micro-percent.low {
    color: var(--color-muted);
}

/* Close button for food details modal */
.food-details-content .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1001;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.food-details-content .close-btn:hover {
    color: #000;
}

/* Make food list items clickable */
#foodList li {
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#foodList li:hover {
    background: var(--color-surface-alt);
    transform: translateY(-1px);
}

#foodList li:active {
    transform: translateY(0);
}

/* Prevent the remove button from triggering the food details */
#foodList li button {
    z-index: 10;
    position: relative;
}

/* Form section grouping for better visual hierarchy */
.modal-form-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(225, 232, 237, 0.5);
}

.modal-form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-form-section.meal-section {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.05) 0%, rgba(52, 168, 83, 0.05) 100%);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(66, 133, 244, 0.1);
    margin-bottom: 24px;
}

/* Improved placeholder styling */
.modal-content input::placeholder {
    color: #94a3b8;
    font-style: normal;
    font-weight: 400;
}

/* Better focus states for accessibility */
.modal-content input:focus,
.modal-content select:focus {
    border-color: #4285f4;
    background-color: white;
    box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.1);
    transform: translateY(-1px);
    outline: none;
}

/* Improve select dropdown styling */
.modal-content select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='[http://www.w3.org/2000/svg](http://www.w3.org/2000/svg)' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 48px;
}

/* Focus visible for keyboard navigation */
.modal-content button:focus-visible {
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

.modal-content input:focus-visible,
.modal-content select:focus-visible {
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

/* Improved accessibility for modals */
.modal {
    backdrop-filter: blur(8px);
    background: rgba(0, 0, 0, 0.6);
}

/* Better button active states */
.modal-content button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.2);
}

/* ===== PROFILE PAGE STYLES ===== */

/* Profile page container */
.profile-page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 20px 40px 20px;
    min-height: 100vh;
    background: var(--color-bg);
}

/* Mobile-first responsive adjustments */
@media (max-width: 768px) {
    .profile-page-container {
        padding: 80px 12px 20px 12px; /* Reduced top padding and side padding */
    }
    
    .profile-page-header h1 {
        font-size: 2rem; /* Reduced from 2.5rem */
        margin-bottom: 24px; /* Reduced spacing */
    }
    
    .profile-info-section {
        padding: 24px 16px; /* Reduced from 40px */
    }
    
    /* Profile avatar adjustments */
    .profile-avatar-large {
        width: 80px; /* Reduced from 120px */
        height: 80px;
        margin: 0 auto 20px auto; /* Reduced bottom margin */
    }
    
    .profile-initials-large {
        font-size: 1.8rem; /* Reduced from 2.5rem */
    }
    
    /* Grid adjustments for mobile */
    .profile-details-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 20px; /* Reduced gap */
        margin-top: 20px;
    }
    
    .profile-card {
        padding: 16px; /* Reduced from 24px */
        margin-bottom: 16px;
    }
    
    .profile-card h3 {
        font-size: 1.1rem; /* Reduced from 1.3rem */
        margin-bottom: 16px;
    }
    
    /* Profile field adjustments */
    .profile-field {
        flex-direction: row; /* Stack label and value vertically */
        align-items: flex-start;
        margin-bottom: 12px;
        gap: 4px;
    }
    
    .profile-field label {
        font-size: 14px;
        margin-right: 0;
        margin-bottom: 2px;
    }
    
    .profile-field span {
        font-size: 16px;
        font-weight: 600;
        color: var(--color-text); /* Make values more prominent */
    }
    
    /* Subscription section mobile adjustments */
    .subscription-details ul {
        margin: 12px 0;
        padding-left: 16px;
    }
    
    .subscription-details li {
        margin-bottom: 6px;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .premium-benefits {
        margin-top: 12px;
        padding: 12px;
    }
    
    .premium-benefits h4 {
        font-size: 1rem;
    }
    
    .premium-benefits ul {
        padding-left: 16px;
    }
    
    .premium-benefits li {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    /* Profile actions mobile adjustments */
    .profile-actions {
        padding: 20px 16px;
    }
    
    .profile-action-btn {
        padding: 12px 24px;
        font-size: 14px;
        width: 100%;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .profile-page-container {
        padding: 75px 8px 16px 8px;
    }
    
    .profile-page-header {
        margin-bottom: 20px;
    }
    
    .profile-page-header h1 {
        font-size: 1.8rem;
        margin-bottom: 16px;
    }
    
    .profile-info-section {
        padding: 20px 12px;
    }
    
    .profile-avatar-large {
        width: 70px;
        height: 70px;
        margin-bottom: 16px;
    }
    
    .profile-initials-large {
        font-size: 1.5rem;
    }
    
    .profile-details-grid {
        gap: 16px;
        margin-top: 16px;
    }
    
    .profile-card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .profile-card h3 {
        font-size: 1rem;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    
    .profile-field {
        margin-bottom: 10px;
    }
    
    .profile-field label {
        font-size: 13px;
    }
    
    .profile-field span {
        font-size: 15px;
    }
    
    .status-badge {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .subscription-details {
        font-size: 13px;
    }
    
    .subscription-details li {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .premium-benefits {
        padding: 10px;
        margin-top: 10px;
    }
    
    .premium-benefits h4 {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .premium-benefits li {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .payment-info {
        padding: 12px;
        border-radius: 8px;
    }
    
    .payment-info h4 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .price-option {
        padding: 8px;
        font-size: 13px;
    }
    
    .price-option strong {
        font-size: 0.9rem;
    }
    
    .address-display code {
        font-size: 10px;
    }
    
    .copy-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .payment-status {
        padding: 8px;
        font-size: 13px;
    }
    
    .profile-actions {
        padding: 16px 12px;
    }
    
    .profile-action-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .profile-page-container {
        padding-top: 60px; /* Reduced for landscape */
    }
    
    .profile-page-header {
        margin-bottom: 16px;
    }
    
    .profile-page-header h1 {
        font-size: 1.8rem;
        margin-bottom: 12px;
    }
    
    .profile-avatar-large {
        width: 60px;
        height: 60px;
        margin-bottom: 12px;
    }
    
    .profile-initials-large {
        font-size: 1.4rem;
    }
}

/* Improve button positioning on mobile */
@media (max-width: 768px) {
    #showPaymentInfoBtn {
        font-size: 13px;
        padding: 10px 16px;
        margin-top: 16px;
        width: 100%;
        text-align: center;
    }
    
}

/* Fix any overflow issues */
@media (max-width: 768px) {
    .profile-page-content {
        overflow-x: hidden;
        border-radius: 16px;
    }
    
    .profile-card {
        overflow-x: hidden;
    }
    
    /* Ensure subscription list items don't overflow */
    .subscription-details ul,
    .premium-benefits ul {
        padding-left: 16px;
        margin-right: 0;
    }
    
    .subscription-details li,
    .premium-benefits li {
        word-wrap: break-word;
        hyphens: auto;
    }
}

/* Dark mode mobile adjustments */
body.dark-mode .profile-page-container,
body.dark-mode .profile-card,
body.dark-mode .profile-page-content {
    background: var(--color-surface);
    color: var(--color-text);
}

@media (max-width: 768px) {
    body.dark-mode .profile-field span {
        color: var(--color-text);
    }
    
    body.dark-mode .subscription-details li,
    body.dark-mode .premium-benefits li {
        color: var(--color-text);
    }
}

.profile-page-header {
    text-align: center;
    margin-bottom: 40px;
}

.profile-page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

/* Profile content layout */
.profile-page-content {
    background: var(--color-surface);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.profile-info-section {
    padding: 40px;
}

/* Profile avatar */
.profile-avatar-large {
    width: 120px;
    height: 120px;
    margin: 0 auto 30px auto;
    position: relative;
    border-radius: 50%;
    background: var(--color-surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(66, 133, 244, 0.15);
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-initials-large {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* Profile details grid */
.profile-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.profile-card {
    background: var(--color-surface-alt);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(66, 133, 244, 0.1);
}

.profile-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(66, 133, 244, 0.1);
}

.profile-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 8px 0;
}

.profile-field label {
    font-weight: 600;
    color: var(--color-text);
    margin-right: 16px;
}

.profile-field span {
    color: var(--color-muted);
    font-weight: 500;
}

/* Subscription section */
.subscription-info {
    margin-top: 16px;
}

.subscription-status {
    margin-bottom: 20px;
}

.status-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
}

.status-badge.free {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.status-badge.premium {
    background: linear-gradient(135deg, #fff3e0 0%, #f3e5f5 100%);
    color: #f57c00;
    border: 1px solid #ffcc02;
}

/* Subscription duration styling */
.subscription-duration {
    margin: 10px 0;
    padding: 12px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 8px;
    border-left: 4px solid #4caf50;
    transition: all 0.3s ease;
}

.subscription-duration:hover {
    background: rgba(76, 175, 80, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

.subscription-duration p {
    margin: 0;
    font-weight: 600;
}

.subscription-duration p:first-child {
    font-size: 1em;
    margin-bottom: 5px;
}

.subscription-duration p:last-child {
    font-size: 0.9em;
    opacity: 0.8;
    font-weight: 400;
}

/* Cancel subscription button styling */
.cancel-subscription-btn {
    background: linear-gradient(135deg, #ff5722 0%, #e91e63 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 120px;
}

.cancel-subscription-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
    background: linear-gradient(135deg, #e64a19 0%, #c2185b 100%);
}

/* Refresh subscription button styling */
.refresh-subscription-btn {
    background: linear-gradient(135deg, #2196f3 0%, #21cbf3 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 120px;
}

.refresh-subscription-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    background: linear-gradient(135deg, #1976d2 0%, #00bcd4 100%);
}

.refresh-subscription-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Subscription actions container */
.subscription-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

@media (max-width: 480px) {
    .subscription-actions {
        flex-direction: column;
    }
    
    .refresh-subscription-btn,
    .cancel-subscription-btn {
        width: 100%;
        margin-right: 0 !important;
    }
}

/* Dark mode support for subscription duration */
body.dark-mode .subscription-duration {
    background: rgba(76, 175, 80, 0.2);
    border-left-color: #66bb6a;
}

body.dark-mode .subscription-duration:hover {
    background: rgba(76, 175, 80, 0.25);
}

.subscription-details ul {
    margin: 16px 0;
    padding-left: 20px;
}

.subscription-details li {
    margin-bottom: 8px;
    color: var(--color-text);
}

.premium-benefits {
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
}

.premium-benefits h4 {
    margin: 0 0 10px 0;
    color: #ffd700;
}

.premium-benefits ul {
    margin: 0;
    padding-left: 20px;
}

/* Payment info - HIDDEN BY DEFAULT */
.payment-info {
    display: none; /* Hide by default */
    margin-top: 24px;
    padding: 20px;
    background: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-surface-alt);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s ease;
}

.payment-info.show {
    display: block; /* Show when needed */
    opacity: 1;
    max-height: 1000px; /* Large enough to accommodate content */
}

.payment-info h4 {
    font-size: 1.1rem;
    color: var(--color-primary);
    margin: 0 0 16px 0;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.price-option {
    padding: 12px;
    background: var(--color-surface-alt);
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(66, 133, 244, 0.1);
}

.price-option.lifetime {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: #ffc107;
}

.price-option strong {
    color: var(--color-primary);
    font-size: 1.1rem;
}

.payment-address {
    margin: 20px 0;
}

.payment-address label {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.address-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface-alt);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.address-display code {
    flex: 1;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    background: none;
    border: none;
    color: var(--color-text);
}

.copy-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: #3367d6;
}

.payment-status {
    margin-top: 16px;
    padding: 12px;
    background: var(--color-surface-alt);
    border-radius: 8px;
}

/* Food Menu Styles */
.food-menu-container {
    padding: 20px;
}

.menu-button {
    transition: transform 0.2s, background-color 0.2s;
}

.menu-button:hover {
    transform: scale(1.02);
    background-color: #3367d6 !important;
}

.menu-button:active {
    transform: scale(0.98);
}

body.dark-mode .menu-button {
    background: #3b3b3b;
}

body.dark-mode .menu-button:hover {
    background: #4a4a4a !important;
}

/* Profile actions */
.profile-actions {
    padding: 30px 40px;
    background: var(--color-surface-alt);
    border-top: 1px solid rgba(224, 224, 224, 0.5);
    text-align: center;
}

.profile-action-btn {
    background: linear-gradient(135deg, #ea4335 0%, #d32f2f 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.profile-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(234, 67, 53, 0.3);
}

/* ===== PREMIUM UNLOCK BANNER STYLES ===== */

/* Premium unlock banner for non-premium users */
.premium-unlock-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 24px 20px;
    margin: 16px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.premium-unlock-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.1) 75%, transparent 75%);
    background-size: 20px 20px;
    opacity: 0.3;
    pointer-events: none;
}

.premium-unlock-banner h3 {
    margin: 0 0 12px 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.premium-unlock-banner p {
    margin: 0 0 20px 0;
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.unlock-premium-btn {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #2c3e50;
    padding: 12px 24px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
    letter-spacing: 0.5px;
}

.unlock-premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.6);
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
    color: #1a202c;
}

.unlock-premium-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

/* Mobile responsiveness for premium banner */
@media (max-width: 768px) {
    .premium-unlock-banner {
        padding: 20px 16px;
        margin: 12px 0;
        border-radius: 10px;
    }
    
    .premium-unlock-banner h3 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .premium-unlock-banner p {
        font-size: 0.9rem;
        margin-bottom: 16px;
    }
    
    .unlock-premium-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .premium-unlock-banner {
        padding: 16px 12px;
        margin: 10px 0;
    }
    
    .premium-unlock-banner h3 {
        font-size: 1.1rem;
    }
    
    .premium-unlock-banner p {
        font-size: 0.85rem;
    }
    
    .unlock-premium-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* Category tags pill style for Add Food modal */
.category-tag {
  display: inline-block;
  padding: 4px 14px;
  /* Remove margin, use gap in parent for spacing */
  border-radius: 18px;
  border: 1px solid #ccc;
  background: #eee;
  color: #333;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background 0.2s, color 0.2s, border 0.2s, box-shadow 0.2s;
}
.category-tag.active {
  background: var(--color-primary, #4285f4);
  color: #fff;
  border: 1px solid var(--color-primary, #4285f4);
}
.category-tag:hover, .category-tag:focus {
  background: #d2e3fc;
  color: #222;
  border: 1px solid #4285f4;
}
.category-tag.active:hover, .category-tag.active:focus {
  background: #3367d6;
  color: #fff;
  border: 1px solid #3367d6;
}

/* Tags wrapper and label styling */
.tags-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin: -32px 0 0 0;
}

.tags-label {
  font-size: 0.98rem;
  font-weight: 500;
  color: #555;
  margin-right: 20px;
  position: relative;
  top: 6px;
  right: -8px;
  min-width: fit-content;
  white-space: nowrap;
}

/* Ensure tags section is horizontally scrollable and tags are side by side */
#modalCategoryTags {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

/* Dark mode styles for category tags in Add Food modal */
body.dark-mode .category-tag {
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #444;
}
body.dark-mode .category-tag.active {
  background: var(--color-primary, #4285f4);
  color: #fff;
  border: 1px solid var(--color-primary, #4285f4);
}
body.dark-mode .category-tag:hover, body.dark-mode .category-tag:focus {
  background: #3a3a3a;
  color: #fff;
  border: 1px solid rgba(66, 133, 244, 0.8);
}
body.dark-mode .category-tag.active:hover, body.dark-mode .category-tag.active:focus {
  background: #3367d6;
  color: #fff;
  border: 1px solid #3367d6;
}
body.dark-mode #modalCategoryTags {
  background: transparent;
}

/* Dark mode styling for tags label */
body.dark-mode .tags-label {
  color: #b0b0b0;
}

/* NEW STYLES FOR AI ENHANCEMENT BUTTON */
#modalEnhanceBtn {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 12px; /* Add margin to separate from Add Food button */
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    letter-spacing: 0.5px;
}

#modalEnhanceBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

#modalEnhanceBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#modalEnhanceBtn.loading {
    animation: pulse 1.5s infinite;
}

/* WEIGHT HELPER STYLES */
#modalWeightHelperBtn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 12px;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    letter-spacing: 0.5px;
}

#modalWeightHelperBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 154, 158, 0.3);
    background: linear-gradient(135deg, #ff8a90 0%, #fdbde2 100%);
}

#weightHelperSection {
    background: var(--color-surface-alt);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border: 2px solid rgba(255, 154, 158, 0.2);
}

#weightHelperSection label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text);
    font-weight: 600;
    font-size: 15px;
}

#modalPortionDescription {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 16px;
    background-color: #f8f9fa;
    box-sizing: border-box;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    color: var(--color-text);
    outline: none;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
}

#modalPortionDescription:focus {
    border-color: #ff9a9e;
    background-color: white;
    box-shadow: 0 0 0 4px rgba(255, 154, 158, 0.1);
    transform: translateY(-1px);
}

#modalPortionDescription::placeholder {
    color: #94a3b8;
    font-style: normal;
    font-weight: 400;
}

#modalCalculateWeightBtn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', 'Roboto', Arial, sans-serif;
    letter-spacing: 0.5px;
}

#modalCalculateWeightBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(255, 154, 158, 0.3);
}

#modalCalculateWeightBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Dark mode styles for weight helper */
body.dark-mode #weightHelperSection {
    background: #23272a;
    border: 2px solid #333;
}

body.dark-mode #modalPortionDescription {
    background: #23272a;
    border: 2px solid #444;
    color: var(--color-text);
}

body.dark-mode #modalPortionDescription:focus {
    border-color: #ff9a9e;
    background-color: #2a2d30;
    box-shadow: 0 0 0 4px rgba(255, 154, 158, 0.1);
}

/* Fix white lines in dark mode - Add these rules to your CSS */

/* Fix profile popup borders in dark mode */
body.dark-mode .profile-popup {
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
    border: 1px solid #333; /* Changed from #e0e0e0 */
}

body.dark-mode .profile-menu-btn {
    border-bottom: 1px solid #333; /* Changed from #e0e0e0 */
}

/* Fix modal borders in dark mode */
body.dark-mode .modal-content,
body.dark-mode #setupModal .modal-content {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 20px 40px rgba(0,0,0,0.7), 0 10px 20px rgba(0,0,0,0.4);
    border: 1px solid #333; /* Ensure consistent dark border */
}

/* Fix modal input borders in dark mode */
body.dark-mode .modal-content input,
body.dark-mode .modal-content select {
    background: #23272a;
    border: 1px solid #444; /* Changed from #e1e8ed */
    color: var(--color-text);
}

/* Fix profile button border in dark mode */
body.dark-mode #profileBtn {
    background: var(--color-surface);
    border: 2px solid #333; /* Changed from #e0e0e0 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Fix address display border in dark mode */
body.dark-mode .address-display {
    background: var(--color-surface-alt);
    border: 1px solid #333; /* Changed from #e0e0e0 */
}

/* Fix profile page borders in dark mode */
body.dark-mode .profile-page-content,
body.dark-mode .profile-card {
    border: 1px solid #333;
}

body.dark-mode .profile-actions {
    border-top: 1px solid #333; /* Changed from rgba(224, 224, 224, 0.5) */
}

/* Fix calendar modal borders in dark mode */
body.dark-mode .calendar-modal {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 20px 40px rgba(0,0,0,0.7), 0 10px 20px rgba(0,0,0,0.4);
    border: 1px solid #333; /* Ensure border is dark */
}

/* Fix food details modal borders in dark mode */
body.dark-mode .food-details-content {
    background: #23272a;
    color: var(--color-text);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5), 0 10px 20px rgba(0,0,0,0.2);
    border: 1px solid #333; /* Changed from #444 to match other modals */
}

/* Fix meal tabs borders in dark mode - remove any white borders */
body.dark-mode .meal-tab {
    border: none; /* Remove any default borders */
}

/* Fix any remaining white borders on containers */
body.dark-mode .progress-container,
body.dark-mode table {
    border: none; /* Remove any white borders */
}

body.dark-mode #foodList li {
    border-left: 5px solid var(--color-primary);
}

/* Ensure calendar bar has proper dark border */
body.dark-mode #calendarBar {
    border-bottom: 1px solid #333; /* Changed from #222 to match other borders */
}

/* Fix premium unlock banner border in dark mode */
body.dark-mode .premium-unlock-banner {
    border: 1px solid rgba(255, 255, 255, 0.2); /* Keep this as is - it's intentionally light */
}

/* Fix any white lines in suggestions dropdown */
body.dark-mode #suggestions {
    background: var(--color-surface);
    border: 2px solid #333; /* Ensure dark border */
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

/* Fix category tags borders in dark mode */
body.dark-mode .category-tag {
    background: #222;
    color: #eee;
    border: 1px solid #444; /* Keep this as is - it's already dark */
}

/* Fix price option borders in dark mode */
body.dark-mode .price-option {
    background: var(--color-surface-alt);
    border: 1px solid #333; /* Changed from rgba(66, 133, 244, 0.1) */
}

body.dark-mode .price-option.lifetime {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: #444; /* Darker border for lifetime option */
}

/* Stripe payment styles */
.upgrade-btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 12px 20px;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(66, 133, 244, 0.3);
}

.upgrade-btn.yearly {
    background: linear-gradient(135deg, #34a853 0%, #4285f4 100%);
}

.pricing-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (min-width: 600px) {
    .pricing-options {
        flex-direction: row;
        gap: 12px;
    }
    
    .upgrade-btn {
        flex: 1;
    }
}

/* Premium Upgrade Modal Styles */
.premium-modal {
    display: block !important;
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.premium-modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 30px;
    border: none;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.premium-modal-icon {
    color: #4285f4;
    font-size: 48px;
    margin-bottom: 20px;
}

.premium-modal-title {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
    font-weight: 600;
}

.premium-modal-description {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
    font-size: 16px;
}

.premium-modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.premium-upgrade-btn {
    background: linear-gradient(135deg, #4285f4, #34a853) !important;
    color: white !important;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.premium-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(66, 133, 244, 0.4);
}

.premium-cancel-btn {
    background: #f1f3f4 !important;
    color: #5f6368 !important;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.premium-cancel-btn:hover {
    background: #e8eaed !important;
}

/* Dark mode styles for premium modal */
body.dark-mode .premium-modal-content {
    background-color: #2d2d2d;
    color: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
}

body.dark-mode .premium-modal-title {
    color: #ffffff;
}

body.dark-mode .premium-modal-description {
    color: #cccccc;
}

body.dark-mode .premium-cancel-btn {
    background: #444 !important;
    color: #cccccc !important;
}

body.dark-mode .premium-cancel-btn:hover {
    background: #555 !important;
}


