/* Advanced Search Amenities Styles */

/* More Search Options Button */
.adv_extended_options_text {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--wprentals-primary-color);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
    letter-spacing: 0.5px;
    gap: 8px;
}

.adv_extended_options_text:hover {
    background-color: rgba(128, 106, 230, 0.1);
    color: var(--wprentals-primary-color);
    transform: translateY(-1px);
}

.adv_extended_options_text:after {
    content: "\f078";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    transition: transform 0.3s ease;
    display: inline-block;
}

.adv_extended_options_text.active:after {
    transform: rotate(180deg);
}

/* Extended Search Container */
.extended_search_check_wrapper {
    display: none;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    margin-top: 8px;
    min-width: 100%;
    width: auto;
}

/* Amenities Grid Layout */
.advanced-search-amenities-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-top: 15px;
    width: 100%;
    padding-top: 30px;
}

/* Tablet: 3 columns */
@media (max-width: 992px) {
    .advanced-search-amenities-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    /* tablet adjustments: slightly smaller icons and text */
    .search-amenity-icon {
        width: 24px;
        height: 24px;
    }

    .search-amenity-name {
        font-size: 11px;
    }
}

/* Mobile: 2 columns */
@media (max-width: 768px) {
    .advanced-search-amenities-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

/* Small mobile: Keep 2 columns */
@media (max-width: 480px) {
    .advanced-search-amenities-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

/* Amenity Card Styles - Adapted from dashboard styles */
.search-amenity-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 10px;
    transition: all 0.3s ease;
    background-color: #ffffff;
    position: relative;
    cursor: pointer;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.search-amenity-card:hover {
    border-color: var(--wprentals-secondary-color);
    background-color: var(--wprentals-secondary-color);
    box-shadow: 0 2px 12px rgba(68, 66, 70, 0.35);
    transform: translateY(-2px);
}

.search-amenity-card.checked {
    border-color: var(--wprentals-secondary-color);
    background-color: var(--wprentals-secondary-color);
    box-shadow: 0 2px 12px rgba(68, 66, 70, 0.35);
    color: #ffffff;
}

.search-amenity-card.checked .search-amenity-name {
    color: #ffffff;
    font-weight: 600;
}

.search-amenity-card.checked .search-amenity-icon svg,
.search-amenity-card.checked .search-amenity-icon-svg svg {
    fill: #ffffff !important;
    color: #ffffff;
}

/* Hidden Checkbox (positioned to the right of the icon)
   The checkbox is placed inside `.search-amenity-icon` in markup so
   absolute positioning is relative to the icon container. */
.search-amenity-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
    pointer-events: auto;
    flex-shrink: 0;
    accent-color: var(--wprentals-secondary-color);
    z-index: 1; /* behind the visible svg icon (svg has z-index:2) */
    top: 50%;
    left: calc(100% + 6px); /* place just to the right of the icon */
    transform: translateY(-50%);
}

/* Amenity Label */
.search-amenity-label {
    margin-top: 10px;
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: center; /* center text below the icon */
    pointer-events: auto; /* ensure label handles clicks */
}

/* Amenity Icon */
.search-amenity-icon {
    /* make the icon a block so it can be precisely centered above the label */
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto 0; /* small, consistent gap between icon and text (desktop) */
    line-height: 0; /* remove inline SVG baseline whitespace */
    position: relative; /* keep relative for absolute checkbox positioning */
    z-index: 2; /* icon sits above the checkbox */
    pointer-events: auto; /* allow checkbox (child) to receive events */
}

/* Ensure the visible icon uses the theme primary/main color by default.
   Falls back to existing inherited color if CSS variables are not defined. */
.search-amenity-icon {
    color: var(--wprentals-primary-color, var(--wprentals-main-color, inherit));
}

.search-amenity-icon svg,
.search-amenity-icon-svg svg {
    display: block; /* remove inline whitespace and reduce gap */
    width: 100%;
    height: 100%;
    max-width: 28px;
    max-height: 28px;
    /* use currentColor so theme/custom CSS (`customcss.php`) can set the color (e.g. $main_color) */
    fill: currentColor;
    transition: fill 0.3s ease;
    object-fit: contain;
}

/* Make svg itself non-intercepting so clicks reach the checkbox placed beside it */
.search-amenity-icon svg {
    pointer-events: none;
}

.search-amenity-card.checked .search-amenity-icon svg,
.search-amenity-card.checked .search-amenity-icon-svg svg {
    fill: #ffffff !important;
}

.search-amenity-icon-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* (duplicate definitions removed) */

.search-amenity-icon-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.search-amenity-icon-default {
    font-size: 28px;
    /* use theme primary/main color as fallback for icon fonts */
    color: var(--wprentals-primary-color, var(--wprentals-main-color, inherit));
    transition: color 0.3s ease;
}

.search-amenity-card.checked .search-amenity-icon-default {
    color: #ffffff;
}

/* Amenity Name */
.search-amenity-name {
    flex-grow: 1;
    font-size: 12px;
    font-weight: 500;
    /* Use theme font color when available, fall back to inherited color */
    color: var(--wprentals-font-color, inherit);
    transition: color 0.3s ease;
    margin: 0;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
}

/* Close Button */
.adv_extended_close_button {
    position: relative;
    cursor: pointer;
    color: #666;
    font-size: 18px;
    transition: color 0.3s ease;
    z-index: 1001;
    background: none;
    border: none;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.amenities-search-wrapper .adv_extended_close_button {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
}

.adv_extended_close_button:hover {
    color: #333;
}

/* Scrollbar Styling */
.extended_search_check_wrapper::-webkit-scrollbar {
    width: 8px;
}

.extended_search_check_wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.extended_search_check_wrapper::-webkit-scrollbar-thumb {
    background: var(--wprentals-primary-color);
    border-radius: 4px;
}

.extended_search_check_wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--wprentals-secondary-color);
}

/* Legacy checkbox styles - hide if using new grid */
.extended_search_checker {
    display: none;
}

.extended_search_checker.legacy {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .extended_search_check_wrapper {
        max-height: 300px;
        padding: 12px;
    }

    .advanced-search-amenities-grid {
        padding-top: 32px;
    }

    .adv_extended_options_text {
        font-size: 13px;
        padding: 8px 14px;
    }

    .search-amenity-card {
        padding: 10px 8px;
        min-height: 65px;
    }

    .search-amenity-name {
        font-size: 11px;
    }

    /* mobile (<=768) - slightly smaller icons and text for readability */
    .search-amenity-icon {
        width: 20px;
        height: 20px;
      
    }

    .search-amenity-name {
        font-size: 10px;
    }

    .search-amenity-icon svg,
    .search-amenity-icon-svg svg {
        max-width: 24px;
        max-height: 24px;
    }

    .adv_extended_close_button {
        top: 8px;
        right: 10px;
    }

    /* adjust checkbox offset for tablet - keep it vertically centered next to icon */
    .search-amenity-checkbox {
        left: calc(100% + 6px);
        top: 50%;
        transform: translateY(-50%);
    }
}

@media (max-width: 480px) {
    .extended_search_check_wrapper {
        max-height: 250px;
        padding: 10px;
        left: 0;
        right: 0;
        border-radius: 8px;
    }

    .advanced-search-amenities-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding-top: 35px;
    }

    .adv_extended_options_text {
        font-size: 12px;
        padding: 8px 12px;
    }

    .search-amenity-card {
        padding: 6px 4px;
        min-height: 50px;
    }

    /* small mobile (<=480) - smallest icon and text, 2 columns */
    .search-amenity-icon {
        width: 16px;
        height: 16px;
    }

    .search-amenity-name {
        font-size: 9px;
    }

    .search-amenity-icon svg,
    .search-amenity-icon-svg svg {
        max-width: 16px;
        max-height: 16px;
    }

    .adv_extended_close_button {
        top: 5px;
        right: 8px;
        font-size: 14px;
        padding: 3px;
    }

    /* adjust checkbox offset for small mobile */
    .search-amenity-checkbox {
        left: calc(100% + 6px);
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Amenities Search Bar */
.amenities-search-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #f8f9fa;
    margin-bottom: 10px;
    border-radius: 6px;
    padding: 10px;
    position: relative;
    z-index: 100;
}

.amenities-search-input {
    flex: 1;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    transition: border-color 0.3s ease;
}

.amenities-search-input:focus {
    outline: none;
    border-color: var(--wprentals-primary-color) !important;
    box-shadow: 0 0 0 3px rgba(128, 106, 230, 0.1) !important;
}

/* Hide amenities that don't match search */
.search-amenity-card.hidden-by-search {
    display: none;
}

/* Show message when no amenities match search */
.advanced-search-amenities-grid.no-results::after {
    content: '';
    display: block;
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
    width: 100%;
    grid-column: 1 / -1;
}

/* Responsive Styles for Search Bar */
@media (max-width: 768px) {
    .amenities-search-wrapper {
        padding: 8px;
        gap: 8px;
    }

    .amenities-search-input {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }

    .amenities-search-wrapper .adv_extended_close_button {
        font-size: 16px;
        padding: 4px;
    }
}

@media (max-width: 480px) {
    .amenities-search-wrapper {
        padding: 8px;
        gap: 6px;
        margin-bottom: 8px;
    }

    .amenities-search-input {
        padding: 6px 8px !important;
        font-size: 12px !important;
    }

    .amenities-search-wrapper .adv_extended_close_button {
        font-size: 14px;
        padding: 3px;
    }
}
