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

:root {
    --primary: #FF5252;
    --primary-light: #FF6E40;
    --accent: #FFB74D;
    --success: #66BB6A;
    --warning: #FFD54F;
    --info: #42A5F5;
    --text: #1A237E;
    --text-light: #455A64;
    --bg: #FFFFFF;
    --bg-alt: #F1F8E9;
    --border: #C8E6C9;
    --radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    color: var(--text);
    line-height: 1.6;
    background: linear-gradient(135deg, #FFFDE7 0%, #F1F8E9 50%, #E0F2F1 100%);
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #FF5252 0%, #FFB74D 50%, #66BB6A 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
}

.language-switcher {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
    background: white;
    color: #FF5252;
    border-color: white;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    opacity: 0.95;
    font-weight: 600;
}

.description {
    font-size: 1rem;
    opacity: 0.85;
    font-style: italic;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-top: 2rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1.5rem;
    background: var(--bg-alt);
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 150px;
    padding: 1rem 1.5rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s;
    color: var(--text-light);
}

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

.tab-btn.active {
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    border-color: transparent;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

main {
    min-height: 500px;
}

/* Search Section */
.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input {
    flex: 1;
    padding: 1.2rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.1rem;
    transition: border-color 0.3s;
    font-family: 'Poppins', sans-serif;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.search-btn {
    padding: 1.2rem 2.5rem;
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

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

.search-btn:active {
    transform: translateY(0);
}

/* Search Tips */
.search-tips {
    background: linear-gradient(135deg, #FFF5E1 0%, #FFE5CC 100%);
    border: 2px solid #FFD7B5;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-tips p {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.search-tips ul {
    list-style: none;
    padding-left: 0;
}

.search-tips li {
    padding: 0.5rem 0 0.5rem 1.75rem;
    position: relative;
    color: var(--text);
}

.search-tips li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

/* Search Results */
.search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.food-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
}

.food-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.food-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.food-source {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.nutrition-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.nutrition-item {
    background: var(--bg-alt);
    padding: 0.75rem;
    border-radius: 8px;
}

.nutrition-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
}

.nutrition-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 0.25rem;
}

.food-actions {
    display: flex;
    gap: 0.75rem;
}

.add-btn {
    flex: 1;
    padding: 0.75rem;
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

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

.quantity-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    text-align: center;
}

/* Diary Section */
.diary-container {
    max-width: 900px;
    margin: 0 auto;
}

.date-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
    justify-content: center;
}

.date-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    background: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

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

.date-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.meals-container {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.meal-section {
    background: linear-gradient(135deg, #FFF5E1 0%, #FFE5CC 100%);
    border: 2px solid #FFD7B5;
    border-radius: var(--radius);
    padding: 1.5rem;
}

.meal-section h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.meal-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.meal-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary);
}

.meal-item-name {
    font-weight: 600;
    color: var(--text);
}

.meal-item-calories {
    background: var(--warning);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-weight: 600;
}

.add-meal-btn {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.add-meal-btn:hover {
    background: var(--bg-alt);
}

.daily-summary {
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.daily-summary h3 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}

.nutrition-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.nutrition-label {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.nutrition-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.nutrition-unit {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* AI Chat Section */
.insights-container {
    max-width: 900px;
    margin: 0 auto;
}

.ai-chat {
    display: flex;
    flex-direction: column;
    height: 600px;
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-alt);
}

.chat-message {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 12px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    margin-left: auto;
    max-width: 80%;
    text-align: right;
    font-weight: 600;
}

.bot-message {
    background: white;
    color: var(--text);
    max-width: 80%;
    line-height: 1.7;
    border-left: 4px solid var(--primary);
}

.chat-input-area {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-top: 2px solid var(--border);
}

.chat-input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
}

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

.chat-send-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #FF6B6B 0%, #FFA366 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Loading */
.loading-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;
    flex-direction: column;
    gap: 1rem;
    z-index: 10000;
}

.spinner {
    border: 4px solid rgba(255, 107, 107, 0.2);
    border-top: 4px solid #FF6B6B;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

#loadingText {
    color: white;
    font-weight: 600;
}

/* Footer */
footer {
    background: var(--bg-alt);
    border-top: 2px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

footer p {
    margin: 0.5rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .header-top {
        flex-direction: column;
        gap: 1rem;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        min-width: unset;
    }

    .search-box {
        flex-direction: column;
    }

    .search-results {
        grid-template-columns: 1fr;
    }

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

    .ai-chat {
        height: auto;
        min-height: 400px;
    }

    .chat-message {
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {
    .container {
        border-radius: 0;
        margin-top: 0;
    }

    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .language-switcher {
        gap: 0.25rem;
    }

    .lang-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    main {
        padding: 1rem;
    }

    .tab-content {
        padding: 1rem;
    }
}