/**
 * Filter Components CSS
 * Reusable styles for filter sections
 */

.filter-section {
    border-radius: 8px;
    max-width: 1150px;
    margin-bottom: 0.5rem;
    overflow: visible;
}

.filter_header {
    background-color: #258001;
    color: #fff;
    padding: 8px;
    cursor: default;
    position: relative;
    margin-bottom: 8px;
    font-size: 1.1em;
    font-weight: bold;
    display: block;
    width: 100%;
}

.filter_header>span.icon>img {
    vertical-align: inherit;
}

.filter-row {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    overflow: visible;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-row-split {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.filter-row-buttons {
    justify-content: flex-end;
}

/* Flexible Grid Layout: 2 columns on desktop, 1 on mobile */
.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 20px;
    margin-bottom: 15px;
    overflow: visible;
}

.filter-item {
    flex: 0 0 calc(50% - 10px);
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    overflow: visible;
}

.filter-item-full {
    flex: 0 0 100%;
}

.filter-item .filter-label {
    font-weight: bold;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-item .date-range-group {
    flex: 1;
    min-width: 0;
}

.filter-item .dropdown_district {
    flex: 1;
    min-width: 0;
}

.filter-col-half {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    overflow: visible;
}

.filter-label {
    font-weight: bold;
    min-width: 80px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.filter-col-half .dropdown_district {
    flex: 1;
}


.dropdown_district {
    position: relative;
}

.dropdown_district button.collapsible {
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 16px;
    text-align: left;
    width: 100%;
    min-height: 40px;
    color: #757575;
}

.dropdown_district button.collapsible.has-selection {
    color: #000 !important;
}

/* .dropdown_district button.collapsible:hover {
    background-color: #e9ecef;
} */

.dropdown_district button.collapsible::after {
    content: '\f107';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
}

.dropdown_district .content {
    display: none;
    position: absolute;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
    min-width: 300px;
    margin-top: 2px;
    left: 0;
    top: 100%;
}

.dropdown_district .content.show {
    display: block;
}

.district-section {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.district-section:last-child {
    border-bottom: none;
}

.district-section-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.district-section-title.regional-title {
    background-color: #f0f8ff;
    border-bottom: 2px solid #007790;
    padding: 8px;
}

.regional-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: 0;
}

.regional-checkbox-label input[type="checkbox"] {
    margin-right: 8px;
}

.regional-checkbox-label span {
    font-weight: bold;
    color: #007790;
}

.district-section label {
    display: flex;
    align-items: baseline;
    padding: 5px 0;
    cursor: pointer;
}

.district-section input[type="checkbox"] {
    margin-right: 8px;
}

#organizerContent label {
    display: flex;
    align-items: baseline;
    padding: 5px 10px;
    cursor: pointer;
}

#organizerContent input[type="checkbox"] {
    margin-right: 8px;
}

.date-picker-section {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

#datepicker {
    padding: 8px 15px;
    border: 1px solid #ccc;
    font-size: 16px;
    width: 180px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

#searchBtn,
#resetBtn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    min-width: 120px;
    height: auto;
    white-space: nowrap;
}

#searchBtn {
    background-color: #007bff;
    color: white;
}

#searchBtn:hover {
    background-color: #0056b3;
}

#resetBtn {
    background-color: white;
    color: black;
    border: 1px solid #007bff;
}

#resetBtn:hover {
    background-color: #f8f9fa;
}

#activeFilters {
    padding: 8px;
    border-left: 4px solid #007790;
    border-radius: 4px;
    display: none;
}

#activeFilters.show {
    display: block;
}

.active-filter-item {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 5px;
    font-size: 1em;
}

.active-filter-item strong {
    color: #007790;
}

.filter-separator {
    display: inline;
}

/* Date range group for better mobile layout */
.date-range-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
    flex: 1;
}

.date-range-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.date-range-label {
    white-space: nowrap;
}

/* Datepicker input fields */
#datepickerFrom,
#datepickerTo {
    min-width: 80px;
    width: 100%;
    max-width: 220px;
    flex: 1;
}

.date-picker-section {
    position: relative;
}

/* Flatpickr calendar styling - ensure proper display */
.flatpickr-calendar {
    width: auto !important;
    min-width: 280px;
}

.flatpickr-calendar.open {
    z-index: 9999;
}

/* Mobile view: < 576px - all filters full width */
@media (max-width: 575px) {
    .filter-grid {
        gap: 15px;
    }

    .filter-item {
        flex: 0 0 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-item .date-range-group,
    .filter-item .dropdown_district {
        width: 100%;
    }

    .date-range-group {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .date-range-item {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .date-range-label {
        min-width: 30px;
    }

    .date-picker-section {
        flex: 1;
    }

    #datepickerFrom,
    #datepickerTo {
        width: 100%;
        max-width: none;
    }

    .dropdown_district .content {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 40px);
        max-width: 90vw;
        z-index: 9999;
    }
}

/* Tablet/Desktop: >= 576px and < 768px */
@media (min-width: 576px) and (max-width: 767px) {
    .filter-item {
        flex: 0 0 calc(50% - 10px);
    }
}

@media (max-width: 767px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-row-split {
        flex-direction: column;
    }

    .filter-col-half {
        min-width: 100%;
    }

    .filter-label {
        min-width: auto;
    }

    .filter-buttons {
        margin-left: 0;
        width: 100%;
        justify-content: stretch;
    }

    .filter-row-buttons {
        justify-content: stretch;
    }

    #searchBtn,
    #resetBtn {
        flex: 1;
        min-width: auto;
    }
    
    /* Display active filter items on separate rows in mobile */
    .active-filter-item {
        display: block !important;
        margin-bottom: 8px;
        margin-right: 0;
    }
    
    /* Hide pipe separator in mobile view */
    .filter-separator {
        display: none;
    }
}

