/* General body styling */
body {
    font-family: 'JetBrains Mono', monospace;
    background: #f5f5f5;
    color: #1a1a1a;
    margin: 0;
    padding: 20px;
}

/* Container for the entire page */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Styling for the main heading */
h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1a1a1a;
    text-transform: lowercase;
}

/* Styling for "try it out!" */
h2 {
    font-size: 13px;
    margin-top: 10px;
    margin-bottom: -8px;
    color: #666666;
    text-transform: lowercase;
    font-weight: 500;
}

/* Input container layout */
.input-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px; /* Reduced from 20px to 10px */
    width: 100%;
    max-width: 800px;
    margin-bottom: 15px; /* Slightly reduced bottom margin */
}

/* Adjusting the input-row to balance spacing */
.input-row {
    display: flex;
    justify-content: center;
    gap: 30px; /* Reduced gap between groups from 40px to 30px */
    width: 100%;
}

/* Individual input box styles */
.input-container {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center-align the input and label */
    width: 130px; /* Slightly reduced width for all inputs */
}

/* Styling for input labels */
.input-container label {
    font-size: 13px;
    font-weight: 600;
    color: #666666;
    margin-top: 5px;
    text-align: center;
    text-transform: lowercase;
    white-space: nowrap;
}

/* Styling for input boxes */
.input-container input {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: #1a1a1a;
    background-color: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    width: 100%;
    min-width: 130px;
    text-align: center;
    transition: all 0.2s;
}

.input-container input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Remove up and down arrows (spinners) for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Total Units Box */
.total-units-box {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: #1a1a1a;
    background-color: transparent;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    text-align: center;
    width: 100%;
    min-width: 130px;
    height: 16px;
}

/* Highlight Total Units Box only when there is output */
.total-units-box.has-output {
    background-color: #d1fae5;
    border-color: #10b981;
}

/* ============================= */
/* Existing CSS (unchanged) ...  */
/* ============================= */

/* Add these styles at the bottom or in a separate file */

/* Wrapper for the half-units label + toggle switch */
.half-units-wrapper {
    display: flex;
    align-items: center;
    gap: 10px; /* space between text and switch */
    margin: 10px 0; /* spacing above/below the switch */
}

/* Optional styling for the label text next to the switch */
.half-units-label {
    font-size: 13px;
    font-weight: 600;
    color: #666666;
    text-transform: lowercase;
}

/* ============= Toggle Switch Slider ============= */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px; /* width of the slider */
    height: 24px; /* height of the slider */
    margin-left: 4px; /* slight spacing if desired */
}

.toggle-switch input {
    /* Hide the default checkbox */
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

/* The slider background */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px; /* round the edges */
}

/* The circle inside the slider */
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

/* When checked, change background color */
.toggle-switch input:checked + .slider {
    background-color: #2196F3; /* or whatever color you prefer */
}

/* Move the circle to the right when checked */
.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Optional: if you want a “round” slider style */
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

/* Tables container layout */
.tables-container {
    display: flex;
    justify-content: center; /* center the pair as a whole */
    gap: 30px; /* space between them */
    width: 100%;
    max-width: 900px;
}

/* Ensure each table doesn't get too wide. */
table {
    width: 35%;
    border-collapse: collapse;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px;
}

table th, table td {
    border: 1px solid #e5e7eb;
    text-align: center;
    padding: 8px;
    white-space: nowrap;
    margin: 0;
}

table tr {
    height: 40px;
    vertical-align: middle;
}

table th {
    font-size: 13px;
    font-weight: 600;
    text-transform: lowercase;
    background: #f9f9f9;
    color: #1a1a1a;
}

table th:first-child {
    width: 40%;
}

table td {
    font-size: 13px;
    color: #1a1a1a;
}

/* Highlight selected rows */
.highlight {
    background-color: #d1fae5;
}

/* ---------- Responsive Design ----------- */
@media (max-width: 768px) {

    /* Reduce top margin for the "insulin dosing tables" title */
    h1 {
        margin-top: -10px; /* Reduced from default to 10px for smaller screens */
    }    
    
    /* Hide the "try it out!" heading on small screens */
    h2 {
        display: none;
    }

    /* Use grid to form 2 columns for input boxes */
    .input-section {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 2 columns */
        gap: 15px; /* Reduced space between columns and rows */
        align-items: start;
        justify-items: center;
    }

    /* Flatten .input-row to allow individual positioning */
    .input-row {
        display: contents;
    }

    /* Assign each input box to specific positions */
    .box1 {
        grid-column: 1;
        grid-row: 1;
    }
    .box2 {
        grid-column: 1;
        grid-row: 2;
    }
    .box3 {
        grid-column: 1;
        grid-row: 3;
    }

    .box4 {
        grid-column: 2;
        grid-row: 1;
    }
    .box5 {
        grid-column: 2;
        grid-row: 2;
    }
    .box6 {
        grid-column: 2;
        grid-row: 3;
    }

    /* Adjust the size of each input box for smaller screens */
    .input-container {
        width: 90%; /* Adjusted to fit within grid layout */
        margin-bottom: -10px; /* Reduce margin between boxes */
    }

    .input-container input {
        padding: 6px; /* Reduce padding inside input boxes */
        font-size: 0.85em; /* Slightly smaller font for compactness */
    }

    /* Compact total-units-box */
    .total-units-box {
        width: 100%;
        padding: 6px; /* Reduce padding for smaller screens */
        font-size: 0.85em; /* Adjust font size for readability */
    }

    /* Tables remain side-by-side */
    .tables-container {
        display: flex; /* Ensure tables are displayed in a row */
        flex-wrap: nowrap; /* Prevent wrapping */
        justify-content: space-evenly; /* Equal space between tables */
        gap: 15px; /* Reduced gap between tables */
    }

    table {
        width: 45%; /* Adjusted table width to fit within smaller screens */
        font-size: 0.9em; /* Ensure font size is readable */
        margin: 4px; /* Smaller margin for compact layout */
    }

    /* Reduce table cell padding for compactness */
    table th, table td {
        padding: 4px;
    }

    /* Ensure table rows have consistent height */
    table tr {
        height: 30px; /* Adjust row height */
        vertical-align: middle; /* Center-align content */
    }
}
