* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --primary-dark: #45a049;
    --secondary-color: #2196F3;
    --background: #f5f5f5;
    --surface: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border: #e0e0e0;
    --error: #f44336;
    --carbs: #FF9800;
    --protein: #2196F3;
    --fat: #FF5722;
    --sugar: #E91E63;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 30px;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.sub-nav-container {
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: none;
}

.sub-nav-container.active {
    display: block;
}

.sub-nav {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.sub-nav-btn {
    padding: 6px 14px;
    font-size: 13px;
}

header h1 {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 700;
}

nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

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

/* Main Sections */
.main-section {
    display: none;
}

.main-section.active {
    display: block;
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dashboard-header h2 {
    font-size: 28px;
    font-weight: 600;
}

.date-display {
    color: var(--text-secondary);
    font-size: 16px;
}

.nutrition-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.nutrition-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.goal-badge {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--background);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Progress Circle */
.progress-circle {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 20px auto;
}

.progress-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progress-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.progress-bar {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.5s ease;
    stroke-linecap: round;
}

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

.progress-text span:first-child {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.card-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.remaining {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Macro Bars */
.macro-bars {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.macro-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.macro-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
}

.macro-amount {
    color: var(--text-primary);
    font-weight: 600;
}

.progress-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

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

.progress-bar-fill.carbs {
    background: var(--carbs);
}

.progress-bar-fill.protein {
    background: var(--protein);
}

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

.progress-bar-fill.sugar {
    background: var(--sugar);
}

.macro-goal {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.action-btn {
    flex: 1;
    padding: 16px;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.3s;
}

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

.action-btn .icon {
    font-size: 20px;
}

/* Food Diary */
.meals-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.meal-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.meal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.meal-calories {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.food-list {
    min-height: 50px;
    margin-bottom: 15px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--background);
    border-radius: 8px;
    transition: background 0.2s;
}

.food-item:hover {
    background: #eeeeee;
}

.food-info {
    flex: 1;
}

.food-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.food-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.food-calories {
    font-weight: 600;
    color: var(--primary-color);
    margin-right: 10px;
}

.food-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.btn-remove:hover {
    background: #d32f2f;
}

.add-food-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

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

/* Search Page */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

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

.search-btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.search-btn:hover {
    background: var(--primary-dark);
}

.search-results {
    display: grid;
    gap: 15px;
}

.food-result {
    background: var(--surface);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.result-name {
    font-weight: 600;
    font-size: 16px;
}

.result-calories {
    color: var(--primary-color);
    font-weight: 600;
}

.result-macros {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

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

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

/* Food Add Form */
.food-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.goals-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* My Foods Page */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 600;
}

.my-foods-list {
    display: grid;
    gap: 15px;
}

.custom-food-item {
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.custom-food-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.custom-food-info {
    flex: 1;
}

.custom-food-name {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 8px;
}

.custom-food-nutrition {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: var(--text-secondary);
}

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

.btn-edit {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-edit:hover {
    background: #1976D2;
}

.btn-delete-food {
    background: var(--error);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-delete-food:hover {
    background: #d32f2f;
}

/* Body Measurements */
.measurements-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.measurement-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-unit {
    font-size: 14px;
    color: var(--text-secondary);
}

.measurements-list-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.measurements-list-container h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.measurements-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.measurement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    transition: background 0.2s;
}

.measurement-item:hover {
    background: #eeeeee;
}

.measurement-date {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
}

.measurement-details {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.measurement-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.measurement-detail-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.measurement-detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

.measurement-actions {
    display: flex;
    gap: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 15px;
    }

    .main-nav {
        width: 100%;
        justify-content: space-around;
    }

    .sub-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nutrition-cards {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        flex-direction: column;
    }

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

    .measurement-stats {
        grid-template-columns: 1fr;
    }

    .measurement-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .measurement-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}
