/* Root Variables */
:root {
    --primary-color: #003366;
    --secondary-color: #0055a5;
    --background-color: #ffffff;
    --light-background-color: #f5f5f5;
    --text-color: #333333;
    --border-color: #dda519;
    --input-border-color: #cccccc;
    --nav-footer-height: 30px;
    --spacing: 15px;
}

/* General Styling */
html, body {
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
    box-sizing: border-box;
}

.bar-style {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed; /* Sticky positioning */
    width: 100%; /* Full width */
    height: var(--nav-footer-height); /* Consistent height */
    background-color: var(--primary-color);
    color: var(--background-color);
    padding: 0 var(--spacing); /* Horizontal padding */
    box-sizing: border-box;
    font-size: 14px;
    font-weight: bold;
    z-index: 1000; /* Ensure it stays above other elements */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Shadow for visual separation */
}

/* Footer Specific Overrides */
footer.bar-style {
    justify-content: center; /* Center all footer content */
    bottom: 0; /* Stick to the bottom of the viewport */
    left: 0;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1); /* Shadow above footer */
}

/* Navigation Specific Overrides */
header nav.bar-style {
    justify-content: space-between; /* Left-align links, right-align button */
    top: 0; /* Stick to the top of the viewport */
    left: 0;
}

/* Navigation Bar */
.nav-left {
    display: flex;
    gap: var(--spacing); /* Space between links */
}

.nav-right {
    display: flex;  /* Ensures items are in a row (not stacked) */
    align-items: center;
    gap: var(--spacing)
}

.nav-right a {
    margin-right: 10px; /* Adds spacing between Help and Logout */
}

/* Navigation Bar Links and Buttons */
header nav a, header nav button {
    text-decoration: none; /* Remove underline */
    font-size: 14px; /* Same font size */
    font-weight: bold; /* Bold text */
    font-family: inherit; /* Ensure font matches the rest of the nav bar */
    color: var(--background-color); /* Same color for links and buttons */
    padding: 5px 10px; /* Uniform padding */
    border: none; /* Remove button borders */
    background: none; /* Remove button background */
    display: inline-flex; /* Align properly with other elements */
    align-items: center; /* Center text vertically */
    cursor: pointer; /* Pointer on hover */
    line-height: var(--nav-footer-height); /* Ensure height consistency */
}

/* Hover Effect for Links and Buttons */
header nav a:hover, header nav button:hover {
    text-decoration: underline; /* Same hover effect */
}

/* Footer Styles */
footer {
    display: flex;
    justify-content: center; /* Center content horizontally */
    align-items: center; /* Center content vertically */
    height: var(--nav-footer-height); /* Match nav bar height */
    background-color: var(--primary-color); /* Same background as nav bar */
    color: var(--background-color); /* Text color */
    font-size: 14px; /* Same font size as nav bar */
    padding: 0 var(--spacing); /* Consistent padding */
    box-sizing: border-box;
    text-align: center; /* Center align text */
}

footer p {
    margin: 0; /* Remove default margin for proper centering */
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--nav-footer-height) * 2); /* Full height minus nav and footer */
    padding: 20px;
    /* background-color: var(--light-background-color); */
    background-color: transparent;
    box-sizing: border-box;
}

.login-container .frame {
    padding: 20px;
    width: 100%;
    max-width: 400px; /* Limit the width */
    /* background-color: var(--background-color); */
    background-color: rgba(255, 255, 255, 0.85); 
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    text-align: center;
    display: flex;
    flex-direction: column; /* Stack children vertically */
    gap: 10px;
}

.login-form {
    text-align: left; /* Align all form content to the left */
    margin-bottom: 20px; /* Add space between the form and the button */
}

.login-form .form-group {
    display: flex;
    flex-direction: column; /* Stack label and input */
    margin-bottom: 15px; /* Space between fields */
}

.login-form label {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 14px;
    text-align: left; /* Left-align labels */
}

.login-form input {
    padding: 8px;
    font-size: 14px;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

/* Login Form Button */
.login-form .button {
    padding: 8px;
    font-size: 14px;
    color: var(--background-color);
    background-color: var(--primary-color);
    border: none;
    border-radius: 4px;
    /* text-transform: uppercase; */
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
}

.login-form .button:hover {
    background-color: var(--secondary-color);
}

/* General Container Adjustments */
.data-view-container {
    display: flex;
    gap: 15px;
    height: calc(100vh - var(--nav-footer-height) * 2);
    padding: 15px;
    box-sizing: border-box;
    align-items: stretch; /* Ensure all frames align in height */
    overflow: hidden; /* Prevent scrolling for the container itself */
}

.manage-users-container {
    display: flex;
    flex-direction: column; /* Stack frames vertically */
    gap: 15px; /* Space between frames */
    height: calc(100vh - var(--nav-footer-height) * 2);
    width: 100%; /* Full width */
    box-sizing: border-box;
    padding: 15px;
    overflow: hidden; /* Prevent scrolling for the container itself */
}

.messages-container {
    padding: 15px; /* Add padding for inner spacing */
    max-width: 600px; /* Optional: Limit the width for readability */
    margin: 0 auto; /* Center the container on the page */
    box-sizing: border-box; /* Include padding in the width */
    height: calc(100vh - var(--nav-footer-height) * 2); /* Constrain height dynamically */
    overflow: hidden; /* Prevent scrolling for the container */
    display: flex;
    flex-direction: column; /* Stack children vertically */
}

.container {
    padding-top: var(--nav-footer-height); /* Space below nav bar */
    padding-bottom: var(--nav-footer-height); /* Space above footer */
    box-sizing: border-box;
}

.button-container {
    text-align: center; /* Center the button */
    margin-top: auto; /* Space above the button */
    padding: 10px 0;/* Add some vertical padding */
    flex-shrink: 0; /* Prevent shrinking */
}

.compact-header {
    margin: 0; /* Align with regular header styling */
    padding: 0; /* Match regular header padding */
    font-size: 1.1em; /* Uniform font size */
    line-height: 2.0; /* Consistent vertical spacing */
    text-align: left; /* Match alignment with regular headers */
    flex-shrink: 0; /* Ensure header does not shrink in flexbox */
}

.frame {
    display: flex;
    flex-direction: column; /* Stack content vertically */
    gap: 10px; /* Space between child elements */
    padding: 10px 15px 0 15px; /* Adjust bottom padding */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    box-sizing: border-box;
    height: 100%;
    overflow: hidden; /* Prevent scrolling for the frame itself */
}

.pdf-frame {
    flex-grow: 1; /* Ensures iframe takes all available space */
    width: 100%; /* Stretches across full width */
    height: 100%; /* Fills entire height of .data-view-container */
    border: none; /* Removes iframe border */
}

/* General <h2> Styling for Frames */
.frame h2,
.search-results-frame h2,
.stats-frame h2,
.graphs-frame h2,
.manage-users-frame h2 {
    margin: 0; /* Remove external spacing */
    padding: 0; /* Remove internal spacing */
    font-size: 1.1em; /* Uniform font size */
    line-height: 2.0; /* Adjust vertical spacing */
    text-align: left; /* Optional: Align text left */
}

.main-frame, .right-frame {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
    background-color: transparent;
    border: none;
}

.right-frame {
    height: 100%; /* Match height of main frame */
}

.add-user-frame {
    padding: 0;
    flex: 0 0 auto; /* Prevent it from growing or shrinking */
    height: auto;  /*Take up 1/5 or 20% of the container */
    max-height: 200px; /* Optional max height */
    overflow: hidden; /* Hide overflow content */
    box-sizing: border-box; /* Ensure consistent padding/border calculation */
}

.add-user-frame .search-form {
    margin: 0; /* Remove extra margins */
    padding: 15px; /* Keep consistent with .search-frame */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Same layout as other forms */
    grid-gap: 10px; /* Consistent spacing between elements */
    align-items: center; /* Vertically align elements */
    background-color: var(--background-color);
}

.manage-users-frame {
    flex: 1; /* Take the remaining space */
    overflow: hidden; /* Prevent scrolling for the frame itself */
    display: flex; /* Establish a flex layout */
    flex-direction: column; /* Stack children vertically */
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-footer-height) * 2); /* Account for nav/footer */
    gap: 15px;
    padding: var(--spacing);
    box-sizing: border-box;
}

#dashboard-site-selector {
    flex: 0 0 auto;            /* Let it size based on content */
    min-height: 15%;           /* Default baseline */
    height: auto;              /* Expand as needed */
}

#dashboard-site-info {
    display: flex;
    flex-direction: row; /* Important: horizontal layout */
}

.site-info-subframe {
    flex: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 10px 15px;
    background-color: var(--background-color);
    overflow: hidden;
    height: 100%;
}

/* Remove left border from the first subframe */
#site-map {
    border-left: none;
}

#dashboard-nav {
    flex: 0 0 15%;
}

.dashboard-nav-grid {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.dashboard-nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    gap: 10px;
    transition: transform 0.2s ease-in-out;
}

.dashboard-nav-item:hover {
    transform: scale(1.05);
    color: var(--primary-color);
}

.dashboard-nav-item img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    margin-bottom: 10px;
}

/* Search Frame */
.search-frame {
    padding: 0; /* Optional: Maintain padding for content spacing */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    box-sizing: border-box; /* Ensure padding is included in the width/height */
    overflow: hidden; /* Prevent content overflow breaking corners */
}

/* Search Form Adjustments */
.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Create a row for text boxes */
    grid-gap: 10px; /* Spacing between elements */
    align-items: center; /* Vertically align items */
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background-color: var(--background-color);
}

/* Individual Form Groups */
.search-form .form-group {
    display: flex;
    flex-direction: column; /* Stack label and input vertically */
    /* font-size: 14px; */
    width: 100%;
}

/* Labels */
.search-form .form-group label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px; /* Space between label and input */
}

.search-form .form-group.button-group {
    flex-direction: row;
    gap: 10px;
    align-items: flex-end;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.search-form .form-group.button-group button {
    min-width: auto;
    width: auto;
    padding: 6px 12px;
    font-size: 14px;
    height: 36px;
    line-height: 1.2; /* Optional: aligns text better inside buttons */
}

.transparent-icon-button {
    background: transparent;
    border: none;
    font-size: 14px; /* Reduce size as needed */
    padding: 2px 6px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}

.transparent-icon-button:hover {
    opacity: 0.8;
}

/* Form Actions - Aligning Submit Button and Checkboxes */
.form-actions {
    display: flex;
    justify-content: space-between; /* Keeps button left & checkboxes right */
    align-items: center;
    width: 100%;
    grid-column: span 4; /* Ensure it spans the full grid width */
    margin-top: auto; /* Pushes it to the bottom */
}

/* P-code Filters (Checkboxes) - Right-Aligned */
.pcode-filters label {
    font-size: 14px; /* Match other labels */
    font-weight: bold;
    color: var(--text-color);
    display: flex;
    align-items: center; /* Align with checkboxes */
    gap: 5px;
}

/* Ensure Sites label and checkboxes are in one row */
.pcode-filters {
    display: flex;
    align-items: center;
    gap: 5px; /* Space between label and checkboxes */
}

/* Ensure checkboxes stay inline */
.checkbox-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pcode_checkbox {
    accent-color: var(--primary-color); /* Match the theme */
    background-color: transparent; /* Ensures checkbox blends with background */
    border: none;
}

.p_code_checkbox:checked {
    background-color: transparent;
}

.add-actions {
    display: block; /* Forces it to stay below */
    width: 100%;
    margin-top: 5px;
    text-align: left; /* Align Add button to the left */
}

/* Common Input Style */
.input-uniform {
    width: 100%;
    padding: 6px;
    font-size: 14px;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    background-color: #f9f9f9;
    color: #333;
    box-sizing: border-box;
}

.multi-select {
    display: block;               /* Ensure it behaves like an input field */
    width: 100%;                  /* Match the width of input elements */
    max-height: calc(3em + 6px);  /* 3 rows, with extra padding */
    overflow-y: auto;             /* Add a scrollbar for overflow content */
    padding: 4px;                 /* Ensure padding matches input styles */
    font-size: 14px;              /* Match font size to .input-uniform */
    border: 1px solid #ccc;       /* Add a uniform border style */
    border-radius: 4px;           /* Match rounded corners */
    box-sizing: border-box;       /* Include padding in width/height */
    background-color: #fff;       /* Ensure consistent background color */
    color: #333;                  /* Match text color */
}

/* Inputs and Selects */
/*.search-form input, */
.search-form select {
    padding: 8px;
    font-size: 14px;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    width: 100%; /* Full width within form group */
    box-sizing: border-box;
}

/* General Button Styling for Frames and Tables */
.frame .button,
.results-table .button {
    display: inline-block; /* Make the button a block-level element */
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    color: var(--background-color);
    background-color: var(--primary-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
    width: auto;
}

.frame .button:hover,
.results-table .button:hover {
    background-color: var(--secondary-color);
}

/* Results Frame */
.search-results-frame {
    flex: 1; /* Maintain frame height proportional to container */
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 0; /* Prevent unnecessary stretching */
    overflow: hidden; /* Prevent scrolling for the frame itself */
}

.results-scrollable {
    flex-grow: 1; /* Allow this section to take up available space */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: auto; /* Enable horizontal scrolling */
    margin-top: 0;
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
}

.results-table {
    table-layout: auto; /* Ensure columns adjust based on content */
    width: 100%;
    min-width: 100%;
    border-collapse: separate; /* Changed */
    border-spacing: 0;         /* Required to eliminate spacing */
    font-size: 14px;
}

.results-table thead tr:first-child th:first-child {
    border-top-left-radius: 8px;
}

.results-table thead tr:first-child th:last-child {
    border-top-right-radius: 8px;
}

.results-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}

.results-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

.results-table th, .results-table td {
    padding: 8px;
    border: 1px solid var(--input-border-color);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Ensure content does not overflow cells */
}

.results-table th {
    position: sticky;
    top: 0;
    background-color: var(--background-color); /* Ensure it's not transparent */
    z-index: 2; /* Ensure it stays above table rows */
    box-shadow: none;
}

.results-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.results-table tr:hover {
    background-color: #e8f4fd;
}

.results-table th:first-child,
.results-table td:first-child {
    width: auto; /* Allow the column width to adjust dynamically */
    white-space: nowrap; /* Prevent wrapping of long values */
}

/* Search Form Button */
.search-form .button {
    /* grid-column: 1; /* Place the button under the first text box */
    /* justify-self: start; /* Align the button to the left */
    /* margin-top: 0; /* Add space above the button */

    /* Button Styling */
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    color: var(--background-color);
    background-color: var(--primary-color);
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
}

.search-form .button:hover {
    background-color: var(--secondary-color);
}

.search-form .button:disabled,
.frame .button:disabled,
.results-table .button:disabled {
    background-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    border-color: #aaa !important;
    opacity: 0.7;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    margin-right: 12px;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    accent-color: var(--primary-color); /* matches theme */
    margin-right: 4px;
    cursor: pointer;
}

.radio-label.disabled {
    pointer-events: none;
    opacity: 1;
}

.radio-label.disabled input[type="radio"] {
    accent-color: var(--primary-color);
    cursor: default;
}

/* Paginator */
.paginator {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.paginator a {
    margin: 0 5px;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: bold;
}

.paginator a:hover {
    text-decoration: underline;
}

.paginator span {
    margin: 0 10px;
    font-weight: bold;
}

/* Stats Frame */
.stats-frame,
.graphs-frame {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background-color); /* Match search frame */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

/* Remove conflicting or redundant flex properties */
.stats-frame {
    /* Ensure only one definition for .stats-frame exists */
    flex: 1; /* Ensure proportional height */
}

.graphs-frame {
    /* Ensure only one definition for .graphs-frame exists */
    flex: 2; /* Ensure proportional height */
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Dynamically fit items */
    gap: 10px; /* Space between grid items */
    align-items: start; /* Align items to the top */
    margin-top: 10px;
}

/* Stat Item */
.stat-item {
    display: flex;
    flex-direction: column; /* Stack label and value vertically */
    justify-content: start;
    font-size: 14px;
}

.stat-item label {
    font-weight: bold;
    margin-bottom: 5px; /* Space between label and value */
}

.stat-item input {
    width: 100%; /* Full width of the grid cell */
    padding: 6px;
    font-size: 12px;
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    background-color: #f9f9f9; /* Light background */
    color: #333; /* Text color */
    text-align: left; /* Center-align values */
    box-sizing: border-box;
}

/* Harmonize .expandable-select with .stat-item input */
.expandable-select {
    width: 100%; /* Match the dynamic width of .stat-item input */
    padding: 6px; /* Add padding for consistency */
    font-size: 12px; /* Match the font size */
    border: 1px solid var(--input-border-color); /* Match border */
    border-radius: 4px; /* Add rounded corners */
    background-color: #f9f9f9; /* Light background color */
    color: #333; /* Match text color */
    box-sizing: border-box; /* Ensure consistent box-sizing */
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden; /* Hide overflowing content */
    text-overflow: ellipsis; /* Apply ellipses */
}

/* Optional: Ensure options display correctly */
.expandable-select option {
    white-space: normal; /* Allow wrapping within options */
    overflow: visible; /* Ensure content is visible */
}

.graphs-frame canvas {
    max-width: 100%;
    margin: 20px 0;
    font-weight: normal !important;
}

.hidden-content {
    display: none;
}
  
.visible-content {
    display: block;
}

.messages {
    text-align: left; /* Align messages for readability */
}

.messages .message {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid transparent; /* Base border to be overridden by specific types */
}

/* Error message styling */
.messages .message.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Success message styling */
.messages .message.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* Info message styling */
.messages .message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

/* Warning message styling */
.messages .message.warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}