@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #1f1b1a; /* Darker background color */
    --description: #a7a7a7;
    --btn: #171614;
    --btn-hover: #0f0e0d; /* Darker color for selected button */
    --text: #ffffff;
    --base-font-size: 24px;
}

html {
    font-size: var(--base-font-size);
}

body {
    background-color: var(--bg);
    font-family: 'Nunito', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text);
    overflow: hidden; /* Prevent scrollbar */
}

.panel {
    position: relative;
    background: #2b2625; /* Revert to original panel background color */
    border-radius: 15px;
    box-shadow: 0 1px 3px 1px rgba(0,0,0,0.5);
    padding: 30px;
    max-width: 900px;
    text-align: center;
    color: var(--text);
    line-height: 1.4;
    font-size: 1rem;
    box-sizing: border-box;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.title {
    font-weight: bold;
    font-size: 1.625rem;
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 1px 1px 8px rgba(255, 255, 255, 0.2);
    transition: text-shadow 0.3s ease-in-out;
}

/* Enhanced shadows for consistent styling */
input[type="number"] {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

input[type="number"]:focus {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    transform: translateY(-1px);
}

.panel {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.units-btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.units-btn:hover, .units-btn.active {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.units-switch {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
    gap: 15px; /* Add space between the buttons */
}

.units-btn {
    margin: 0;
    display: inline-block;
    border: none;
    background: var(--btn);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.875rem; 
    border-radius: 5px;
    transition: background-color 0.3s ease-in-out, transform 0.3s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Add shadow to buttons */
}

.units-btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-2px);
}

.units-btn.active {
    background-color: var(--btn-hover);
}

.sub-text {
    font-size: 0.6875rem; 
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, 0);
    width: 100%;
    color: var(--text);
    margin-top: 5px;
}

.calculator {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    border-radius: 10px;
    background-color: var(--primary);
    padding: 20px;
    box-sizing: border-box;
}

.result {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px;
}

#value {
    font-size: 1rem;
    font-weight: bold;
}

.input-container {
    display: flex;
    align-items: center;
    margin: 5px 0;
    width: 100%;
}

input {
    outline: none !important;
    border: 1px solid var(--accent);
    border-radius: 5px;
    flex: 1; /* Allow input to take available space */
    text-align: center;
    padding: 5px;
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 5px var(--primary);
}

input[type="number"] {
    padding: 0.3125rem; /* 5px to rem */
    margin: 0; /* Remove margin */
    font-size: 1rem; /* 16px to rem */
    border: 0; /* 0px to rem */
    border-radius: 0.3125rem; /* 5px to rem */
    color: var(--text);
    background-color: var(--btn);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.5); /* 2px and 4px to rem */
    transition: box-shadow 0.3s ease-in-out;
    text-align: center; /* Center the numbers inside the input fields */
}

/* Hide input arrows on Firefox */
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Hide input arrows on Chrome, Safari, Edge, and Opera */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.unit {
    margin-left: 10px; /* Add space between input and unit */
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap; /* Prevent unit from wrapping to the next line */
}

form {
    text-align: left;
    padding: 10px;
    height: 100%;
}

/* Label styling to display above inputs */
form label {
    display: block;
    margin-bottom: 8px;
    margin-top: 15px;
    font-weight: 500;
    color: var(--text);
}

form label:first-of-type {
    margin-top: 0; /* Remove top margin from first label */
}

a,
a:visited {
    color: var(--accent);
}

.divider {
    margin: 20px 0;
    font-size: 1.2rem;
    color: var(--description);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.divider span {
    margin-bottom: 2px; /* Decrease space between text and divider */
}

.divider hr {
    width: 80%; /* Make the divider wider */
    border: 0;
    border-top: 1px solid var(--description);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 40px; /* Increase spacing between input fields */
    width: 100%;
}

.grid-container > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px; /* Add space between divs */
}

div h2 {
    margin-bottom: 10px; /* Add margin below the currency name */
}

/* Footer styling */
footer {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--description);
}

/* Media Queries */

/* Small devices (phones, 600px and down) */
@media (max-width: 600px) {
    :root {
        --base-font-size: 14px;
    }

    html {
        font-size: var(--base-font-size);
    }

    body {
        padding: 10px;
    }

    .panel {
        padding: 20px;
        max-width: 100%;
    }

    .title {
        font-size: 1.2rem;
    }

    .input-container {
        flex-direction: column;
        align-items: flex-start;
    }

    input {
        width: 100%;
        margin-bottom: 10px;
    }

    .unit {
        margin-left: 0;
    }
}

/* Medium devices (tablets, 600px to 768px) */
@media (min-width: 601px) and (max-width: 768px) {
    :root {
        --base-font-size: 18px;
    }

    html {
        font-size: var(--base-font-size);
    }

    body {
        padding: 15px;
    }

    .panel {
        padding: 25px;
        max-width: 90%;
    }

    .title {
        font-size: 1.4rem;
    }

    .input-container {
        flex-direction: row;
        align-items: center;
    }

    input {
        width: 70%;
    }

    .unit {
        margin-left: 10px;
    }
}

/* Large devices (desktops, 768px and up) */
@media (min-width: 769px) {
    :root {
        --base-font-size: 24px;
    }

    html {
        font-size: var(--base-font-size);
    }

    body {
        padding: 20px;
    }

    .panel {
        padding: 30px;
        max-width: 70%;
    }

    .title {
        font-size: 1.625rem;
    }

    .input-container {
        flex-direction: row;
        align-items: center;
    }

    input {
        width: 80%;
    }

    .unit {
        margin-left: 10px;
    }
}

/* Input with unit styling */
.input-with-unit {
    position: relative;
    display: block;
    margin-bottom: 5px;
    width: 100%;
    max-width: 300px;
}

.input-with-unit input {
    padding-right: 2.5rem; /* Add padding to make room for unit text */
    width: 100%;
    box-sizing: border-box;
}

.unit-overlay {
    position: absolute;
    right: 0.625rem; /* 10px */
    top: 50%;
    transform: translateY(-50%);
    color: var(--description);
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: none; /* Prevent unit text from interfering with input */
    z-index: 1;
}

.unit-overlay::after {
    content: attr(data-unit);
}

/* Days input field styling */
#days {
    max-width: 300px;
    width: 100%;
    margin-bottom: 5px;
}

/* Reduce spacing from br tags in form */
form br {
    line-height: 0.5;
    margin: 5px 0;
}
