﻿.k-grid-header,
.k-grid-header .k-header,
.k-grouping-header,
.k-grid-pager,
.k-grid-footer {
    background-color: #C4E2F7 !important;
}

.k-table-alt-row{
    background-color: #F3FAFE !important;
}

.k-grid-header .k-header {
    font-weight: bold;
    /* removed underline for accessibility/visual clarification */
    text-decoration: none;
}
.white-button{
    background-color: white !important;
    border: 1px solid black !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin-right: 5px;
}

.k-grid-pager {
    display: flex !important;
    flex-direction: row-reverse;
    align-items: center;
}

.k-pager-info{
    justify-content: flex-start;
}

.k-pager-numbers-wrap{
    justify-content: flex-end;
}

.k-pager-numbers-wrap .k-button {
    background-color: white !important;
    border: 1px solid #ccc !important;
    color: #333 !important;
    margin-left: 6px;
}

.k-pager-numbers-wrap .k-button.k-state-selected,
.k-pager-numbers-wrap .k-button.k-selected,
.k-pager-numbers-wrap .k-button.k-state-active,
.k-pager-numbers-wrap .k-button[aria-current="true"] {
    background-color: #1C84C6 !important; 
    color: #ffffff !important;            
    border-color: #000 !important;
    font-weight: bold;
    box-shadow: 0 0 0 2px #000, 0 2px 6px rgba(0,0,0,0.15);
}

#resultsGridContainer {
    width: 100% !important; /* Adjust as needed */
    margin: 0 auto;
}
#petitionSearchResultsSection,
#searchResultsRegion {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
    align-self: stretch !important;
}

#searchResultsRegion {
    background-color: #ffffff !important;
    margin-bottom: 0 !important;
}

#searchResultsContent {
    margin-left: 20px !important;
    margin-right: 20px !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
}

.instruction-panel {
    margin: 0 auto;
    border: 3px solid #1c84c6;
    font-weight: 600;
    line-height: 1.5;
    padding: 0;
    text-align: center;
}

.instruction-panel .k-expander-header {
    background-color: #f7fbff;
    padding: 6px 12px;
    min-height: auto;
}

.instruction-panel .k-expander-title {
    font-weight: 700;
    line-height: 1.2;
    text-transform: none;
}

.instruction-list {
    text-align: left;
    margin: 0;
    padding-left: 1.5rem;
    line-height: 1.5;
}

.instruction-list li {
    margin-bottom: 4px;
}

/* Correct selector: the petition results grid's Name() is petitionSearchResultsGrid */
#petitionSearchResultsGrid { /* was #voterSearchResultsGrid */
    width: 100% !important;
    max-width: 100%;
}

/* Center-align all header content (desktop + mobile) */
#petitionSearchResultsGrid .k-grid-header th,
#petitionSearchResultsGrid .k-table-thead th,
.county-detail-wrapper .k-grid-header th,
.county-detail-wrapper .k-table-thead th {
    text-align: center !important;
    vertical-align: middle !important;
}
#petitionSearchResultsGrid .k-grid-header th .k-link,
#petitionSearchResultsGrid .k-table-thead th .k-link,
.county-detail-wrapper .k-grid-header th .k-link,
.county-detail-wrapper .k-table-thead th .k-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    width: 100%;
    gap: 0.35rem;
}
#petitionSearchResultsGrid .k-grid-header th .k-link .k-column-title,
#petitionSearchResultsGrid .k-table-thead th .k-link .k-column-title,
.county-detail-wrapper .k-grid-header th .k-link .k-column-title,
.county-detail-wrapper .k-table-thead th .k-link .k-column-title {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    text-align: center !important;
    justify-content: center !important;
}
#petitionSearchResultsGrid .k-grid-header th .k-link .k-sort-icon,
#petitionSearchResultsGrid .k-table-thead th .k-link .k-sort-icon,
.county-detail-wrapper .k-grid-header th .k-link .k-sort-icon,
.county-detail-wrapper .k-table-thead th .k-link .k-sort-icon {
    margin-left: auto;
    align-self: center;
}

/* Responsive: Hide desktop columns on small screens, hide mobile column on wide screens */
@media (max-width: 1000px) { /* MOBILE <=1000px */
    .k-grid td.desktop-col,
    .k-grid th.desktop-col {
        display: none !important;
    }
    .k-grid td.mobile-combined-col,
    .k-grid th.mobile-combined-col {
        display: table-cell !important;
        width: 100% !important;
    }
    .k-grid table {
        table-layout: auto !important;
    }
    .k-grid-pager {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center;
        align-items: center;
        gap: 4px 6px;
        padding: 8px 14px; /* symmetric horizontal padding */
        overflow: visible !important; /* no horizontal scroll */
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
    }
    .k-grid-pager > * { min-width: 0; }
    .k-grid-pager .k-button, .k-pager-numbers-wrap .k-button {
        margin: 0 2px !important;
    }
    #petitionSearchResultsGrid,
    #petitionSearchResultsGrid .k-grid-content,
    #petitionSearchResultsGrid .k-table-wrap {
        width:100% !important;
        max-width:100% !important;
        box-sizing:border-box !important;
        overflow-x:visible !important;
    }
    /* Ensure hierarchy (expand/collapse) cell has predictable narrow width */
    #petitionSearchResultsGrid tr.k-master-row td.k-hierarchy-cell { width:34px !important; }
    /* Mobile combined column: occupy full remaining width and never clip text */
    #petitionSearchResultsGrid td.mobile-combined-col {
        display:table-cell !important;
        width:calc(100% - 34px) !important; /* subtract hierarchy cell */
        white-space:normal !important;
        word-break:break-word !important;
        word-wrap:break-word !important;
        overflow-wrap:break-word !important;
        overflow:visible !important; /* prevent right-edge clipping */
    }
    /* Inner content should also not clip */
    #petitionSearchResultsGrid td.mobile-combined-col > div,
    #petitionSearchResultsGrid td.mobile-combined-col h4 {
        max-width:100% !important;
        white-space:normal !important;
        word-break:break-word !important;
        overflow-wrap:break-word !important;
        overflow:visible !important;
        display:block;
    }
    /* Detail row cell: allow content visibility (avoid clipping petition name width recalculation) */
    #petitionSearchResultsGrid tr.k-detail-row td.petition-detail-cell { overflow:visible !important; }
}

/* Desktop breakpoint mirrors voter search results behavior */
@media (min-width: 1001px) { /* DESKTOP >=1001px */
    .k-grid td.mobile-combined-col,
    .k-grid th.mobile-combined-col { display: none !important; }
    .k-grid td.desktop-col,
    .k-grid th.desktop-col { display: table-cell !important; }

    /* Reserve space for Kendo expand/collapse (hierarchy) column */
    #petitionSearchResultsGrid .k-hierarchy-cell, 
    #petitionSearchResultsGrid th.k-hierarchy-cell { width: clamp(30px, 4%, 50px) !important; }

    /* Primary desktop width ratios (petition name set to 20%; remaining 8 columns share 76% (each 9.5%); sum = 20% + (8 * 9.5%) = 96% (+ 4% hierarchy = 100%). */
    /* UPDATED: Reduce petition name by 2% of 20% (0.4%) -> 19.6%; distribute freed 0.4% equally across 8 columns (+0.05% each: 9.5% -> 9.55%). New sum: 19.6% + (8 * 9.55%) = 96% (+ 4% hierarchy = 100%). */
    #petitionSearchResultsGrid .col-petition-name { width:19.6% !important; }
    #petitionSearchResultsGrid .col-required-signature { width:9.55% !important; }
    #petitionSearchResultsGrid .col-total-counties { width:9.55% !important; }
    #petitionSearchResultsGrid .col-total-checked-signature { width:9.55% !important; }
    #petitionSearchResultsGrid .col-total-valid-signature { width:9.55% !important; }
    #petitionSearchResultsGrid .col-status { width:9.55% !important; }
    #petitionSearchResultsGrid .col-certified-date { width:9.55% !important; }
    #petitionSearchResultsGrid .col-filing-date { width:9.55% !important; }
    #petitionSearchResultsGrid .col-expiration-date { width:9.55% !important; }

    /* Remove min-width constraints - clamp() handles this now */
    /* Old min-width rules deleted - clamp() min values prevent undersizing */

    /* Right-align numeric data cells for clarity */
    #petitionSearchResultsGrid td.col-required-signature,
    #petitionSearchResultsGrid td.col-total-counties,
    #petitionSearchResultsGrid td.col-total-checked-signature,
    #petitionSearchResultsGrid td.col-total-valid-signature {
        text-align: right !important;
    }

    /* Center-align date columns for visual consistency */
    #petitionSearchResultsGrid td.col-certified-date,
    #petitionSearchResultsGrid td.col-filing-date,
    #petitionSearchResultsGrid td.col-expiration-date {
        text-align: center !important;
    }

    /* Allow petition names to wrap without breaking words */
    #petitionSearchResultsGrid td.col-petition-name { 
        white-space: normal !important; 
        overflow-wrap: break-word !important;
        word-break: normal !important;
        overflow: visible !important;
    }

    .k-grid table { table-layout:fixed !important; }
}


/* County detail grid full-width behavior */
.county-detail-wrapper { width:100% !important; box-sizing:border-box; }
@media (min-width: 1001px) {
    .county-detail-wrapper { width:50% !important; }
}
.county-detail-wrapper .k-grid { width:100% !important; }
.county-detail-wrapper .k-grid table { width:100% !important; table-layout:fixed !important; }
.county-detail-wrapper .k-grid thead th.desktop-col,
.county-detail-wrapper .k-grid tbody td.desktop-col { width:auto !important; }
/* Distribute three columns evenly when desktop */
@media (min-width: 1001px) {
    .county-detail-wrapper .k-grid thead th.col-county-name,
    .county-detail-wrapper .k-grid tbody td.col-county-name { width:40% !important; }
    .county-detail-wrapper .k-grid thead th.col-total-sig-checked,
    .county-detail-wrapper .k-grid tbody td.col-total-sig-checked { width:30% !important; }
    .county-detail-wrapper .k-grid thead th.col-total-sig-valid,
    .county-detail-wrapper .k-grid tbody td.col-total-sig-valid { width:30% !important; }
    
    /* Right-align signature data cells in county detail grids */
    .county-detail-wrapper .k-grid tbody td.col-total-sig-checked,
    .county-detail-wrapper .k-grid tbody td.col-total-sig-valid {
        text-align: right !important;
    }
}
@media (max-width:1000px) {
    .county-detail-wrapper .k-grid td.mobile-combined-col,
    .county-detail-wrapper .k-grid th.mobile-combined-col { width:100% !important; display:table-cell !important; }
    
    /* Ensure text wraps properly in mobile view for county detail grid */
    .county-detail-wrapper .k-grid td.mobile-combined-col {
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Ensure h4 elements in county detail grid mobile view wrap text */
    .county-detail-wrapper .k-grid td.mobile-combined-col h4 {
        white-space: normal !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100%;
    }
}


@media (min-width: 1001px) {
    /* Desktop: allow headers to expand for wrapped text */
    #petitionSearchResultsGrid .k-grid-header tr,
    #petitionSearchResultsGrid .k-table-thead tr {
        min-height: 34px !important;
        height: 34px !important;
    }

    #petitionSearchResultsGrid .k-grid-header th.desktop-col,
    #petitionSearchResultsGrid .k-table-thead th.desktop-col {
        padding-top: 4px !important;
        padding-bottom: 4px !important;
        line-height: 16px !important;
        white-space: normal !important;
        overflow: visible !important;
        vertical-align: middle !important;
    }

    #petitionSearchResultsGrid .k-grid-header th.desktop-col .k-link,
    #petitionSearchResultsGrid .k-table-thead th.desktop-col .k-link {
        display: grid !important;
        grid-template-columns: 1fr auto;
        align-items: center !important;
        width: 100%;
        white-space: normal !important;
        overflow: visible !important;
        min-width: 0 !important;
        line-height: 16px !important;
        font-size: 12.50px !important; /* match legacy relative sizing */
        height: 100% !important;
        column-gap: 6px;
    }

    #petitionSearchResultsGrid .k-grid-header th.desktop-col .k-link .k-column-title,
    #petitionSearchResultsGrid .k-table-thead th.desktop-col .k-link .k-column-title {
        justify-self: center;
        min-width: 0 !important;
        white-space: normal !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
        overflow: visible !important;
        line-height: inherit !important;
        font-size: 12.50px !important;
        hyphens: auto !important;
    }

    #petitionSearchResultsGrid .k-grid-header th.desktop-col .k-link .k-sort-icon,
    #petitionSearchResultsGrid .k-table-thead th.desktop-col .k-link .k-sort-icon {
        justify-self: end;
        align-self: center;
        margin-left: 4px;
        flex-shrink: 0;
    }

    #petitionSearchResultsGrid .k-table-tbody tr td.desktop-col,
    #petitionSearchResultsGrid .k-grid tbody tr td.desktop-col {
        padding-top: 2px !important;
        padding-bottom: 2px !important;
        line-height: 18px !important;
        min-height: 30px;
        /*height: auto !important;*/
        height: 34px !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        overflow: visible !important;
    }
}

/* Desktop header wrapper: allow overflow visible so wrapped text is visible */
#petitionSearchResultsGrid .k-grid-header,
#petitionSearchResultsGrid .k-grid-header-wrap { overflow: visible !important; }


/* Focus / keyboard navigation: ensure focused grid cell has a clear 2px black border.
   Using box-shadow inset to avoid layout shift that a border would cause, while visually
   appearing as a solid border. If an actual border is later preferred, replace box-shadow
   with border:2px solid #000. */
#petitionSearchResultsGrid td.k-focus,
#petitionSearchResultsGrid th.k-focus,
#petitionSearchResultsGrid td:focus,
#petitionSearchResultsGrid th:focus,
#petitionSearchResultsGrid td.k-state-focused,
#petitionSearchResultsGrid th.k-state-focused,
#petitionSearchResultsGrid td[tabindex]:focus,
#petitionSearchResultsGrid th[tabindex]:focus {
    outline: none !important;          /* remove any default outline */
    box-shadow: 0 0 0 2px #000 inset !important; /* visual 2px border */
    position: relative;                /* ensure inset renders consistently */
    z-index: 2;                        /* lift above neighbors for clarity */
}
/* When the expand/collapse button inside the hierarchy cell has focus, show a full border on the TD wrapper. */
#petitionSearchResultsGrid td.k-hierarchy-cell:focus-within {
    outline: none !important;
    box-shadow: 0 0 0 1px #000 inset, 0 0 0 1px #000 !important;
    position: relative;
    z-index: 2;
    border-radius: 1px;
}
/* Child (county) detail grid focus styling */
.county-detail-wrapper .k-grid td.k-focus,
.county-detail-wrapper .k-grid th.k-focus,
.county-detail-wrapper .k-grid td:focus,
.county-detail-wrapper .k-grid th:focus,
.county-detail-wrapper .k-grid td.k-state-focused,
.county-detail-wrapper .k-grid th.k-state-focused,
.county-detail-wrapper .k-grid td[tabindex]:focus,
.county-detail-wrapper .k-grid th[tabindex]:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px #000 inset !important;
    position: relative;
    z-index: 2;
}
@media (forced-colors: active) {
    .county-detail-wrapper .k-grid td.k-focus,
    .county-detail-wrapper .k-grid th.k-focus,
    .county-detail-wrapper .k-grid td:focus,
    .county-detail-wrapper .k-grid th:focus {
        box-shadow: none !important;
        outline: 2px solid CanvasText !important;
        outline-offset: 0;
    }
}
/* High contrast mode (forced-colors): rely on outline for clarity */
@media (forced-colors: active) {
    #petitionSearchResultsGrid td.k-focus,
    #petitionSearchResultsGrid th.k-focus,
    #petitionSearchResultsGrid td:focus,
    #petitionSearchResultsGrid th:focus,
    #petitionSearchResultsGrid td.k-hierarchy-cell:focus-within {
        box-shadow: none !important;
        outline: 2px solid CanvasText !important;
        outline-offset: 0;
    }
}

/* Pager buttons focused: 2px solid black border (avoid shift via box-shadow fallback if needed) */
.k-grid-pager .k-button:focus,
.k-grid-pager a:focus,
.k-grid-pager button:focus,
.k-grid-pager .k-pager-nav:focus,
.k-grid-pager .k-pager-first:focus,
.k-grid-pager .k-pager-last:focus,
.k-grid-pager .k-pager-numbers-wrap .k-button:focus {
    outline: none !important;
    border: 2px solid #000 !important;
    box-shadow: none !important;
}
/* High contrast mode fallback */
@media (forced-colors: active) {
    .k-grid-pager .k-button:focus,
    .k-grid-pager a:focus,
    .k-grid-pager button:focus {
        border: 2px solid CanvasText !important;
    }
}
@media (max-width: 1000px) {
    /* Center mobile summary column headers (parent & child grids) */
    .k-grid th.mobile-combined-col { text-align: center !important; }
    .k-grid th.mobile-combined-col .k-link {
        display: flex !important; /* Kendo often uses inline-flex or block; force flex for centering */
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center !important;
    }
    .k-grid th.mobile-combined-col .k-link .k-column-title {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
}

/* Hover feedback: highlight entire row and show vertical dividers between cells */
#petitionSearchResultsGrid .k-grid tbody tr.k-detail-row > td,
#petitionSearchResultsGrid .k-table-tbody tr.k-detail-row > td {
    background-color: #ffffff !important;
    border-left: none !important;
}

#petitionSearchResultsGrid .k-grid tbody tr.k-detail-row:hover > td,
#petitionSearchResultsGrid .k-table-tbody tr.k-detail-row:hover > td {
    background-color: #ffffff !important;
}

#petitionSearchResultsGrid .k-grid tbody tr.k-master-row:hover td,
#petitionSearchResultsGrid .k-grid tbody tr.k-master-row:hover th,
#petitionSearchResultsGrid .k-table-tbody tr.k-master-row:hover td,
#petitionSearchResultsGrid .k-table-tbody tr.k-master-row:hover th,
#petitionSearchResultsGrid .k-grid .k-detail-row .k-grid tbody tr:hover td,
#petitionSearchResultsGrid .k-grid .k-detail-row .k-grid tbody tr:hover th,
#petitionSearchResultsGrid .k-table .k-detail-row .k-table tbody tr:hover td,
#petitionSearchResultsGrid .k-table .k-detail-row .k-table tbody tr:hover th {
    background-color: #f2f2f2 !important;
    transition: background-color 120ms ease-in-out;
}

#petitionSearchResultsGrid .k-grid tbody tr.k-master-row:hover td:first-child,
#petitionSearchResultsGrid .k-table-tbody tr.k-master-row:hover td:first-child,
#petitionSearchResultsGrid .k-grid .k-detail-row .k-grid tbody tr:hover td:first-child,
#petitionSearchResultsGrid .k-table .k-detail-row .k-table tbody tr:hover td:first-child {
    border-left: 1px solid #6b6b6b !important;
}

#petitionSearchResultsGrid .k-grid tbody tr.k-master-row:hover td + td,
#petitionSearchResultsGrid .k-table-tbody tr.k-master-row:hover td + td,
#petitionSearchResultsGrid .k-grid .k-detail-row .k-grid tbody tr:hover td + td,
#petitionSearchResultsGrid .k-table .k-detail-row .k-table tbody tr:hover td + td {
    border-left: 1px solid #6b6b6b !important;
}
