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

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: rgb(137, 176, 224);
    min-height: 100vh;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid rgb(102, 142, 212);
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 20px;
    line-height: 1.3;
}

form {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
    gap: 8px;
}

.input-group label {
    align-self: flex-start;
}

.input-group label {
    font-weight: 600;
    color: #34495e;
    font-size: 0.95rem;
}

.required {
    color: #e74c3c;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.input {
    flex: 1;
    font-size: 1rem;
    background-color: rgba(82, 141, 170, 0.986);
    border: none;
    border-radius: 8px;
    color: rgb(226, 231, 235);
    padding: 12px 16px;
    outline: none;
    transition: box-shadow 0.2s;
}

.input:focus {
    box-shadow: 0 0 0 3px rgba(82, 141, 170, 0.3);
}

.input[aria-invalid="true"] {
    border: 2px solid #c62828;
}

.input::placeholder {
    color: rgba(226, 231, 235, 0.7);
}

select {
    font-size: 1rem;
    background-color: rgba(82, 141, 170, 0.986);
    border: none;
    border-radius: 8px;
    color: rgb(226, 231, 235);
    padding: 12px 16px;
    cursor: pointer;
    outline: none;
    transition: box-shadow 0.2s;
}

select:focus {
    box-shadow: 0 0 0 3px rgba(82, 141, 170, 0.3);
}

button#calc-btn {
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    background-color: rgb(183, 206, 226);
    color: rgb(50, 50, 178);
    border: 2px solid rgb(50, 50, 178);
    cursor: pointer;
    transition: all 0.2s;
    margin: 16px 0;
    width: 100%;
    max-width: 400px;
}

button#calc-btn:hover {
    background-color: rgb(50, 50, 178);
    color: white;
}

button#calc-btn:active {
    transform: scale(0.98);
}

#res {
    width: 100%;
    max-width: 400px;
    text-align: center;
    padding: 16px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 500;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.field-error {
    align-self: flex-start;
    width: 100%;
    max-width: 400px;
    color: #b71c1c;
    font-size: 0.875rem;
    text-align: left;
}

.field-error:empty,
.history-status:empty {
    display: none;
}

.bmi-gauge {
    width: 100%;
    padding: 8px 0 0;
}

.bmi-gauge-track {
    position: relative;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(
        to right,
        #1976d2 0%,
        #1976d2 28.33%,
        #2e7d32 28.33%,
        #2e7d32 50%,
        #f57f17 50%,
        #f57f17 66.67%,
        #c62828 66.67%,
        #c62828 100%
    );
}

.bmi-gauge-marker {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    border: 3px solid white;
    border-radius: 50%;
    background: #263238;
    box-shadow: 0 0 0 2px #263238;
    transform: translate(-50%, -50%);
}

.bmi-gauge-labels {
    position: relative;
    height: 1.25em;
    margin-top: 8px;
    color: #455a64;
    font-size: 0.75rem;
}

.bmi-gauge-labels span {
    position: absolute;
    transform: translateX(-50%);
}

.bmi-gauge-labels span:first-child {
    transform: none;
}

.bmi-gauge-labels span:last-child {
    transform: translateX(-100%);
}

.bmi-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.bmi-category {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 20px;
}

/* WHO adult BMI category colors */
.category-underweight { background-color: #1976d2; color: white; }
.category-normal { background-color: #2e7d32; color: white; }
.category-overweight { background-color: #b45309; color: white; }
.category-obesity { background-color: #c62828; color: white; }

.history-status {
    margin: 0 0 10px;
    color: #b71c1c;
    font-size: 0.875rem;
}

/* History Section */
.history-section {
    width: 100%;
    max-width: 400px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

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

.history-header h2 {
    font-size: 1.1rem;
    color: #34495e;
    font-weight: 600;
}

.clear-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 6px;
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background-color: #c62828;
    color: white;
}

#history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: #f5f5f5;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 0.9rem;
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-bmi {
    font-weight: 600;
    font-size: 1rem;
}

.history-item-details {
    font-size: 0.8rem;
    color: #666;
}

.history-item-category {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

/* Responsive */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 16px;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group label {
        align-self: center;
    }

    .input, select {
        width: 100%;
    }

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

    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .clear-btn {
        width: 100%;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .history-item-category {
        align-self: flex-start;
    }
}
