/* General Styles */
body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background-color: #f4f4f4;
    overflow: hidden;
    width: 100vw;
    text-align: center;
}

/* Title Styling */
h3 {
    text-align: center;
    font-size: 24px; /* Slightly smaller to fit better */
    color: #24346c;
    margin-bottom: 10px;
}

/* Ensures select elements and dropdowns are centered */
select {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #fff;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#text {
    color: #006283;
}

/* Ensures all text and elements are aligned */
h3, select, .checkbox-container, .total-margin-container, input {
    width: 100%;
    text-align: center;
}

.ts-control {
    width: 100% !important;
    max-width: 300px; /* or whatever limit you want */
}


.ts-control {
    padding: 8px;
    line-height: 1.2;
    justify-content: center !important;

}

.ts-control input {
    padding: 0;
    margin: 0;
    text-indent: 0;
    text-align: center !important;

}

/* Container: Ensuring it fits the viewport */
.container {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 90%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Prevents elements from stretching */
    height: 90vh; /* Limits height to allow scrolling */
    overflow-y: auto; /* Enables vertical scrolling */
    overflow-x: hidden; /* Prevents unwanted horizontal scrolling */
}

/* Form Elements: Optimized for Small Spaces */
select, input[type="text"] {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 25px;
    background-color: #fff;
    width: fit-content; /* Use available space without overflow */
}


/* Button Container */
.button-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px; /* Reduce space */
    margin-top: 10px; /* Save space */
}

/* Custom Radio Button Styling */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #24346c; /* Default border color */
    border-radius: 50%;
    outline: none;
    position: relative;
    cursor: pointer;
    background-color: white; /* Default background */
    transition: all 0.3s ease;
}

input[type="radio"]:checked {
    border-color: #B42025; /* Change border color when checked */
    background-color: #B42025; /* Fully fill the radio button */
}

/* Styling for the results table */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 16px;
    text-align: center;
}

/* Table header styling */
.styled-table thead tr {
    background-color: #24346c;
    color: white;
    text-align: center;
    font-weight: bold;
}

/* Table row styling */
.styled-table tbody tr:nth-child(odd) {
    background-color: #f2f2f2; /* Light gray */
}

.styled-table tbody tr:nth-child(even) {
    background-color: #ffffff; /* White */
}

/* Table cell styling */
.styled-table th, 
.styled-table td {
    padding: 10px;
    border: 1px solid #ddd;
}

/* Sorting button styling */
.sorting-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    justify-content: center;
}

.sorting-buttons button {
    background-color: #24346c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.sorting-buttons button:hover {
    background-color: #1b2954;
}


#tierCheckboxes,
#materialRadioButtons,
#projectRadioButtons,
#locationRadioButtons,
#projectSizeRadioButtons {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Keeps text aligned properly */
    width: 50%; /* Adjust width for better positioning */
    margin: 0 auto 0 44%; /* Centers while slightly shifting right */
}

/* Hide both elements on page load */
#sortingControlsContainer,
#resultsContainer {
    display: none; /* Default hidden state */
    visibility: hidden; /* Prevents unwanted flashes */
}

#marginKeyWrapper ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1em;
  }
  
  #marginKeyWrapper li {
    padding: 4px 0;
  }
  
  #marginKeyWrapper strong {
    color: #0074D9;
  }
  
  #toggleMarginKey {
    background-color: #0074D9;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
  }
  
  #toggleMarginKey:hover {
    background-color: #005fa3;
  }
  
  #marginKey > div {
    margin-bottom: 1.5em;
  }
  
  

#resultsContainer {
    min-height: 360px; /* Ensures visibility on small screens */
    max-height: 70vh; /* Limits height to prevent excessive stretching */
    overflow-y: auto; /* Enables scrolling */
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: white;
}

.styled-table thead {
    position: sticky;
    top: 0;
    background-color: #24346c; /* Ensures visibility */
    color: white;
    z-index: 10;
}


/* Ensure labels and radio buttons are aligned inline */
#tierCheckboxes label,
#materialRadioButtons label,
#projectRadioButtons label,
#locationRadioButtons label,
#projectSizeRadioButtons label {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Aligns text to left */
    gap: 10px;
    cursor: pointer;
    width: auto;
}


/* Fix for margin input */
.total-margin-container input {
    padding: 6px !important;
    font-size: 18px !important;
    text-align: center !important;
    width: 90% !important;
    max-width: 300px !important;
    border: none !important;
    outline: none !important;
    background-color: transparent !important;
    display: block;
}

/* Button Styling */
button {
    background-color: #24346c;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    width: auto;
}

button:hover {
    background-color: #1b2954;
}

/* Style for total margin container */
.total-margin-container {
    width: 100%; /* Makes sure it takes full width */
    max-width: 900px; /* Prevents excessive stretching */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

/* Style for the input field */
.total-margin-container input {
    font-size: 24px !important; /* Bigger text */
    font-weight: bold; /* Make text stand out */
    text-align: center !important; /* Center align the text */
    width: 100% !important; /* Takes full width */
    max-width: 800px !important; /* Prevents excessive stretching */
    padding: 15px !important; /* Increase padding for better visibility */
    border: 2px solid #24346c !important; /* Add border for visibility */
    border-radius: 10px !important; /* Slightly rounded corners */
    outline: none !important;
    background-color: white !important;
    color: #B42025 !important; /* Text color matching theme */
}



/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
    }

    .container {
        height: auto;
        max-width: 95%;
        padding: 15px;
    }

    h3 {
        font-size: 20px;
    }

    select, input[type="text"] {
        width: 100%;
        max-width: 100%;
        font-size: 16px;
    }

    .button-container {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    #resultsContainer {
        min-height: 250px;
        max-height: 50vh; /* Limits height on mobile */
        overflow-y: auto; /* Enables scrolling */
        padding: 10px;
    }

    .styled-table thead {
        font-size: 14px;
    }

    button {
        width: 100%;
        max-width: 300px;
        font-size: 16px;
        padding: 12px;
    }

    .styled-table th, 
    .styled-table td {
        padding: 8px; /* Slightly smaller padding for better fit */
        font-size: 14px; /* Smaller font on mobile */
    }

    input[type="radio"] {
        width: 18px;
        height: 18px;
    }

    #tierCheckboxes,
    #materialRadioButtons,
    #projectRadioButtons,
    #locationRadioButtons,
    #projectSizeRadioButtons {
        display: flex;
        flex-direction: column;
        align-items: center; /* Centers items */
        justify-content: center; /* Centers items */
        width: 100%; /* Full width */
        margin: 0 auto; /* Center the container */
    }

    #tierCheckboxes label,
    #materialRadioButtons label,
    #projectRadioButtons label,
    #locationRadioButtons label,
    #projectSizeRadioButtons label {
        display: flex;
        align-items: center;
        justify-content: center; /* Centers text */
        gap: 10px;
        width: auto; /* Prevents stretching */
        text-align: center;
    }

    .total-margin-container input {
        font-size: 18px !important;
        padding: 12px !important;
    }
}

@media screen and (max-width: 480px) {
    h3 {
        font-size: 18px;
    }

    #tierCheckboxes,
    #materialRadioButtons,
    #projectRadioButtons,
    #locationRadioButtons,
    #projectSizeRadioButtons {
        width: 100%;
        padding-left: 0;
        align-items: center;
        justify-content: center;
    }

    #tierCheckboxes label,
    #materialRadioButtons label,
    #projectRadioButtons label,
    #locationRadioButtons label,
    #projectSizeRadioButtons label {
        width: 100%;
        justify-content: center; /* Ensures text remains centered */
        text-align: center;
    }

    .container {
        width: 100%;
        padding: 10px;
    }

    select, input[type="text"], button {
        font-size: 14px;
        padding: 10px;
        width: 100%;
        max-width: 250px;
    }

    #resultsContainer {
        min-height: 200px;
        max-height: 45vh;
    }

    .styled-table th, 
    .styled-table td {
        font-size: 12px;
        padding: 6px;
    }

    .total-margin-container input {
        font-size: 16px !important;
        padding: 10px !important;
    }

    input[type="radio"] {
        width: 16px;
        height: 16px;
    }

    .button-container {
        gap: 8px;
    }
}