/* Nutrition Tracker Styles */

.nutrition-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 100px 20px 40px;
}

/* Loading & Auth States */
.loading-state,
.auth-message {
    text-align: center;
    padding: 80px 20px;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid #fce4ec;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

/* Header */
.nutrition-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}

.nutrition-header h1 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    font-size: 0.85rem;
    color: var(--text-light);
}

.btn-goals {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.btn-goals:hover {
    background: #c2185b;
}

.btn-signout {
    background: none;
    border: 1px solid #ddd;
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-signout:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Date Navigation */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.date-nav-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.date-nav-btn:hover {
    background: #c2185b;
}

.date-display {
    font-size: 1.3rem;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
    color: var(--text-dark);
}

.today-btn {
    background: none;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 6px;
    padding: 4px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Goal Progress Cards */
.goals-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.goal-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s;
}

.goal-card:hover {
    transform: translateY(-2px);
}

.goal-label {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}

.goal-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.goal-value .unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
}

.goal-target {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

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

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

.progress-bar-fill.protein {
    background: linear-gradient(90deg, #e91e63, #ff6b9d);
}

.progress-bar-fill.calories {
    background: linear-gradient(90deg, #ff9800, #ffc107);
}

.progress-bar-fill.fat {
    background: linear-gradient(90deg, #9c27b0, #ce93d8);
}

.progress-bar-fill.protein-pct {
    background: linear-gradient(90deg, #2196f3, #64b5f6);
}

.progress-bar-fill.over-goal {
    background: linear-gradient(90deg, #f44336, #ff5252) !important;
}

/* Weight & BMI Box */
.weight-bmi-box {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.weight-bmi-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.weight-bmi-current {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.weight-bmi-label {
    font-size: 0.78rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.weight-bmi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.weight-bmi-unit {
    font-size: 0.85rem;
    color: var(--text-light);
}

.weight-bmi-date {
    font-size: 0.75rem;
    color: #bbb;
    margin-left: 4px;
}

.weight-bmi-category {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.weight-bmi-category.underweight { background: #fff3e0; color: #e65100; }
.weight-bmi-category.normal { background: #e8f5e9; color: #2e7d32; }
.weight-bmi-category.overweight { background: #fff3e0; color: #e65100; }
.weight-bmi-category.obese { background: #fce4ec; color: #c62828; }

.weight-bmi-divider {
    width: 1px;
    height: 32px;
    background: #e0e0e0;
}

.weight-log-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.weight-input {
    width: 100px;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

.weight-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.btn-log-weight {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.btn-log-weight:hover {
    background: #c2185b;
}

/* Weight Chart */
.weight-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.weight-chart-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-dark);
}

.weight-chart-range {
    display: flex;
    gap: 4px;
}

.range-btn {
    background: none;
    border: 1px solid #e0e0e0;
    color: var(--text-light);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.range-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.range-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Meal Sections */
.meal-section {
    background: white;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-bg, #fce4ec);
}

.meal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark);
}

.meal-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meal-totals {
    font-size: 0.8rem;
    color: var(--text-light);
}

.btn-add-food {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    flex-shrink: 0;
}

.btn-add-food:hover {
    background: #c2185b;
}

.meal-empty {
    color: #bbb;
    font-size: 0.85rem;
    font-style: italic;
    padding: 4px 0;
}

/* Food Entry Row */
.food-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

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

.food-name {
    font-weight: 500;
    flex: 1;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.food-serving {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 6px;
}

.food-macros {
    display: flex;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-light);
    margin: 0 15px;
}

.food-macros span {
    white-space: nowrap;
}

.macro-protein { color: #e91e63; font-weight: 500; }
.macro-calories { color: #ff9800; font-weight: 500; }
.macro-fat { color: #9c27b0; font-weight: 500; }

.food-actions {
    display: flex;
    gap: 4px;
}

.food-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    padding: 4px 6px;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.food-actions button:hover {
    color: var(--primary-color);
    background: #fce4ec;
}

/* Add Food Button */
.btn-add-entry {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    margin-bottom: 25px;
    background: white;
    border: 2px dashed #ddd;
    border-radius: 12px;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal h3 {
    margin: 0 0 20px;
    font-size: 1.3rem;
    color: var(--text-dark);
}

.modal .form-group {
    margin-bottom: 14px;
}

.modal .form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.modal .form-input,
.modal select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.modal .form-input:focus,
.modal select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.form-row {
    display: grid;
    gap: 10px;
}

.form-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row-2 {
    grid-template-columns: 1fr 1fr;
}

/* Search */
.search-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-input-group input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
}

.search-input-group input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.btn-search {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.3s;
}

.btn-search:hover {
    background: #c2185b;
}

.search-results {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.search-result-item {
    padding: 10px 12px;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #fce4ec;
}

.search-result-item strong {
    font-size: 0.9rem;
    color: var(--text-dark);
}

.search-result-item small {
    color: var(--text-light);
    font-size: 0.78rem;
}

.search-result-item .result-macros {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.search-message {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 8px;
}

.search-message.success {
    color: #4caf50;
}

.separator {
    text-align: center;
    color: #ccc;
    font-size: 0.8rem;
    margin: 14px 0;
    position: relative;
}

.separator::before,
.separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e0e0e0;
}

.separator::before { left: 0; }
.separator::after { right: 0; }

/* Modal Buttons */
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-cancel {
    background: none;
    border: 2px solid #ddd;
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel:hover {
    border-color: var(--text-dark);
    color: var(--text-dark);
}

.btn-save {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-save:hover {
    background: #c2185b;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chart-card h3 {
    margin: 0 0 15px;
    font-size: 1rem;
    color: var(--text-dark);
}

.chart-card canvas {
    max-height: 250px;
}

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Notification */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    z-index: 3000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background: #4caf50;
}

.notification.error {
    background: #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .nutrition-container {
        padding: 80px 15px 30px;
    }

    .nutrition-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .goals-section {
        grid-template-columns: 1fr;
    }

    .goal-card {
        display: flex;
        align-items: center;
        gap: 15px;
        text-align: left;
        padding: 14px 18px;
    }

    .goal-card .goal-label {
        min-width: 60px;
        margin-bottom: 0;
    }

    .goal-card .goal-value {
        font-size: 1.3rem;
        min-width: 70px;
    }

    .goal-card .goal-target {
        margin-top: 0;
        min-width: 60px;
    }

    .goal-card .progress-bar {
        flex: 1;
        margin-top: 0;
    }

    .weight-bmi-box {
        flex-direction: column;
        align-items: flex-start;
    }

    .weight-bmi-info {
        width: 100%;
    }

    .weight-log-form {
        width: 100%;
    }

    .weight-input {
        flex: 1;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .food-macros {
        gap: 6px;
        font-size: 0.75rem;
        margin: 0 8px;
    }

    .date-display {
        font-size: 1.1rem;
        min-width: 160px;
    }

    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .form-row-2 {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 20px;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .food-entry {
        flex-wrap: wrap;
        gap: 4px;
    }

    .food-macros {
        width: 100%;
        justify-content: flex-start;
        margin: 0;
        padding-left: 0;
    }
}
