:root {
    --primary: #ff6b6b;
    --secondary: #4ecdc4;
    --dark: #2d3436;
    --light: #f7f9fc;
    --white: #ffffff;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e74c3c;

    /* Meal type colors */
    --breakfast: #f39c12;
    --lunch: #27ae60;
    --dinner: #3498db;
    --snack: #9b59b6;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--light);
    color: var(--dark);
}

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

.hidden {
    display: none !important;
}

/* Landing Page */
#landing-page {
    text-align: center;
    margin-top: 100px;
}

#landing-page h1 {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0;
}

.hero h2 {
    font-size: 2rem;
    color: var(--dark);
    margin-bottom: 1rem;
}

.hero p {
    color: #666;
    max-width: 500px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

/* App Dashboard */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

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

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--dark);
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-email {
    color: #666;
    font-size: 0.9rem;
}

#logout-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

#logout-btn:hover {
    background: var(--light);
}

/* Daily Summary */
.daily-summary {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.summary-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

#today-date {
    color: #666;
    font-size: 0.9rem;
}

.calorie-progress {
    text-align: center;
}

.progress-info {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.progress-info .separator {
    color: #ccc;
    margin: 0 4px;
}

.progress-info .unit {
    font-size: 1rem;
    font-weight: 400;
    color: #666;
}

.progress-bar-container {
    background: #e0e0e0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-container.small {
    height: 8px;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--success);
    border-radius: 10px;
    transition: width 0.3s ease, background 0.3s ease;
}

.progress-bar.near {
    background: var(--warning);
}

.progress-bar.over {
    background: var(--danger);
}

.progress-remaining {
    color: #666;
    font-size: 0.9rem;
}

/* Upload Section */
.upload-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.upload-section h3 {
    margin: 0 0 16px 0;
    font-size: 1.2rem;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-area {
    border: 2px dashed #ccc;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    background: var(--light);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(255, 107, 107, 0.05);
}

.upload-area p {
    margin: 0 0 16px 0;
    color: #666;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-secondary,
.btn-camera {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-secondary:hover,
.btn-camera:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

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

.btn-camera:hover {
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.meal-options {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.option-group {
    flex: 1;
    min-width: 120px;
}

.option-group label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.option-group input,
.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
}

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

/* Loading Indicator */
#loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    color: var(--primary);
    font-weight: 500;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Calendar Section */
.calendar-section {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.calendar-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.nav-btn {
    background: var(--light);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--dark);
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #e0e0e0;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.calendar-weekdays span {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    padding: 8px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    min-height: 80px;
    padding: 8px;
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.calendar-day:hover {
    background: #e8eaed;
    transform: scale(1.02);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.empty:hover {
    transform: none;
}

.calendar-day.today {
    border: 2px solid var(--primary);
}

.calendar-day.has-meals {
    background: #e8f5e9;
}

.calendar-day.over-goal {
    background: #ffebee;
}

.calendar-day.near-goal {
    background: #fff8e1;
}

.day-number {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.day-calories {
    font-size: 0.75rem;
    color: #666;
    font-weight: 500;
}

.day-progress {
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.day-progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
}

.calendar-day.over-goal .day-progress-fill {
    background: var(--danger);
}

.calendar-day.near-goal .day-progress-fill {
    background: var(--warning);
}

.day-thumbnails {
    display: flex;
    gap: 2px;
    margin-top: auto;
    flex-wrap: wrap;
}

.day-thumbnail {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

.more-meals {
    font-size: 0.65rem;
    color: #888;
    display: flex;
    align-items: center;
}

/* Day Detail View */
.day-detail {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.day-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    position: relative;
}

.day-detail-header h3 {
    margin: 0;
    flex: 1;
}

.close-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 0;
    line-height: 1;
}

.close-btn:hover {
    color: var(--dark);
}

.day-summary {
    font-size: 0.9rem;
    color: #666;
}

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

.meal-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--light);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    position: relative;
}

.meal-card:hover {
    background: #e8eaed;
    transform: translateX(4px);
}

.meal-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.meal-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.meal-time-display {
    color: #888;
    font-size: 0.85rem;
}

.meal-calories {
    font-weight: 600;
    margin-left: auto;
}

.delete-meal-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #888;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.delete-meal-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.no-meals {
    text-align: center;
    color: #888;
    padding: 20px;
}

/* Meal Type Badges */
.meal-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.meal-badge.fruehstueck {
    background: rgba(243, 156, 18, 0.15);
    color: var(--breakfast);
}

.meal-badge.mittagessen {
    background: rgba(39, 174, 96, 0.15);
    color: var(--lunch);
}

.meal-badge.abendessen {
    background: rgba(52, 152, 219, 0.15);
    color: var(--dinner);
}

.meal-badge.snack {
    background: rgba(155, 89, 182, 0.15);
    color: var(--snack);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    position: relative;
}

.modal-content .close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1;
}

.modal-content .close:hover {
    opacity: 0.8;
}

#modal-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

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

#modal-meal-datetime {
    color: #888;
    font-size: 0.9rem;
}

.modal-body h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
}

.ingredients-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.ingredient-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--light);
    border-radius: 8px;
}

.ingredient-name {
    flex: 1;
    font-weight: 500;
}

.ingredient-quantity {
    color: #888;
    margin-right: 16px;
}

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

.no-ingredients {
    color: #888;
    text-align: center;
    padding: 20px;
}

.modal-total {
    padding: 16px;
    background: var(--light);
    border-radius: 8px;
    text-align: right;
    font-size: 1.1rem;
}

#modal-total-calories {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.3rem;
}

/* Settings Modal */
.settings-content {
    padding: 24px;
}

.settings-content h2 {
    margin: 0 0 24px 0;
}

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

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

.setting-group label {
    font-weight: 500;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1.1rem;
}

.input-with-unit .unit {
    color: #888;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 4px;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    z-index: 2001;
    line-height: 1;
}

.close-lightbox:hover {
    opacity: 0.8;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    animation: slideUp 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

.toast.error {
    background: var(--danger);
}

.toast button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.toast button:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    nav {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

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

    #user-email {
        display: none;
    }

    .container {
        padding: 12px;
    }

    .daily-summary,
    .upload-section,
    .calendar-section,
    .day-detail {
        padding: 16px;
        border-radius: 12px;
    }

    .progress-info {
        font-size: 1.5rem;
    }

    .calendar-day {
        min-height: 60px;
        padding: 4px;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .day-calories {
        font-size: 0.65rem;
    }

    .day-thumbnails {
        display: none;
    }

    .upload-buttons {
        flex-direction: column;
    }

    .btn-secondary,
    .btn-camera {
        width: 100%;
        justify-content: center;
    }

    .meal-options {
        flex-direction: column;
    }

    .option-group {
        min-width: 100%;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: 12px;
    }

    #modal-image {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .hero h2 {
        font-size: 1.5rem;
    }

    .calendar-weekdays span {
        font-size: 0.7rem;
    }

    .calendar-day {
        min-height: 50px;
    }

    .meal-card {
        padding: 8px;
        gap: 10px;
    }

    .meal-thumbnail {
        width: 50px;
        height: 50px;
    }

    .meal-info {
        font-size: 0.85rem;
    }
}
