﻿/* Early Voting Sites Search Page Styles */

/* Constrain the ibox width to reduce excessive whitespace */
.ibox.float-e-margins {
    max-width: 1000px;
    margin: 0 auto 20px;
}

.ibox-content.early-voting-sites-search {
    padding: 15px !important;
}

.early-voting-sites-search {
    padding: 0 !important;
}

/* County Selector Section */
#CountySelector {
    margin: 0 !important; /* Remove all margins */
    margin-bottom: 20px !important; /* Add back bottom margin */
    padding: 0 !important; /* Remove any padding */
    width: 100%;
}

/* Result Section */
#divResult {
    margin: 0 !important; /* Remove all margins including top spacing */
    padding: 0 !important;
    width: 100%;
    overflow-x: hidden; /* ensure no stray negative margins/padding can visually spill */
}

/* Remove margins and padding from nested div (except divLink which has its own spacing rules) */
#CountySelector > div:not(#divLink) {
    margin: 0 !important;
    padding: 0 !important;
}

/* Clearfix for floated children */
#CountySelector:after {
    content: "";
    display: table;
    clear: both;
}

#divCounty {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Make Registration County label bold */
#divCounty .control-label {
    font-weight: bold;
}

/* Dropdown wrapper for chevron icon */
.dropdown-wrapper {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    max-width: 220px; /* Prevent excessive width */
}

.dropdown-wrapper::after {
    content: '\25BC'; /* Down chevron */
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 12px;
    color: #555;
    transition: transform 0.3s ease;
}

.dropdown-wrapper.open::after {
    transform: translateY(-50%) rotate(180deg);
}

#divCounty .form-control {
    display: inline-block;
    width: 200px;
    max-width: 100%;
    padding-right: 35px; /* Make room for chevron */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: white;
}

#CountylblError {
    margin-left: 0;
    margin-top: 5px;
}

#CountyElectionInfo {
    color: #333;
    margin-top: 0; /* Remove vertical spacing above */
    margin-bottom: 0; /* Remove vertical spacing below */
    display: block;
    width: 100%;
    clear: both; /* Clear any floats from desktop layout */
}

/* Map and Site List Container */
.row.map-site-list-container {
    width: 100%;
    display: flex;
    align-items: flex-start;

    /* Bootstrap .row uses negative margins; neutralize so it doesn't spill outside #divResult */
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

/* Keep existing container selector for any non-row uses */
.map-site-list-container {
    width: 100%;
}

.map-site-list-container .row {
    display: flex;
    align-items: flex-start;
    margin-left: 0;
    margin-right: 0;
}

.map-site-list-container .col-sm-6 {
    display: flex;
    flex-direction: column;
}

/* First column (list/detail) should match map height */
.map-site-list-container .col-sm-6:first-child {
    min-height: 600px;
}

/* Remove left padding from list/detail column */
#listDetailColumn {
    padding-left: 0;
    padding-right:0;
    overflow: hidden; /* Clip animation overflow to prevent momentary scrollbar during view transitions */
}

.map-column {
    padding: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    min-height: 600px; /* Default minimum height for desktop */
}

#sitemap {
    width: 100%;
    height: 600px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    visibility: hidden; /* Hide until height is calculated to prevent flash */
}

/* List and Detail Results - flex, animations, and transitions */
#ListResults,
#DetailResult {
    flex: 1;
    animation: slideIn 0.3s ease-out;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    min-height: 600px; /* Maintain consistent height when toggling views */
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure the partial root (#Results) stretches to match its container (#ListResults) */
#ListResults {
    display: flex;
    flex-direction: column;
}

#ListResults > #Results {
    flex: 1 1 auto;
}

/* Site List Results */
.site-list-results {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    height: 100%; /* Fill parent container completely */
    min-height: 600px; /* Ensure consistent height */
}

.results-header,
.detail-header {
    font-weight: bold;
    text-transform: uppercase;
}

/* Border styling to match legacy - blue borders (#337ab7) */
.border-between {
    border-top: 1px solid #337ab7;
}

/* Remove top border from first row in Results to align with map top */
#Results > .border-between:first-child {
    border-top: none;
}

/* Add padding on top of each row except first child */
.border-between:not(:first-child) {
    padding-top: 0.5em;
}

/* Add bottom border ONLY to navigation row (not site rows) */
#navrow.border-between {
    border-bottom: 1px solid #337ab7;
}

/* No borders for empty placeholder rows - container provides left/right */
.no-border-between {
    padding-top: 0.57em;
}

/* Push navigation row to bottom */
#navrow {
    margin-top: auto;
    padding-top: 0em;
}

/* Previous/Next Site button styling */
#navrow .btn-link {
    text-decoration: none;
    color: inherit; /* Use inherited text color by default */
}

/* Remove blue border/outline when button is clicked or focused */
#navrow .btn-link:focus,
#navrow .btn-link:active,
#navrow .btn-link:focus-visible {
    outline: none;
    box-shadow: none;
    border: none;
}

/* Change text color to blue on hover and focus */
#navrow .btn-link:hover,
#navrow .btn-link:focus {
    color: #337ab7 !important;
    text-decoration: underline !important;
}

/* Add border between navigation columns */
.col-border {
    border-right: 1px solid #337ab7;
}

.site-row {
    min-height: 120px;
}

/* Match legacy fixed height for empty tables */
.table-borderless {
    min-height: 182px;
}

/* Create table with no borders */
.table-borderless>thead>tr>th,
.table-borderless>tbody>tr>th,
.table-borderless>tfoot>tr>th,
.table-borderless>thead>tr>td,
.table-borderless>tbody>tr>td,
.table-borderless>tfoot>tr>td {
    border: none !important;
}

/* Set fixed width for first column (sequence number) */
.table-borderless>tbody>tr>td:first-child {
    width: 6% !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
}

/* Remove the bottom margin on the table to avoid extra white space */
.col-sm-12>table {
    margin-bottom: 0px;
}

.site-sequence {
    font-family: "Material Icons", Arial, sans-serif;
    font-size: 16px;
    width: 30px;
    vertical-align: top;
}

/* Remove padding from link button to align with other text */
.btn-site-detail {
    text-align: left;
    padding: 0;
    white-space: normal;
    word-wrap: break-word;
}

.btn-site-detail:hover,
.btn-site-detail:focus {
    text-decoration: none;
}

.btn-site-detail u {
    color: #2563a0;
}

/* Replace obsolete <u> element usage: provide a class for underlined text */
.btn-site-detail .underline-text {
    color: #2563a0;
    text-decoration: underline;
}

/* Pagination buttons */
#prevlink,
#nextlink {
    padding: 10px 15px;
}

/* Site Detail */
.site-detail {
    background-color: #fff;
}

.btn-close-detail {
    float: right;
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    color: #000;
    opacity: 0.65;
    background: none;
    border: none;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.btn-close-detail:hover,
.btn-close-detail:focus {
    opacity: 1;
}

.hours-table {
    margin-top: 10px;
}

.hours-table td {
    padding: 2px 5px;
}

/* Fixed height for consistency */
.fh-200 {
    min-height: 120px;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 40px;
}

.loading-indicator .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #337ab7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Styles */
@media (max-width: 767px) {
    .map-site-list-container .row {
        display: block;
    }

    .map-site-list-container .col-sm-6 {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
    }

    #listDetailColumn {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important; /* Remove fixed min-height in mobile */
    }

    /* Remove desktop map-matching min-height in mobile (map is hidden) */
    #ListResults,
    #DetailResult {
        min-height: auto !important;
    }

    /* Override base min-height for mobile */
    .map-site-list-container .col-sm-6:first-child {
        min-height: auto !important;
    }

    /* Hide map div completely in mobile to prevent vertical spacing */
    #divMap {
        display: none !important;
    }

    .map-column {
        display: none;
        position: static;
    }

    #sitemap {
        display: none;
    }

    .site-list-results {
        border: none;
        min-height: 400px !important; /* Ensure minimum height in mobile for last row to expand */
    }

    /* Make the last site row fill remaining space in mobile */
    .site-list-results > .site-row:last-of-type {
        flex: 1 1 auto; /* Allow last site row to grow and fill remaining space */
    }

    /* Add bottom border on navigation row or last visible row before nav on mobile */
    .site-list-results > .border-between:last-of-type,
    .site-list-results > .no-border-between:last-of-type {
        border-bottom: 1px solid #337ab7;
    }

    /* Hide navigator button row on mobile */
    #navrow {
        display: none;
    }

    .early-voting-sites-search {
        padding: 10px;
    }

    /* Make the county selector a flex column layout so label is above, dropdown and button on same line */
    #divCounty {
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Label goes full width at top */
    #divCounty .control-label {
        white-space: nowrap;
        margin-bottom: 0;
        width: 100%;
    }

    /* Make the wrapper and dropdown flexible in a row (dropdown and button on same line) */
    #divCounty > span:first-of-type {
        display: flex !important;
        align-items: center;
        gap: 4px;
        flex: 1 1 auto;
        width: 100%;
        min-width: 0; /* allow shrinking below content width */
    }

    .dropdown-wrapper {
        flex: 1 1 auto;
        min-width: 120px; /* Minimum width to keep dropdown usable */
        max-width: 100%;
    }

    /* Allow the actual select to shrink and fill the wrapper */
    #divCounty .form-control {
        width: 100%;
        min-width: 0;
    }

    /* Keep the Find Sites button fixed to avoid shrinking and breaking */
    #divCounty .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    #CountylblError {
        margin-left: 0;
        margin-top: 5px;
    }

    /* Remove width constraints to fill full ibox-content width */
    #CountySelector,
    #divResult {
        width: 100%;
        max-width: 100%;
        padding: 0 !important;
    }

    #CountySelector {
        margin: 0 !important;
        display: block; /* Ensure block layout, not grid in mobile */
    }

    /* Add vertical spacing above and below election info paragraph in mobile */
    #CountyElectionInfo {
        margin-top: 10px; /* Spacing between dropdown and paragraph */
        margin-bottom: 10px; /* Spacing between paragraph and download link */
    }

    #divResult {
        margin: 0 !important;
        margin-top: 10px !important; /* Spacing between download link and results-header */
    }

    /* Position download link below election info in mobile view (natural flow) */
    #divLink {
        display: block;
        width: 100%;
        position: static;
        margin: 0 !important;
        margin-top: 10px !important; /* Spacing above when CountyElectionInfo is hidden */
        padding: 0;
    }

    #divLink > p {
        text-align: left;
        margin: 0;
    }
}

@media (min-width: 768px) {
    .map-column {
        display: flex !important;
    }

    /* Reset ibox-content height to auto in desktop view */
    .ibox-content.early-voting-sites-search {
        height: auto !important;
        min-height: auto !important;
    }

    /* Ensure proper 50/50 split when both columns are visible */
    #listDetailColumn {
        width: 50% !important;
        max-width: 50% !important;
        flex: 0 0 50% !important;
    }

    #divMap {
        width: 50% !important;
        max-width: 50% !important;
        flex: 0 0 50% !important;
    }

    /* Remove width constraints to fill full ibox-content width */
    #CountySelector,
    #divResult {
        width: 100%;
        max-width: 100%;
        padding: 0 !important;
        clear: both;
    }

    #CountySelector {
        margin: 0 !important;
    }

    #divResult {
        margin: 0 !important; /* Remove top margin - no spacing between download link and results */
    }

    /* Add top spacing to #divResult only when it contains content and is visible (not hidden). This prevents the county dropdown and #divResult from touching in desktop view. */
    #divResult:not(:empty):not([style*="display:none"]):not(.d-none):not(.hidden) {
        margin-top: 12px !important; /* adjust spacing value as needed */
    }

    /* Use CSS Grid to reposition elements in desktop view */
    #CountySelector {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "paragraph paragraph"
            "controls link"
            "election election";
        column-gap: 15px;
    }

    #CountySelector > p:first-child {
        grid-area: paragraph;
    }

    .county-controls-row {
        grid-area: controls;
        display: flex;
        align-items: center;
        min-height: 38px;
    }

    /* Desktop: Reset mobile column layout - keep label inline with dropdown/button */
    #divCounty {
        display: block !important;
    }

    /* Desktop: Keep label inline with controls */
    #divCounty .control-label {
        display: inline-block;
        margin-right: 10px;
        vertical-align: middle;
        margin-bottom: 0;
    }

    /* Desktop: The span containing dropdown/button displays inline */
    #divCounty > span:first-of-type {
        display: inline-block;
        vertical-align: middle;
    }

    /* Desktop: Error message should appear on new line, offset by label width */
    #CountylblError {
        margin-left: 145px; /* Approximate width of "Registration County" label + margin */
        margin-top: 5px;
    }

    #CountyElectionInfo {
        grid-area: election;
        margin-top: 10px; /* Slight vertical spacing above */
        margin-bottom: 10px; /* Slight vertical spacing below */
    }

    #divLink {
        grid-area: link;
        display: flex;
        align-items: center; /* Vertically center with button row */
        justify-content: flex-end; /* Right align content */
        position: static; /* Reset mobile position */
        top: auto; /* Reset mobile top offset */
        margin-bottom: 20px; /* Add spacing below for alert messages */
    }

    #divLink > p {
        text-align: right;
        margin: 0;
        white-space: nowrap;
    }
}

/* Mobile Landscape version - match legacy */
@media (min-width: 520px) and (max-width: 767px) and (orientation: landscape) {
    /* Needed to show the election information in one line */
    #CountyElectionInfo {
        min-width: 500px;
    }
}

/* Print Styles */
@media print {
    .map-column,
    #sitemap,
    #navrow,
    .btn-close-detail,
    #btnFindSites,
    #downloadStatewideList {
        display: none !important;
    }

    .site-list-results {
        border: none;
    }

    .border-between {
        border-bottom: 1px solid #000;
    }
}

/* SearchPopup Modal Styles */
body.modal-open #searchModal + .modal-backdrop,
body.modal-open #searchModal + .modal-backdrop.fade,
body.modal-open #searchModal + .modal-backdrop.show,
body.modal-open #searchModal + .modal-backdrop.fade.show,
body.modal-open .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.35) !important;
    opacity: 1 !important;
}

.search-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease-in-out;
    z-index: 1049;
}

#searchModal.show ~ .search-modal-overlay {
    opacity: 1;
}

/* Fade-in animation for error messages */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduced motion support for users with vestibular disorders (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .loading-indicator .spinner {
        animation: none !important;
        border-top-color: #337ab7;
    }
    
    #ListResults,
    #DetailResult {
        animation: none !important;
    }
}
