/*Rest and base styles*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', sans-serif;
    background: rgb(139, 182, 53);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #3c4201;
    transition: background 0.4s ease, color 0.4s ease;
    background-size: 400% 400%;
}

body.dark {
    background: rgb(73, 122, 73);
}

nav {
    position: absolute;
    display: flex;
    gap: 30px;
    top: 0;
    left: 0;
    padding: 10px 30px;
    justify-content: center;
    width: 100%;
    background: rgb(72, 114, 17);
    color: pink;
    margin-bottom: 20px;
}

body.dark nav {
    background: rgb(54, 88, 54);
}
nav ul {
    list-style: none;
    display: flex;
    font-size: 1.5rem;
    font-style: italic;
    gap: 30px;
    text-decoration: rgb(192, 221, 112) wavy underline;
}

nav a {
    text-decoration: none;
    color: rgb(198, 228, 93);
}

main {
    flex: 1;
    justify-content: flex-start;
    padding: 30px;
    margin-top: 50px;
}

/*Theme Toggle Button*/
#themeToggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgb(72, 136, 47);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 0;
    font-size: 1rem;
    font-family:'Courier New', Courier, monospace;
    cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    transition: background 0.3s;
    z-index: 10;
    margin-top: 50px;
}

#themeToggle:hover {
    background: rgb(2, 95, 2);
}

body.dark #themeToggle {
    background: #455533;
}

h2 {
    color: rgb(45, 94, 25);
    text-align: center;
    text-decoration: rgb(24, 82, 24) wavy underline;
    margin-bottom: 10px;
    margin-top: 10px;
}

body.dark h2 {
    color: rgb(211, 235, 174);
    text-decoration: rgb(157, 209, 109) wavy underline;
}

p {
    text-align: center;
    align-items: center;
    justify-content: center;
    color: rgb(49, 77, 18);
    font-size: 1.13rem;
    font-style: italic;
    margin-top: 21.5px;
}

body.dark p {
    color: rgb(186, 240, 186);
}
/*Container*/
.container {
    max-width: 480px;
    background: rgb(100, 153, 64);
    backdrop-filter: blur(12px);
    margin: 100px auto 0;
    padding: 2rem;
    border-radius: 0; 
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    color:#142b04;
} 

body.dark .container {
    color: #0b6325;
}

.container h1 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.tagline p {
    text-align: center;
    opacity: 0.85;
    margin-bottom: 2rem;
}

.input-group {
    margin: 1.2rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius:10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

input[type="number"]:focus {
    border-color:var(--primary);
}

button[type="submit"] {
    display: block;
    width: 100%;
    padding: 0.9rem;
    background: #a7d17f;
    color: white;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

body.dark button[type="submit"] {
    background: #0d3605;
}
body.dark button[type="submit"]:hover {
    background: #1b5c0b;
}
button[type="submit"]:hover {
    background: yellowgreen;
}

.result {
    margin-top: 2rem;
    font-size: 1.3rem;
    font-weight: 600;
    background: #f0fdfa;
    padding: 1rem;
    border-radius: 10px;
    color: #0f7631;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

body.dark .result {
    background: #25471d;
    color: #9ae976;
}

.bmi-bar {
    margin-top: 50px;
    position: relative;
}

.bmi-track {
    display: flex;
    height: 25px;
    border-radius: 15px;
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    color: #fff;
}

.bar-segment {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    line-height: 24px;
    font-weight: 500;
    color: white;
    display: flex;
    justify-content: center;
}
/*Responsive*/
@media (max-width: 600px) {
    .container {
        margin-top: 60px;
    }
    .bar-segment {
        font-size: 0.65rem;
    }
    h1 {
        font-size: 1.6rem;
    }
}

.bmi-advice {
    margin-top: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #334155;
}

body.dark .bmi-advice {
    color: #13501d;
}

.bar-segment.underweight {
    background: #60a5fa;
}
.bar-segment.normal {
    background: #10b981;
}
.bar-segment.overweight {
    background: #f59e0b;
}
.bar-segment.obese {
    background: #ef4444;
}

/*Pointer triangle*/
.bmi-pointer {
    position: absolute;
    margin-top: -18px;
    transform: translateX(-50%);
    left: 0;
    font-size: 1.2rem;
    border-bottom: 10px solid black;
    z-index: 5;
    color: #444;
    font-weight: bold;
}

.bmi-label {
    display: block;
    font-size: 0.75rem;
    background: #fff;
    color: #000;
    padding: 2px 6px;
    border-radius: 6px;
    margin-top: 2px;
}
/*Dark mode fix*/
body.dark .bmi-pointer {
   filter:drop-shadow(0 0 2px rgba(255, 255, 255, 0.5))
}

.bmi-pointer .bmi-label {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

dark.dark .bmi-pointer .bmi-label {
    background: white;
    color: black;
}

.bmi-result {
    background: #bee788;
    border-radius: 20px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    transform: translateY(10px);
    animation: fadeInUp 0.6s ease forwards;
    font-family:'Segoe UI', sans-serif;
}

body.dark .bmi-result {
    color: rgb(96, 133, 10);
}
.bmi-result p {
    margin: 10px 0;
    font-size: 1rem;
}

.bmi-result .bmi-category {
    font-weight: bold;
    color: #007BFF;
}
.bmi-result.show {
    opacity: 1;
    transform: translateY(0);
}

.bmi-result .bmi-advice {
    font-style: italic;
    color: #555;
}

.ideal-weight {
    font-size: 1rem;
    margin-top: 15px;
    color: #226655;
}

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

@media (max-width: 400px) {
    .bmi-container {
        padding: 1rem;
        margin: 60px auto 0;
    }
    .bmi-result p,
    .bmi-advice,
    .ideal-weight {
        font-size: 0.9rem;
    }
    .bmi-label {
        font-size: 10px;
        padding: 2px 4px;
    }

    .history-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .history-actions button {
        width: 100%;
    }
}

/*History Section*/
.bmi-history {
    margin-top: 25px;
    background: #afcf84;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body.dark .bmi-history {
    color: green;
}

.bmi-history h3 {
    margin-bottom: 12px;
    font-size: 1.2rem;
    color: #222;
}

.bmi-history ul {
    padding-left: 20px;
}

.bmi-history li {
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.bmi-history .value {
    color: #17a2b8;
    font-weight: 500;
    margin-left: 10px;
}

body.dark .bmi-history .value {
    color: red;
}

/*Buttons*/
.history-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

#clearHistoryBtn {
    background-color: #307507;
    color: #c0e7b5;
}

#clearHistoryBtn:hover {
    background-color: #599614;
}

#exportHistoryBtn {
    background-color: #bcce1e;
    color: #3d6606;
    border-radius: 2px;
}

#exportHistoryBtn:hover {
    background-color: #c6df5a;
}

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

body.dark .bmi-advice {
    color: blueviolet;
}

.bmi-advice {
    margin-top: 0.5rem;
    font-style: italic;
    opacity: 0.85;
}

body.dark .bmi-advice {
    color: #416349;
}

/*Stylish Reset Button*/
.reset-btn {
    background-color: #8aaa31;
    color: #fff;
    border: 2px solid #548f23;
    padding: 8px 16px;
    margin-top: 12px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}


.reset-btn:hover {
    background-color: #96e757;
    transform: scale(1.05);
}

.reset-btn:active {
    background-color: #4e822c;
    transform: scale(0.97);
}

body.dark .reset-btn {
    background-color: rgb(4, 49, 4);
    color: #bbe9bb;
    border-color: #83ed63;
}

body.dark .reset-btn:hover {
    background-color: #267014;
}

.form-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.calculate-btn,
.reset-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

/*Calculate BMI button*/
.calculate-btn {
    padding: 20px 30px;
    background-color: #2b6cb0;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.calculate-btn:hover {
    background-color: #2c5282;
    transform: scale(1.05);
}

.calculate-btn:active {
    transform: scale(0.97);
}

body.dark .calculate-btn {
    background-color: #4299e1;
    color: #fff;
}

footer {
    bottom: 0;
    display: flex;
    margin-top: 35px;
    justify-content: center;
    text-align: center;
    font-size: 1.3rem;
    font-style: italic;
    background-color: rgb(71, 112, 17);
    color: rgb(205, 228, 74);
    position: relative;
    width: 100%;
}

body.dark footer {
    background: rgb(54, 88, 54);
}

@media (max-width: 400px) {
    .bmi-container {
        padding: 1rem;
        margin: 60px auto 0;
    }
    .bmi-result p,
    .bmi-advice,
    .ideal-weight {
        font-size: 0.9rem;
    }
    .bmi-label {
        font-size: 10px;
        padding: 2px 4px;
    }

    .history-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .history-actions button {
        width: 100%;
    }
}