/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --underweight-color: #60a5fa;
    --normal-color: #34d399;
    --overweight-color: #fbbf24;
    --obese-color: #f87171;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px 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-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.logo-container {
    margin-bottom: 1rem;
}

.logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
main {
    flex: 1;
}

/* Calculator Section */
.calculator-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
}

.unit-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

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

.unit-btn:hover:not(.active) {
    background: var(--border-color);
}

/* Form Styles */
.bmi-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.input-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-field label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-field input {
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
}

.input-field input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-field input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Dual Input for Imperial Height */
.dual-input {
    display: flex;
    gap: 1rem;
}

.sub-input {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sub-input input {
    flex: 1;
}

.sub-input span {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Calculate Button */
.calculate-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

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

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

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
    animation: fadeIn 0.3s ease;
}

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

.bmi-result {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #f1f5f9 100%);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.bmi-value-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.bmi-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.bmi-category {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

.category-label {
    color: var(--text-secondary);
}

.category-value {
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
}

.category-value.underweight {
    background: rgba(96, 165, 250, 0.2);
    color: #2563eb;
}

.category-value.normal {
    background: rgba(52, 211, 153, 0.2);
    color: #059669;
}

.category-value.overweight {
    background: rgba(251, 191, 36, 0.2);
    color: #d97706;
}

.category-value.obese {
    background: rgba(248, 113, 113, 0.2);
    color: #dc2626;
}

/* Healthy Range */
.healthy-range {
    padding: 1.5rem;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.healthy-range h3 {
    color: #059669;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.healthy-range p {
    color: var(--text-primary);
    font-weight: 500;
}

/* BMI Chart */
.chart-container {
    margin-top: 1.5rem;
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.bmi-chart {
    position: relative;
    padding-bottom: 2.5rem;
}

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

.chart-segment {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    color: white;
    text-align: center;
    transition: var(--transition);
}

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

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

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

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

.segment-label {
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}

.segment-range {
    font-size: 0.7rem;
    opacity: 0.9;
}

.chart-pointer {
    position: absolute;
    bottom: 0;
    left: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.5s ease;
}

.pointer-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 10px solid var(--primary-color);
}

.pointer-value {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 2px;
}

/* Info Section */
.info-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.info-section h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.info-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* BMI Table */
.bmi-table {
    margin-top: 1.5rem;
}

.bmi-table h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.bmi-table table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.bmi-table th,
.bmi-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.bmi-table th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text-primary);
}

.bmi-table tr:last-child td {
    border-bottom: none;
}

.bmi-table tr:nth-child(even) {
    background: var(--bg-primary);
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: auto;
}

footer a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

footer a:hover {
    text-decoration: underline;
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .calculator-section,
    .results-section,
    .info-section {
        padding: 1.5rem;
    }

    .input-group {
        grid-template-columns: 1fr;
    }

    .bmi-value {
        font-size: 3rem;
    }

    .chart-segment {
        padding: 0.25rem;
    }

    .segment-label {
        font-size: 0.65rem;
    }

    .segment-range {
        font-size: 0.6rem;
    }

    .bmi-table th,
    .bmi-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    header h1 {
        font-size: 1.75rem;
    }

    .logo {
        width: 60px;
        height: 60px;
    }

    .unit-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .calculate-btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }

    .calculator-section {
        display: none;
    }

    .results-section,
    .info-section {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}
