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

:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --secondary-color: #2196F3;
    --accent-color: #FFC107;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #ddd;
    --header-bg: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --footer-bg: #333;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --shadow: rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #444;
    --header-bg: linear-gradient(135deg, #1a5a1a 0%, #1a3a5a 100%);
    --footer-bg: #1a1a1a;
    --input-bg: #333;
    --input-border: #555;
    --shadow: rgba(0,0,0,0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

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

header {
    background: var(--header-bg);
    color: white;
    padding: 40px 0;
    text-align: center;
    position: relative;
    transition: background 0.3s;
}

.header-controls {
    position: absolute;
    top: 15px;
    right: 20px;
}

.control-group {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

[data-theme="dark"] .control-btn {
    background: rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.2);
}

[data-theme="dark"] .control-btn:hover {
    background: rgba(0,0,0,0.5);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.version-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.85rem;
    margin-top: 15px;
}

[data-theme="dark"] .version-badge {
    background: rgba(0,0,0,0.3);
}

main {
    padding: 40px 20px;
}

.input-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 30px;
    transition: background 0.3s, box-shadow 0.3s;
}

.input-section h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.5rem;
}

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

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

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, background 0.3s;
    background: var(--input-bg);
    color: var(--text-primary);
}

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

.submit-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.result-section {
    animation: fadeIn 0.5s ease;
}

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

.result-section h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.bmi-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 30px;
    text-align: center;
    transition: background 0.3s;
}

.bmi-card h3 {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.bmi-display {
    margin-bottom: 20px;
}

#bmiValue {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary-color);
}

#bmiCategory {
    font-size: 1.2rem;
    margin-left: 10px;
    padding: 5px 15px;
    border-radius: 20px;
    background: var(--primary-color);
    color: white;
}

.bmi-scale {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 20px;
}

.scale-item {
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    font-size: 0.85rem;
    color: white;
}

.scale-item.underweight { background: #2196F3; }
.scale-item.normal { background: #4CAF50; }
.scale-item.overweight { background: #FFC107; color: #333; }
.scale-item.obese { background: #F44336; }

.recommendations {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.rec-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow);
    border-left: 4px solid;
    min-height: 100px;
    transition: background 0.3s;
}

.rec-card h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.sleep-card { border-left-color: #66BB6A; }
.exercise-card { border-left-color: #42A5F5; }
.diet-card { border-left-color: #FFA726; }
.meal-plan-card { border-left-color: #9C27B0; }

.rec-item {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    transition: background 0.3s;
}

.rec-item:last-child {
    margin-bottom: 0;
}

.rec-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.rec-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.rec-source {
    font-size: 0.75rem;
    color: #999;
    margin-top: 8px;
    font-style: italic;
}

.sources-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: background 0.3s;
}

.sources-section h3 {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.sources-section ul {
    list-style: none;
}

.sources-section li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sources-section li:last-child {
    border-bottom: none;
}

.meal-plan-container {
    max-height: none;
    overflow-y: visible;
}

.nutrition-summary {
    background: linear-gradient(135deg, #4CAF50 0%, #2196F3 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
    margin-bottom: 20px;
}

.nutrition-summary h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

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

.nutrition-item {
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.nutrition-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
}

.nutrition-value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    margin: 5px 0;
}

.nutrition-source {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    font-style: italic;
}

.calculation-method {
    font-size: 0.8rem;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.3);
    line-height: 1.5;
}

.day-nutrition-total {
    background: linear-gradient(135deg, #FF9800 0%, #F44336 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
    margin-bottom: 20px;
}

.day-nutrition-total h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

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

.total-item {
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
}

.total-item strong {
    display: block;
    font-size: 1.2rem;
    margin-top: 5px;
}

.weekday-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.weekday-tab {
    padding: 8px 15px;
    border-radius: 20px;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.weekday-tab.active {
    background: var(--primary-color);
    color: white;
}

.day-meals {
    display: grid;
    gap: 15px;
}

.meal-block {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid var(--primary-color);
    transition: background 0.3s;
}

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

.meal-time {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.meal-subtotal {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--card-bg);
    padding: 5px 10px;
    border-radius: 15px;
    transition: background 0.3s;
}

.meal-content {
    display: grid;
    gap: 10px;
}

.meal-item {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px;
    border-left: 3px solid var(--primary-color);
    transition: background 0.3s;
}

.food-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.food-detail {
    display: block;
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-bottom: 3px;
}

.food-source {
    display: block;
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
}

.data-source-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-top: 15px;
    transition: background 0.3s;
}

.meal-notes {
    font-size: 0.8rem;
    color: #999;
    margin-top: 10px;
    font-style: italic;
}

.collapsible {
    position: relative;
}

.collapse-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.collapse-toggle h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.collapse-icon {
    font-size: 0.8rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.collapse-toggle.active .collapse-icon {
    transform: rotate(180deg);
}

.collapse-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapse-content.expanded {
    max-height: 1000px;
    padding-top: 15px;
}

footer {
    background: var(--footer-bg);
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    transition: background 0.3s;
}

footer p {
    opacity: 0.8;
    font-size: 0.9rem;
}

.footer-source {
    font-size: 0.8rem !important;
    opacity: 0.6 !important;
    margin-top: 5px;
}

.version-info {
    font-size: 0.8rem !important;
    opacity: 0.5 !important;
    margin-top: 10px;
}

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

    header h1 {
        font-size: 1.8rem;
    }

    #bmiValue {
        font-size: 3rem;
    }

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

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

    .meal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .meal-subtotal {
        font-size: 0.75rem;
    }

    .header-controls {
        position: static;
        margin-bottom: 15px;
    }
}