:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #e5e7eb;
    --background: #ffffff;
    --surface: #f9fafb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* BMI Category Colors */
    --underweight: #3b82f6;
    --normal: #10b981;
    --overweight: #f59e0b;
    --obese: #ef4444;
}

[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --secondary-color: #374151;
    --background: #111827;
    --surface: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border: #374151;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

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

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

.container {
    min-height: 100vh;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.calculator-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.input-section, .results-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.input-section h2, .results-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
}

.unit-toggle {
    display: flex;
    background: var(--background);
    border-radius: var(--radius);
    padding: 0.25rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.unit-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--text-secondary);
}

.unit-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

.bmi-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

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

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input, .form-group select {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-group .unit {
    position: absolute;
    right: 0.75rem;
    top: 2.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}

.calculate-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.calculate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.bmi-display {
    text-align: center;
    margin-bottom: 2rem;
}

.bmi-number {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.bmi-status {
    font-size: 1.25rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    display: inline-block;
}

.bmi-status.underweight {
    background: var(--underweight);
    color: white;
}

.bmi-status.normal {
    background: var(--normal);
    color: white;
}

.bmi-status.overweight {
    background: var(--overweight);
    color: white;
}

.bmi-status.obese {
    background: var(--obese);
    color: white;
}

.bmi-chart {
    position: relative;
    margin: 2rem 0;
}

.chart-bar {
    display: flex;
    height: 60px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chart-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    position: relative;
    text-align: center;
    padding: 0.5rem;
}

.chart-segment.underweight {
    background: var(--underweight);
}

.chart-segment.normal {
    background: var(--normal);
}

.chart-segment.overweight {
    background: var(--overweight);
}

.chart-segment.obese {
    background: var(--obese);
}

.chart-segment::after {
    content: attr(data-range);
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.bmi-indicator {
    position: absolute;
    top: -10px;
    width: 20px;
    height: 80px;
    background: var(--text-primary);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
    display: none;
}

.bmi-indicator::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--text-primary);
}

.health-info {
    display: grid;
    gap: 1.5rem;
}

.info-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.info-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.calorie-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calorie-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.calorie-item:last-child {
    border-bottom: none;
}

.recommendations {
    background: linear-gradient(135deg, var(--primary-color)10, var(--background));
}

.recommendations ul {
    list-style: none;
    padding: 0;
}

.recommendations li {
    padding: 0.5rem 0;
    position: relative;
    padding-left: 1.5rem;
}

.recommendations li::before {
    content: '•';
    color: var(--primary-color);
    font-weight: bold;
    position: absolute;
    left: 0;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .calculator-section {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .input-section, .results-section {
        padding: 1.5rem;
    }
    
    .bmi-number {
        font-size: 3rem;
    }
    
    .chart-segment {
        font-size: 0.7rem;
        padding: 0.25rem;
    }
}

@media (max-width: 480px) {
    .controls {
        flex-direction: column;
    }
    
    .unit-toggle {
        width: 100%;
    }
    
    .calorie-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .chart-segment span {
        display: none;
    }
    
    .chart-segment::after {
        bottom: 0.25rem;
        font-size: 0.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #60a5fa;
        --primary-hover: #3b82f6;
        --secondary-color: #374151;
        --background: #111827;
        --surface: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border: #374151;
        --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    }
}