/* Nutrition Page Styles - Refactored for Modern Design System */

.nutrition-main {
    min-height: calc(100vh - 140px);
    padding: 100px 0 var(--space-2xl) 0;
    background: var(--bg-body);
}

/* Header Adjustments */
.site-header {
    border: none !important;
    box-shadow: var(--shadow-sm) !important;
    background: var(--bg-card) !important;
}

.nutrition-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.page-title i {
    color: var(--primary-purple);
}

.premium-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    background: var(--accent-gradient);
    color: var(--white);
    border-radius: var(--radius-full);
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

.page-subtitle {
    max-width: 600px;
    margin: 0 auto;
}

/* Actions Section */
.nutrition-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    margin-bottom: var(--space-xl);
}

.nutrition-actions.compact {
    margin-bottom: var(--space-lg);
}

/* Date Navigation */
.date-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-sm) var(--space-lg);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    border-radius: var(--radius-full);
}

.date-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.date-nav-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.current-date {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.current-date i {
    color: var(--primary-purple);
}

/* Quick Stats Grid */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
}

.stat-card {
    padding: var(--space-lg);
    display: flex;
    gap: var(--space-md);
    position: relative;
    border: 1px solid var(--border-glass);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.stat-card.calories .stat-icon {
    background: rgba(255, 107, 107, 0.1);
    color: var(--accent-pink);
}

.stat-card.protein .stat-icon {
    background: rgba(93, 95, 239, 0.1);
    color: var(--primary-purple);
}

.stat-card.carbs .stat-icon {
    background: rgba(78, 205, 196, 0.1);
    color: var(--success-green);
}

.stat-card.fat .stat-icon {
    background: rgba(255, 142, 83, 0.1);
    color: var(--accent-orange);
}

.stat-content {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-progress {
    margin-top: var(--space-sm);
}

.progress-bar {
    height: 6px;
    background: var(--bg-surface-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

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

.stat-card.calories .progress-fill { background: var(--accent-pink); }
.stat-card.protein .progress-fill { background: var(--primary-purple); }
.stat-card.carbs .progress-fill { background: var(--success-green); }
.stat-card.fat .progress-fill { background: var(--accent-orange); }

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-edit-btn {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.stat-edit-btn:hover {
    background: var(--bg-surface);
    color: var(--primary-purple);
}

/* Layout Container for Meals & Charts */
.meals-section {
    margin-bottom: var(--space-2xl);
    margin-top: var(--space-xl); /* Fix potential overlap with stats */
    position: relative;
    z-index: 5;
}

.meals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.section-title {
    margin-bottom: 0;
}

.meal-actions {
    display: flex;
    gap: var(--space-sm);
}

#dynamic-meals-container {
    display: grid;
    gap: var(--space-lg);
}

.meal-card {
    padding: var(--space-lg);
    position: relative;
    border: 1px solid var(--border-glass);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.meal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-default);
}

.meal-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.meal-title i {
    color: var(--primary-purple);
}

.meal-title small {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.meal-calories {
    font-weight: 700;
    color: var(--text-main);
    background: var(--bg-surface);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.meal-foods {
    margin-bottom: var(--space-md);
}

.empty-meal {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: var(--space-md);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: background-color var(--transition-fast);
}

.food-item:hover {
    background: var(--bg-surface-secondary);
}

.food-info {
    flex: 1;
}

.food-name {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.food-serving-editor {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin: 4px 0;
}

.serving-input {
    width: 60px;
    padding: 2px 6px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    text-align: center;
    background: var(--bg-card);
    color: var(--text-main);
}

.serving-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.food-macros {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.remove-food-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--error-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    opacity: 0.7;
}

.remove-food-btn:hover {
    background: rgba(255, 107, 107, 0.1);
    opacity: 1;
}

.add-food-btn {
    width: 100%;
    padding: var(--space-sm);
    border: 1px dashed var(--border-default);
    background: transparent;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: var(--primary-purple);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.add-food-btn:hover {
    border-color: var(--primary-purple);
    background: rgba(93, 95, 239, 0.05);
}

.add-meal-btn {
    width: 100%;
    padding: var(--space-md);
    border: 2px dashed var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: var(--radius-lg);
    margin-top: var(--space-lg);
}

.add-meal-btn:hover {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    background: rgba(93, 95, 239, 0.05);
}

/* Macro & Water Grid */
.macro-water-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    align-items: start;
}

.macro-section, .water-section {
    padding: var(--space-xl);
    height: 100%;
}

/* Macro Chart */
.macro-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    height: 100%;
}

.macro-chart-small {
    position: relative;
    width: 220px;
    height: 220px;
}

.chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.chart-calories {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

.chart-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.macro-info {
    flex: 1;
    min-width: 200px;
}

.macro-legend {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: var(--space-sm);
    display: inline-block;
}

.legend-item.protein .legend-color { background: var(--primary-purple); }
.legend-item.carbs .legend-color { background: var(--success-green); }
.legend-item.fat .legend-color { background: var(--accent-orange); }

.legend-label {
    font-weight: 500;
    color: var(--text-main);
    flex: 1;
}

.legend-value {
    font-weight: 700;
    color: var(--text-main);
}

/* Water Tracker */
.water-tracker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.water-glasses {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.water-glass {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.125rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.water-glass.filled {
    background: var(--primary-light); /* Fallback */
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(93, 95, 239, 0.4);
}

.water-glass:hover {
    transform: scale(1.1);
}

.water-stats {
    text-align: center;
}

.water-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-purple);
    line-height: 1;
    display: block;
}

.water-goal {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.water-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-surface);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
}

.water-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.water-btn:hover {
    background: var(--primary-purple);
    color: var(--white);
}

.water-increment {
    font-weight: 600;
    color: var(--text-main);
    min-width: 40px;
    text-align: center;
}

/* Modals */
.modal {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.modal-content {
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-2xl);
    padding: 0;
    overflow: hidden;
    animation: modalSlideUp 0.3s ease-out;
}

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

.modal-header {
    padding: var(--space-lg);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: var(--space-lg);
    max-height: calc(85vh - 70px);
    overflow-y: auto;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-main);
}

/* Forms in Modals */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.1);
}

/* Search Results */
.food-result {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

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

.food-result:hover {
    background: var(--bg-surface);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .nutrition-main {
        padding-top: 80px;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .nutrition-actions {
        gap: var(--space-xs);
    }
    
    .nutrition-actions button {
        flex: 1;
        min-width: 100px;
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8rem;
    }

    .quick-stats {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

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

    .macro-water-container {
        grid-template-columns: 1fr;
    }

    .macro-content {
        flex-direction: column;
    }

    .meal-card {
        padding: var(--space-md);
    }

    .meal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .meal-stats {
        align-self: flex-end;
        margin-top: -30px; /* Pull up next to title on mobile if possible, or just let it stack */
    }
    
    .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        margin: 0 !important;
    }
    
    .modal-body {
        max-height: calc(100vh - 60px);
    }
}

/* Meal Planner Specifics */
.planner-step {
    padding-bottom: var(--space-xl);
}

.meal-template-options,
.complexity-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
}

.template-option-card,
.complexity-card {
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.template-option input:checked + .template-option-card,
.complexity-option input:checked + .complexity-card {
    border-color: var(--primary-purple);
    background: rgba(93, 95, 239, 0.05);
    box-shadow: 0 0 0 2px var(--primary-purple) inset;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    text-align: center;
    background: var(--bg-surface);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
}

@media (max-width: 600px) {
    .summary-stats {
        grid-template-columns: 1fr 1fr;
    }
}

.generated-meal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

/* Toggle Switch Style for Inputs */
.input-with-toggle {
    display: flex;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.input-with-toggle input {
    border: none;
    border-radius: 0;
    flex: 1;
}

.unit-toggle {
    display: flex;
    background: var(--bg-surface-secondary);
    padding: 2px;
}

.unit-btn {
    padding: var(--space-xs) var(--space-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.unit-btn.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

/* Light Mode Overrides for Specific Text Issues */
body:not([data-theme="dark"]) .stat-label,
body:not([data-theme="dark"]) .water-goal,
body:not([data-theme="dark"]) .meal-stats,
body:not([data-theme="dark"]) .chart-label,
body:not([data-theme="dark"]) .progress-text,
body:not([data-theme="dark"]) .food-macros {
    color: var(--gray-500);
}

body:not([data-theme="dark"]) .stat-value,
body:not([data-theme="dark"]) .water-amount,
body:not([data-theme="dark"]) .chart-calories,
body:not([data-theme="dark"]) .meal-calories {
    color: var(--gray-800);
}

body:not([data-theme="dark"]) .meal-card,
body:not([data-theme="dark"]) .stat-card,
body:not([data-theme="dark"]) .water-section,
body:not([data-theme="dark"]) .macro-section {
    background: var(--white);
    border-color: var(--gray-200);
}

body:not([data-theme="dark"]) .date-nav-btn {
    background: var(--white);
    border-color: var(--gray-200);
}

body:not([data-theme="dark"]) .date-nav-btn:hover {
    background: var(--gray-50);
}

/* Fix for Modal Steps Visibility */
.planner-step,
.calculator-step-content {
    display: none;
}

.planner-step.active,
.calculator-step-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

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

/* Calculator Progress Steps */
.calculator-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    position: relative;
}

.calculator-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--border-default);
    z-index: 0;
}

.step {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    opacity: 0.6;
    transition: all var(--transition-base);
}

.step.active {
    opacity: 1;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all var(--transition-base);
}

.step.active .step-number {
    background: var(--primary-purple);
    border-color: var(--primary-purple);
    color: var(--white);
    box-shadow: 0 0 0 4px rgba(93, 95, 239, 0.2);
}

.step-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.step.active .step-label {
    color: var(--primary-purple);
}
