/*******************************************************
 * GLOBAL STYLES
 *******************************************************/

/* 
    The body element is the main container for all content.
    We set a default font family, background color, and
    some spacing around the edges.
*/
body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: #F5F5F5;
    margin: 0;
    padding: 20px;
    padding-bottom: 60px;
    color: #333;
    min-width: 320px; /* Ensures at least a 320px wide display */
    overflow-x: hidden; /* Prevents horizontal scrollbar on small screens */
}

/* 
    Container class that provides a max width and centers 
    the content horizontally with responsive padding.
*/
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    position: relative;
}

/* 
    H1 heading style, centered text, and custom color. 
    We also include a margin to space it properly from surrounding elements.
*/
h1 {
    text-align: center;
    color: #144F9B;
    margin-bottom: 10px;
    font-size: 2em;
    width: 100%;
    box-sizing: border-box;
}

/* 
    Paragraph style for informational text under the main heading.
*/
.info-text {
    text-align: center;
    font-size: 1em;
    color: #3E3E3E;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

/*******************************************************
 * LOADING OVERLAY
 *******************************************************/

/* 
    Covers the entire screen while data is loading. 
    A slightly transparent background is used to obscure content.
*/
#loading-overlay {
    position: fixed;   /* Ensures it covers the viewport entirely */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 245, 245, 0.95);
    display: flex;
    flex-direction: column; /* Vertically stacks the loader and text */
    align-items: center;
    justify-content: center;
    z-index: 9999;     /* High z-index to ensure it sits above everything else */
}

/* 
    The spinning loader circle. 
    We use the CSS border trick to animate a spinner.
*/
#loading-overlay .loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #144F9B; /* The top border is colored to create the spinner effect */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* 
    Loading message text under the spinner.
*/
#loading-overlay p {
    font-size: 18px;
    color: #3E3E3E;
}

/* 
    Keyframes defining the spinner's rotation animation.
    It rotates 360 degrees repeatedly.
*/
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/*******************************************************
 * TABLE & DATATABLES STYLING
 *******************************************************/

/* 
    Sets up basic table styles, merges borders, 
    and prevents overflow of table content.
*/
table {
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    table-layout: auto;
    border: 1px solid #ccc;
    width: 100%;
}

/* 
    DataTables plugin specifically targets .dataTable thead th. 
    !important is used to override inline styles set by DataTables.
*/
table.dataTable thead th {
    text-align: center !important;
}

/* 
    Table headers with a background color and shadow effect. 
    The text is centered, and a box-shadow adds depth.
*/
th {
    background-color: #144F9B;
    color: #FFFFFF;
    text-align: center;
    box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.3);
}

/* 
    Changes the background color of the header cell when hovered, 
    indicating it's clickable for sorting.
*/
th:hover {
    background-color: #0B3C75;
    cursor: pointer;
}

/* 
    Table cells in the body use a white background by default.
*/
td {
    background-color: #FFFFFF;
}

/* 
    General spacing and font size for both headers and body cells.
*/
th, td {
    padding: 14px;
    text-align: left;
    font-size: 14px;
    line-height: 1.5;
    border-bottom: 1px solid #ddd;
}

/* 
    Applies a subtle background on every even row, making the table easier to read.
*/
tbody tr:nth-child(even) {
    background-color: #F7F7F7;
}

/* 
    Highlight effect on row hover to guide the user’s eye.
*/
tbody tr:hover {
    background-color: #DCEEFF;
}

/*******************************************************
 * DATATABLES WRAPPER / BUTTONS
 *******************************************************/

/* 
    Ensures the DataTables container can handle horizontal overflow 
    and keeps the table responsive.
*/
.dataTables_wrapper {
    width: 100%;
    margin: 0 auto;
    overflow-x: auto;
    box-sizing: border-box;
    padding-bottom: 15px;
}

/* 
    Additional wrapper that DataTables uses for vertical/horizontal scroll.
*/
.dataTables_scroll {
    overflow-x: auto;
    margin-bottom: 15px;
}

/* 
    Styles for the DataTables buttons (e.g., column visibility, export, etc.).
    Provides a consistent button look and feel matching our color scheme.
*/
.dataTables_wrapper .dt-buttons .dt-button {
    background-color: #144F9B;
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    margin-right: 5px;
    padding: 6px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dataTables_wrapper .dt-buttons .dt-button:hover {
    background-color: #0B3C75;
    color: #FFFFFF;
}

/* 
    The button collection is the dropdown or popup with column toggle options.
*/
.dataTables_wrapper div.dt-button-collection .dt-button {
    background-color: #FFFFFF;
    color: #144F9B;
    border: 1px solid #144F9B;
    padding: 6px 12px;
    margin: 2px;
    border-radius: 4px;
}

.dataTables_wrapper div.dt-button-collection .dt-button:hover {
    background-color: #DCEEFF;
    color: #144F9B;
}

/* 
    Indicates a toggled (pressed) state for buttons 
    in the button collection.
*/
.dataTables_wrapper div.dt-button-collection .dt-button[aria-pressed="true"] {
    background-color: #144F9B;
    color: #FFFFFF;
}

.dataTables_wrapper div.dt-button-collection .dt-button[aria-pressed="true"]:hover {
    background-color: #0B3C75;
    color: #FFFFFF;
}

/*******************************************************
 * DATATABLES PAGINATION
 *******************************************************/

/* 
    Styles for the pagination container (forward/back buttons, page numbers, etc.).
*/
.dataTables_wrapper .dataTables_paginate {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* 
    Pagination buttons, default white background with a border 
    matching the theme color.
*/
.dataTables_wrapper .dataTables_paginate .paginate_button {
    background-color: #FFFFFF;
    color: #144F9B !important; 
    border: 1px solid #144F9B;
    border-radius: 4px;
    margin: 0 2px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    text-decoration: none; /* Removes underline from links if any */
}

/* 
    Hover and focus style for pagination buttons 
    that are not disabled.
*/
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled),
.dataTables_wrapper .dataTables_paginate .paginate_button:focus:not(.disabled) {
    background: #0B3C75 !important;
    background-color: #0B3C75 !important;
    color: #FFFFFF !important;
    border-color: #0B3C75;
    text-decoration: none;
}

/* 
    Hover style to ensure consistency even if :focus doesn't apply.
*/
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #0B3C75 !important;
    background-color: #0B3C75 !important;
    color: #FFFFFF !important;
}

/* 
    Pagination button for the currently active page.
*/
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background-color: #144F9B !important;
    color: #FFFFFF !important;
    border-color: #144F9B;
}

/* 
    Disabled pagination buttons (when there's no previous or next page).
*/
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    background-color: #F5F5F5 !important;
    color: #999999 !important;
    border-color: #CCCCCC;
    cursor: not-allowed;
    opacity: 0.7;
}

/* 
    Specific styles for previous, next, first, last buttons 
    to keep them consistent with other pagination buttons.
*/
.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next,
.dataTables_wrapper .dataTables_paginate .paginate_button.first,
.dataTables_wrapper .dataTables_paginate .paginate_button.last {
    min-width: auto;
    padding: 6px 12px;
    color: #144F9B;
}

/*******************************************************
 * DATATABLES LENGTH / FILTER / INFO
 *******************************************************/

/* 
    Labels for "Show x entries" (dataTables_length) 
    and the search box (dataTables_filter).
*/
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    color: #3E3E3E;
}

/* 
    Table information text ("Showing x to y of z entries").
*/
.dataTables_wrapper .dataTables_info {
    color: #3E3E3E;
}

/* 
    The dropdown used to select the number of table rows shown at once.
*/
.dataTables_length select {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px;
    background-color: #FFFFFF;
}

/* 
    Search box styling in the top-right corner of the table by default.
*/
.dataTables_filter input {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px;
    background-color: #FFFFFF;
}

/*******************************************************
 * DATATABLES TOP/BOTTOM SECTIONS
 *******************************************************/

/* 
    The bottom area of the DataTable which can contain 
    table length control, table info, and pagination controls.
*/
.dataTables_wrapper .bottom {
    display: grid;
    grid-template-columns: 200px 1fr 200px; /* Defines 3 columns layout */
    width: 100%;
    box-sizing: border-box;
    padding: 10px 0;
    position: sticky; /* Stays at the bottom of its container */
    left: 0;
    background-color: #F5F5F5;
    z-index: 1;
    align-items: center;
}

/* 
    First column for the length (Show x entries) selection.
*/
.dataTables_length {
    grid-column: 1;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    height: 32px; /* Aligns the dropdown nicely vertically */
}

/* 
    Label containing the text for the length menu. 
    We use gap to space the label text and the select.
*/
.dataTables_length label {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 
    The dropdown select used for length selection, styled to match button heights.
*/
.dataTables_length select {
    margin: 0 5px;
    height: 28px;
}

/* 
    Second column for the table info text (e.g., "Showing 1 to 100 of 500 entries").
*/
.dataTables_info {
    grid-column: 2;
    text-align: center;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
}

/* 
    Third column for pagination controls (e.g., previous, next, page numbers).
*/
.dataTables_paginate {
    grid-column: 3;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* 
    Ensures pagination buttons fit well in the container.
*/
.dataTables_paginate .paginate_button {
    display: inline-block;
    min-width: auto;
    height: auto;
    margin: 0 2px;
    padding: 6px 12px;
    line-height: normal;
}

/* 
    The top section (under the heading) which typically contains 
    the search box and/or length menu.
*/
.dataTables_wrapper .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;       /* Adjusts layout for smaller screens */
    width: 100%;
    box-sizing: border-box;
    padding: 10px 0;
    position: sticky; /* Sticks to the top while scrolling within the container */
    left: 0;
    background-color: #F5F5F5;
    z-index: 1;       /* Ensures it's above the table rows */
}

/* 
    The filter (search box) and length menu in the top area.
    We keep them visually consistent.
*/
.dataTables_filter,
.dataTables_length {
    position: static;
    background-color: transparent;
    padding: 10px 0;
}

.dataTables_length label {
    margin: 0;
}

.dataTables_info {
    margin: 10px 0;
}

/*******************************************************
 * UTILITY CLASSES
 *******************************************************/

/* 
    .hidden is used to hide elements without removing them from the DOM, 
    typically until data has loaded.
*/
.hidden {
    display: none !important;
}

/*******************************************************
 * STICKY BOTTOM BAR
 *******************************************************/

/* 
    A fixed bar at the bottom of the screen. We use a box shadow 
    to create separation from the page content.
*/
.sticky-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #144F9B;
    color: #FFFFFF;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000; /* Renders above other elements */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

/* 
    Text within the sticky bar, white text on a colored background.
*/
.sticky-bottom-bar p {
    margin: 0;
    font-size: 14px;
}

/* 
    Close button styling for the sticky bottom bar
*/
.close-button {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.close-button:hover {
    opacity: 1;
}

/*******************************************************
 * MEDIA QUERIES
 *******************************************************/

/* 
    Responsive adjustments for screens smaller than 768px. 
    Reduces padding on the body and adjusts table controls layout.
*/
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .dataTables_wrapper .bottom {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .dataTables_info,
    .dataTables_paginate,
    .dataTables_length {
        margin: 5px 0;
    }
}

/*******************************************************
 * FOOTER
 *******************************************************/

/* 
    Footer style, typically used if there's a footer element. 
    Centered text and a subtle color.
*/
.footer {
    text-align: center;
    font-size: 1em;
    margin-top: 30px;
    color: #3E3E3E;
    width: 100%;
    box-sizing: border-box;
    padding: 0 15px;
}