/**
 * Where to Buy - Listing Template Styles
 * 
 * Styles for dealer/contact listing results, sidebar, and modal
 * 
 * @package Kadence Child Theme
 */

/* ==========================================
   Results Page Layout (Sidebar + Content)
   ========================================== */
.where-to-buy-results-wrapper {
    display: grid;
    grid-template-columns: 337px 1fr;
    gap: 3rem;
    position: relative;
}

.where-to-buy-results-content {
    grid-column: 2;
    margin-top: 3rem;
    margin-right: 0;
    margin-bottom: 3rem;
}

/* ==========================================
   Product Type Sidebar - Desktop
   ========================================== */

.wtb-product-sidebar {
    background: #EFEFEF;
    min-height: 500px;
    position: relative;
}

/* Extend sidebar background to left edge of viewport */
.wtb-product-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 100%;
    width: 100vw;
    background: #EFEFEF;
}

/* Mobile Filters Header - hidden on desktop */
.wtb-filters-header {
    display: none;
}

.wtb-sidebar-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: #373a36;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
}

.wtb-sidebar-item.active .wtb-sidebar-button {
    background: #DFDFE0;
}

/* Desktop: chevron icon */
.wtb-sidebar-icon {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* Desktop: hide mobile toggle icons */
.wtb-sidebar-toggle-icon {
    display: none;
}

/* Desktop: filters content always visible */
.wtb-filters-content {
    display: block;
}

/* Desktop Facet Panels */
.wtb-sidebar-panel {
    display: none;
}

.wtb-sidebar-facets {
    padding: 1rem 1.25rem;
    background: #fff;
}

.wtb-sidebar-facet {
    margin-bottom: 0.75rem;
}

/* Desktop Facets (above results) */
.where-to-buy-facets-desktop {
    grid-column: 2;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: flex-start;
}

.where-to-buy-facets-desktop .facet-label {
    display: none;
}

.wtb-facet-item {
    flex: 0 0 auto;
}

/* Remove margin from brand/role filters in desktop area */
.where-to-buy-facets-desktop .wtb-brand-filter,
.where-to-buy-facets-desktop .wtb-role-filter {
    margin-bottom: 0;
}

/* ==========================================
   Product Type Sidebar - Mobile Accordion
   ========================================== */

@media (max-width: 1024px) {
    .wtb-product-sidebar {
        min-height: auto;
        background: transparent;
    }
    
    /* Hide the left bleed on mobile */
    .wtb-product-sidebar::before {
        display: none;
    }
    
    /* Mobile Filters Header */
    .wtb-filters-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        cursor: pointer;
        border: none;
        border-radius: 0;
        width: 100%;
        font-size: 1.125rem;
        font-weight: 600;
        background: var(--global-palette9);
        border-bottom: 1px solid var(--global-palette7);
    }

    .wtb-filters-header[aria-expanded="true"] {
        background: var(--global-palette-btn-bg);
        color: var(--global-palette-btn);
    }

    .wtb-filters-header[aria-expanded="false"] {
        background: var(--global-palette9);
        color: var(--global-palette3);
    }
    .wtb-filters-header-content {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    
    .wtb-filters-header svg {
        transition: transform 0.3s ease;
    }
    
    /* Chevron points down when closed, up when open */
    .wtb-filters-header[aria-expanded="true"] svg.wtb-filters-chevron {
        transform: rotate(180deg);
    }
    
    /* Collapsible filters container */
    .wtb-filters-content {
        display: none;
        background: #fff;
    }
    
    .wtb-filters-content.is-open {
        display: block;
    }
    
    /* Product type accordion items */
    .wtb-sidebar-button {
        padding: .5rem 1.25rem;
        background: #F4F4F5;
    }
    
    .wtb-sidebar-item.active .wtb-sidebar-button {
        background:  #F4F4F5;
    }
    
    /* Replace chevron with +/- icons on mobile */
    .wtb-sidebar-icon {
        display: none;
    }
    
    .wtb-sidebar-toggle-icon {
        display: flex;
        width: 20px;
        height: 20px;
        align-items: center;
        justify-content: center;
    }
    
    .wtb-sidebar-toggle-icon svg {
        width: 16px;
        height: 16px;
    }
    
    /* Show minus when expanded, plus when collapsed */
    .wtb-sidebar-item .wtb-icon-plus {
        display: block;
    }
    
    .wtb-sidebar-item .wtb-icon-minus {
        display: none;
    }
    
    .wtb-sidebar-item.active .wtb-icon-plus {
        display: none;
    }
    
    .wtb-sidebar-item.active .wtb-icon-minus {
        display: block;
    }
    
    /* Facet panel styling */
    .wtb-sidebar-panel {
        background: #F4F4F5;
        padding: 0 1.25rem 1rem;
    }
    
    .wtb-sidebar-item.active .wtb-sidebar-panel:not([hidden]) {
        display: block;
    }
    
    .wtb-sidebar-facets {
        padding: 0;
        background: transparent;
        flex-direction: column;
    }
    .wtb-sidebar-facet {
      margin-bottom: 0;
    }
    .facetwp-facet-brand {
      margin-bottom: 0 !important;
    }
}

@media (min-width: 768px) {
   .wtb-facet-item .facetwp-facet-roles,
   .wtb-facet-item .facetwp-facet-brand {
           display: flex;
           flex-direction: row;
           gap: 1rem;
       }
   }

   .wtb-sidebar-facet .facet-wrap.roles label,
   .wtb-sidebar-facet .facet-wrap.brand label,
   .wtb-facet-item .facet-wrap.roles label,
   .wtb-facet-item .facet-wrap.brand label {
       display: none;
   }

/* ==========================================
   Custom Brand Filter (URL-based)
   ========================================== */

.wtb-brand-filter {
    margin-bottom: 1rem;
}

.wtb-brand-filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.wtb-brand-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--global-palette4);
    transition: color 0.2s ease;
}

.wtb-brand-checkbox:hover {
    color: var(--global-palette1);
}

.wtb-brand-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--global-palette1);
}

.wtb-brand-checkbox.checked .wtb-brand-checkbox-label {
    color: var(--global-palette1);
    font-weight: 500;
}

/* Hide FacetWP brand facet when custom filter is present */
.wtb-brand-filter ~ .facetwp-facet-brand,
.wtb-brand-filter + .facetwp-facet-brand {
    display: none !important;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .wtb-brand-filter-checkboxes {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ==========================================
   Custom Role Filter (matches Brand Filter styling)
   ========================================== */

.wtb-role-filter {
    margin-bottom: 1rem;
}

.wtb-role-filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.wtb-role-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--global-palette4);
    transition: color 0.2s ease;
}

.wtb-role-checkbox:hover {
    color: var(--global-palette1);
}

.wtb-role-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--global-palette1);
}

.wtb-role-checkbox.checked .wtb-role-checkbox-label {
    color: var(--global-palette1);
    font-weight: 500;
}

/* Hide FacetWP roles facet when custom filter is present */
.wtb-role-filter ~ .facetwp-facet-roles,
.wtb-role-filter + .facetwp-facet-roles {
    display: none !important;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .wtb-role-filter-checkboxes {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ==========================================
   Combined Brand + Role Filters Layout
   ========================================== */

.wtb-sidebar-facets {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    align-items: flex-start;
}

.wtb-sidebar-facet {
    flex: 0 0 auto;
}

/* Make brand and role checkboxes inline */
.wtb-sidebar-facets .wtb-brand-filter,
.wtb-sidebar-facets .wtb-role-filter {
    margin-bottom: 0;
}

/* ==========================================
   Result Cards
   ========================================== */

.where-to-buy-result-card {
    display: grid;
    grid-template-columns: 1fr 5fr;
    gap: 30px;
    padding: 20px;
    border: 1px solid var(--global-palette7);
    border-radius: 10px;
    margin-bottom: 20px;
}

.where-to-buy-result-card.no-featured-image {
    grid-template-columns: 1fr;
}

/* Card Image */
.where-to-buy-image.wp-block-kadence-image:not(:last-child) {
    margin-bottom: 0;
}

.where-to-buy-image .kb-is-ratio-image img {
    object-fit: contain;
    object-position: left;
}

/* Card Title */
h3.where-to-buy-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 10px auto;
}

/* Card Info Grid */
.where-to-buy-card-info {
    display: grid;
    grid-template-columns: 1fr 1fr 170px;
    gap: 20px;
}

.where-to-buy-card-info-fields { order: 1; }
.where-to-buy-other-locations { order: 2; }
.where-to-buy-card-info-terms { order: 3; }
.where-to-buy-card-info-actions { order: 4; }

/* Contact Info Links */
.where-to-buy-card-info-dealer-directions a,
.where-to-buy-card-info-dealer-phone a,
.where-to-buy-contact-email,
.where-to-buy-card-info-contact-phone {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    min-width: 125px;
}

.where-to-buy-card-info-dealer-phone-and-directions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    text-transform: uppercase;
}

.where-to-buy-card-info-dealer-phone-and-directions > *:not(:last-child) {
    border-right: 1px solid var(--global-palette7);
    padding-right: 10px;
}

.where-to-buy-card-info-dealer-address {
    margin-bottom: 0;
    font-style: normal;
}

/* Product Types & Brands */
.where-to-buy-card-info-product-type {
    margin-bottom: 5px;
}

.where-to-buy-label {
    font-weight: 600;
}

/* Action Buttons */
.where-to-buy-card-info-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.where-to-buy-card-info-actions .kb-button {
    width: 100%;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.where-to-buy-card-contact-sales.kb-button {
    padding: 16px 20px;
    border-color: var(--global-palette-btn-sec);
    color: var(--global-palette-btn-sec);
}

.where-to-buy-card-contact-sales.kb-button:hover,
.where-to-buy-card-contact-sales.kb-button:focus {
    background-color: var(--global-palette-btn-sec);
    color: var(--global-palette-btn-hover);
}

/* ==========================================
   Other Locations Accordion
   ========================================== */

.where-to-buy-other-locations {
    margin-top: 20px;
    grid-column: 1 / -1;
    border-top: 1px solid var(--global-palette7);
    padding-top: 20px;
}

.where-to-buy-other-locations-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 1.125rem;
    text-transform: capitalize;
    font-weight: 600;
    color: var(--global-palette3);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.where-to-buy-other-locations-toggle:hover,
.where-to-buy-other-locations-toggle:focus {
    color: var(--global-palette3);
    background-color: transparent;
}

.where-to-buy-other-locations-toggle svg {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 10px;
}

.where-to-buy-other-locations-toggle.active svg {
    transform: rotate(180deg);
}

.where-to-buy-other-locations-content {
    display: none;
    padding: 20px 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 30px 15px;
}

.where-to-buy-other-locations-content.open {
    display: flex;
}

.where-to-buy-other-location-item {
    display: flex;
    flex-direction: column;
    width: 190px;
}

/* ==========================================
   Contact Sales Modal
   ========================================== */

.wtb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wtb-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.wtb-modal-content {
    position: relative;
    background: white;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.wtb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--global-palette7);
}

.wtb-modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.wtb-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--global-palette3);
    transition: color 0.2s;
}

.wtb-modal-close:hover {
    color: var(--global-palette1);
}

.wtb-modal-body {
    padding: 30px;
}

/* ==========================================
   Responsive - Tablet & Mobile
   ========================================== */

@media (max-width: 1024px) {
    .where-to-buy-results-wrapper {
      display: block;
        grid-template-columns: 1fr;
    }
    
    .where-to-buy-facets-desktop {
        display: none;
    }
    
    .where-to-buy-results-content {
        margin-top: 1.5rem;
        grid-column: 1;
        margin-left: 1.5rem;
        margin-right: 1.5rem;
    }
    
    .where-to-buy-other-locations-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
   .where-to-buy-result-card {
      grid-template-columns: 1fr;
   }
    .where-to-buy-card-info {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .where-to-buy-image,
    .where-to-buy-image .kb-is-ratio-image img {
      max-height: 150px;
    }
    
    .where-to-buy-other-locations {
        grid-column: 1;
    }

    .where-to-buy-other-locations-content {
        grid-template-columns: 1fr;
        gap: 25px;
    }
}

/* ==========================================
   AJAX Loading State
   ========================================== */

.facetwp-template.wtb-loading {
    position: relative;
    pointer-events: none;
    min-height: 200px;
}

.facetwp-template.wtb-loading > *:not(.wtb-loading-overlay) {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.wtb-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 100;
}

.wtb-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #E5E5E5;
    border-top-color: #0057A5;
    border-radius: 50%;
    animation: wtb-spin 0.8s linear infinite;
}

@keyframes wtb-spin {
    to {
        transform: rotate(360deg);
    }
}

.wtb-error-message {
    text-align: center;
    padding: 2rem;
    background: #FFF5F5;
    border: 1px solid #FED7D7;
    border-radius: 4px;
    color: #C53030;
}

/* ==========================================
   Mobile Filter Actions (Submit & Reset)
   ========================================== */

.wtb-mobile-filter-actions {
    display: none; /* Hidden on desktop */
    flex-direction: column;
    gap: 1rem;
    background: #F4F4F5;
    padding: 0 1rem 1rem;
}

.wtb-submit-filters {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    cursor: pointer;
}

.wtb-reset-filters {
    background: none;
    border: none;
    color: #0057A5;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: underline;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 0.5rem;
    text-align: center;
}

.wtb-reset-filters:hover {
    color: #003d73;
    background-color: transparent;
}

/* Show on mobile */
@media (max-width: 1024px) {
    .wtb-mobile-filter-actions {
        display: flex;
    }
}

/* ==========================================
   Where to Buy Finder Block
   ========================================== */

.where-to-buy-finder-block {
    max-width: 600px;
}

.where-to-buy-finder-block .wtb-filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.where-to-buy-finder-block .wtb-region-filter {
    width: 100%;
}

.where-to-buy-finder-block .wtb-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.where-to-buy-finder-block .wtb-submit {
    flex-shrink: 0;
}

.where-to-buy-finder-block .fwp-submit {
    background: #0057A5;
    color: #fff;
    border: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease;
}

.where-to-buy-finder-block .fwp-submit:hover:not(:disabled) {
    background: #003d73;
}

.where-to-buy-finder-block .fwp-submit:disabled {
    background: #ccc;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}

/* FacetWP Reset facet styling */
.where-to-buy-finder-block .wtb-reset .facetwp-facet-reset {
    display: inline-block;
}

.where-to-buy-finder-block .wtb-reset .facetwp-reset {
    background: none;
    border: none;
    color: #0057A5;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
}

.where-to-buy-finder-block .wtb-reset .facetwp-reset:hover {
    color: #003d73;
}




.wtb-sidebar-icon {
    transform: rotate(270deg);
}

.wtb-sidebar-button {
    font-size: 24px;
}