/**
 * TurnKey Directories - Search Page Mobile Optimization
 * Optimized for modern mobile devices (320px - 768px)
 * 
 * UPDATED: Location dropdown mobile fix - Full screen with close button
 * Version: 2025-01-XX - Cache bust
 */

/* ============================================
   HERO SECTION MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    .tkd-hero-section {
        padding: 24px 0 !important;
        min-height: auto !important;
    }
    
    .tkd-hero-content {
        padding: 0 16px !important;
        max-width: 100% !important;
    }
    
    .tkd-hero-title {
        font-size: 24px !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
        text-align: center !important;
        padding: 0 !important;
    }
    
    .tkd-hero-subtitle {
        font-size: 14px !important;
        line-height: 1.5 !important;
        margin-bottom: 20px !important;
        text-align: center !important;
        padding: 0 !important;
    }
}

/* ============================================
   SEARCH WIDGET MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    .tkd-search-widget {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .tkd-search-form {
        border-radius: 16px !important;
        padding: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        margin: 0 16px !important;
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
        box-sizing: border-box !important;
        flex-direction: column !important;
    }
    
    /* CRITICAL FIX: Force border-box on all search form children */
    .tkd-search-form *,
    .tkd-search-form *::before,
    .tkd-search-form *::after {
        box-sizing: border-box !important;
    }
    
    .tkd-search-inputs {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        min-height: auto !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ============================================
   SEARCH FIELDS MOBILE LAYOUT
   ============================================ */

@media (max-width: 768px) {
    .tkd-search-field {
        width: 100% !important;
        min-height: 56px !important;
        padding: 12px 16px !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
        border: none !important;
        background: #f7f7f7 !important;
        transition: background 0.2s ease !important;
    }
    
    .tkd-search-field:hover {
        background: #eeeeee !important;
    }
    
    .tkd-search-field:focus-within {
        background: #ffffff !important;
        box-shadow: 0 0 0 2px rgba(129, 215, 66, 0.3) !important;
    }
    
    /* Remove separators on mobile */
    .tkd-search-field::after {
        display: none !important;
    }
    
    .tkd-search-field:not(:last-child)::after {
        display: none !important;
    }
    
    /* Individual field styling */
    .tkd-field-business,
    .tkd-field-filters,
    .tkd-field-location {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        border-right: none !important;
        border-bottom: none !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        position: relative !important;
        flex: 0 0 auto !important;
    }
    
    .tkd-field-location {
        margin-bottom: 16px !important;
    }
    
    /* Ensure search field container is properly aligned */
    .tkd-search-field {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* ============================================
   SEARCH INPUTS OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    .tkd-search-field input {
        font-size: 16px !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        width: 100% !important;
        max-width: 100% !important;
        color: #222222 !important;
        box-sizing: border-box !important;
        flex: 1 1 auto !important;
    }
    
    .tkd-search-field input::placeholder {
        color: #717171 !important;
        font-size: 15px !important;
    }
    
    .tkd-search-field input:focus {
        outline: none !important;
    }
    
    /* Labels on mobile */
    .tkd-search-field label {
        font-size: 11px !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        color: #222222 !important;
        margin-bottom: 4px !important;
        display: block !important;
    }
}

/* ============================================
   FILTERS SELECTOR MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* CRITICAL: Override ALL desktop styles for selectors on mobile */
    .tkd-filters-selector,
    .tkd-location-selector {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        cursor: pointer !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        box-sizing: border-box !important;
        position: relative !important;
        overflow: visible !important;
        flex: 1 1 auto !important;
    }
    
    .tkd-filters-text,
    .tkd-location-text {
        font-size: 15px !important;
        color: #222222 !important;
        flex: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .tkd-filters-selector i,
    .tkd-location-selector i {
        font-size: 12px !important;
        color: #717171 !important;
        margin-left: 8px !important;
        flex-shrink: 0 !important;
        display: inline-block !important;
    }
}

/* ============================================
   SEARCH SUBMIT BUTTON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-search-submit {
        width: 100% !important;
        height: 56px !important;
        border-radius: 12px !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        background: var(--tkd-primary, #81d742) !important;
        border: none !important;
        color: white !important;
        cursor: pointer !important;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
        -webkit-tap-highlight-color: transparent !important;
        box-shadow: 0 2px 8px rgba(129, 215, 66, 0.25) !important;
    }
    
    .tkd-search-submit:hover {
        box-shadow: 0 4px 12px rgba(129, 215, 66, 0.35) !important;
        transform: translateY(-1px) !important;
    }
    
    .tkd-search-submit:active {
        transform: scale(0.98) !important;
        background: var(--tkd-primary-dark, #70c033) !important;
        box-shadow: 0 1px 4px rgba(129, 215, 66, 0.2) !important;
    }
}

/* ============================================
   RESET SEARCH BUTTON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-reset-search {
        position: absolute !important;
        right: 60px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 28px !important;
        height: 28px !important;
        border-radius: 8px !important;
        background: rgba(0, 0, 0, 0.05) !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        color: #666 !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
        opacity: 0.8 !important;
        box-shadow: none !important;
        outline: none !important;
    }
    
    .tkd-reset-search:hover {
        background: rgba(0, 0, 0, 0.09) !important;
        color: #333 !important;
        opacity: 1 !important;
        transform: translateY(-50%) scale(1.05) !important;
        box-shadow: none !important;
    }
    
    .tkd-reset-search:active {
        background: rgba(0, 0, 0, 0.12) !important;
        transform: translateY(-50%) scale(0.95) !important;
        box-shadow: none !important;
    }
    
    .tkd-reset-search:focus {
        outline: none !important;
        box-shadow: none !important;
    }
}

/* ============================================
   DROPDOWNS MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    /* Filters dropdown - FULL SCREEN like location dropdown */
    .tkd-filters-dropdown {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 99999 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-direction: column !important;
    }
    
    /* Location dropdown - FULL SCREEN */
    .tkd-location-dropdown {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 99999 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-direction: column !important;
    }
    
    /* CRITICAL: Prevent any child from causing horizontal overflow */
    .tkd-filters-dropdown *,
    .tkd-location-dropdown * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .tkd-filters-dropdown.active {
        display: flex !important;
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .tkd-location-dropdown.active {
        display: flex !important;
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* CRITICAL: When filters dropdown is active, force content to be visible and sized */
    /* MUST override all grid display rules - highest specificity */
    .tkd-filters-dropdown.active .tkd-filters-content,
    .tkd-filters-dropdown.active .tkd-filters-content[style],
    .tkd-filters-dropdown.active .tkd-filters-content[style*="grid"] {
        /* CRITICAL: Override grid - MUST come first */
        display: flex !important;
        flex-direction: column !important;
        grid: none !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        grid-column: auto !important;
        grid-row: auto !important;
        
        /* Layout properties */
        visibility: visible !important;
        opacity: 1 !important;
        min-height: 300px !important;
        height: auto !important;
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 20px !important;
        max-height: calc(100vh - 180px) !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        gap: 20px !important;
    }
    
    /* CRITICAL: When location dropdown is active, force content to be visible and sized */
    .tkd-location-dropdown.active .tkd-location-content {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-height: 300px !important;
        height: auto !important;
        flex: 1 1 auto !important;
    }
    
    .tkd-location-dropdown.active .tkd-filter-content.active {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-height: 200px !important;
        height: auto !important;
    }
    
    /* Remove handle for both dropdowns - full screen doesn't need handle */
    .tkd-filters-dropdown::before,
    .tkd-location-dropdown::before {
        display: none !important;
    }
    
    /* Filters and Location dropdown headers - show close button */
    .tkd-filters-dropdown .tkd-dropdown-header,
    .tkd-location-dropdown .tkd-dropdown-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 16px !important;
        border-bottom: 1px solid #f0f0f0 !important;
        background: white !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        z-index: 10 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .tkd-filters-dropdown .tkd-dropdown-title,
    .tkd-location-dropdown .tkd-dropdown-title {
        font-size: 16px !important;
        font-weight: 600 !important;
        color: #222 !important;
        margin: 0 !important;
    }
    
    .tkd-filters-dropdown .tkd-dropdown-close,
    .tkd-location-dropdown .tkd-dropdown-close {
        width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        border-radius: 50% !important;
        border: none !important;
        background: #f5f5f5 !important;
        color: #666 !important;
        font-size: 14px !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
    }
    
    .tkd-filters-dropdown .tkd-dropdown-close:active,
    .tkd-location-dropdown .tkd-dropdown-close:active {
        background: #e8e8e8 !important;
        transform: scale(0.95) !important;
    }
}

/* ============================================
   FILTER CONTENT MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Base filters content - but will be overridden when active */
    .tkd-filters-content {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        overflow-y: auto !important;
        max-height: calc(70vh - 120px) !important;
        padding: 0 20px 20px !important;
    }
    
    /* CRITICAL: When active, MUST use flex, not grid */
    .tkd-filters-dropdown.active .tkd-filters-content {
        display: flex !important;
        flex-direction: column !important;
        grid: none !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }
    
    /* CRITICAL FIX: Ensure filter content sections are visible when active on mobile */
    .tkd-location-dropdown .tkd-filter-content {
        display: none !important;
        width: 100% !important;
        min-height: 100px !important;
        visibility: hidden !important;
        opacity: 0 !important;
        padding: 12px 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: none !important;
        height: auto !important;
        box-sizing: border-box !important;
        position: relative !important;
    }
    
    .tkd-location-dropdown .tkd-filter-content.active {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
        min-height: 100px !important;
    }
    
    .tkd-filter-tabs {
        display: flex !important;
        overflow-x: auto !important;
        gap: 8px !important;
        padding: 0 20px 16px !important;
        border-bottom: 1px solid #eeeeee !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    
    .tkd-filter-tabs::-webkit-scrollbar {
        display: none !important;
    }
    
    .tkd-filter-tab {
        padding: 10px 16px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
        border-radius: 20px !important;
        background: #f7f7f7 !important;
        border: none !important;
        color: #666666 !important;
        font-weight: 500 !important;
        transition: all 0.2s ease !important;
    }
    
    .tkd-filter-tab.active {
        background: #222222 !important;
        color: white !important;
    }
    
    .tkd-filter-tab i {
        font-size: 14px !important;
        margin-right: 6px !important;
    }
    
    .tkd-filter-tab span {
        display: inline !important;
    }
}

/* ============================================
   LOCATION DROPDOWN MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Hide location search on mobile */
    .tkd-location-dropdown .tkd-location-search {
        display: none !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    
    /* Location filter tabs - horizontal scrollable - MUST FIT WIDTH */
    .tkd-location-dropdown .tkd-location-filters {
        display: flex !important;
        gap: 6px !important;
        padding: 8px 16px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        background: white !important;
        scrollbar-width: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    
    .tkd-location-dropdown .tkd-location-filters::-webkit-scrollbar {
        display: none !important;
    }
    
    .tkd-location-dropdown .tkd-filter-tab {
        padding: 8px 14px !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        border-radius: 18px !important;
        border: none !important;
        background: #f0f0f0 !important;
        color: #666 !important;
        white-space: nowrap !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        min-height: 36px !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
        flex-shrink: 0 !important;
    }
    
    .tkd-location-dropdown .tkd-filter-tab.active {
        background: var(--tkd-primary, #81d742) !important;
        color: white !important;
    }
    
    /* Location content - scrollable area */
    .tkd-location-dropdown .tkd-location-content {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        min-height: 300px !important;
        height: auto !important;
        max-height: calc(100vh - 180px) !important;
        background: white !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* CRITICAL: When dropdown is active, ensure location-content has proper height */
    .tkd-location-dropdown.active .tkd-location-content {
        min-height: 300px !important;
        height: auto !important;
        flex: 1 1 auto !important;
    }
    
    /* CRITICAL FIX: Ensure filter content sections display properly when active */
    .tkd-location-dropdown .tkd-filter-content {
        display: none !important;
        width: 100% !important;
        min-height: 200px !important;
        visibility: hidden !important;
        opacity: 0 !important;
        padding: 16px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 200px) !important;
        height: auto !important;
        box-sizing: border-box !important;
        position: relative !important;
    }
    
    .tkd-location-dropdown .tkd-filter-content.active {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 200px !important;
        max-height: calc(100vh - 200px) !important;
        padding: 16px !important;
    }
    
    /* CRITICAL: Ensure content inside filter-content is visible */
    .tkd-location-dropdown .tkd-filter-content.active * {
        visibility: visible !important;
    }
    
    .tkd-location-dropdown .tkd-filter-content.active .tkd-near-me-option,
    .tkd-location-dropdown .tkd-filter-content.active .tkd-location-grid,
    .tkd-location-dropdown .tkd-filter-content.active .tkd-location-item {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .tkd-location-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }
    
    .tkd-location-item {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 12px 14px !important;
        border-radius: 8px !important;
        border: 1px solid #e8e8e8 !important;
        background: white !important;
        cursor: pointer !important;
        transition: all 0.15s ease !important;
        min-height: 44px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .tkd-location-item:active {
        background: #f5f5f5 !important;
    }
    
    .tkd-location-item.selected {
        background: var(--tkd-primary, #81d742) !important;
        border-color: var(--tkd-primary, #81d742) !important;
        color: white !important;
    }
    
    /* Location footer actions - fixed at bottom - MUST FIT */
    .tkd-location-dropdown .tkd-location-actions {
        position: relative !important;
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        padding: 12px 16px !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
        border-top: 1px solid #f0f0f0 !important;
        display: flex !important;
        gap: 10px !important;
        flex-shrink: 0 !important;
        flex: 0 0 auto !important;
        z-index: 100 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .tkd-location-dropdown .tkd-location-clear,
    .tkd-location-dropdown .tkd-location-apply {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        max-width: 50% !important;
        padding: 12px 8px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        border: none !important;
        cursor: pointer !important;
        min-height: 44px !important;
        transition: all 0.15s ease !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        width: auto !important;
    }
    
    .tkd-location-dropdown .tkd-location-clear {
        background: #f5f5f5 !important;
        color: #333 !important;
    }
    
    .tkd-location-dropdown .tkd-location-clear:active {
        background: #e8e8e8 !important;
    }
    
    .tkd-location-dropdown .tkd-location-apply {
        background: var(--tkd-primary, #81d742) !important;
        color: white !important;
    }
    
    .tkd-location-dropdown .tkd-location-apply:active {
        opacity: 0.9 !important;
    }
}

/* ============================================
   CHECKBOX OPTIONS MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-checkbox-option {
        width: 100% !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        background: #f7f7f7 !important;
        border: 2px solid transparent !important;
        transition: all 0.2s ease !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    .tkd-checkbox-option input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
        border-radius: 4px !important;
        border: 2px solid #dddddd !important;
        margin: 0 !important;
    }
    
    .tkd-checkbox-option input[type="checkbox"]:checked {
        background: var(--tkd-primary, #81d742) !important;
        border-color: var(--tkd-primary, #81d742) !important;
    }
    
    .tkd-checkbox-option label {
        flex: 1 !important;
        margin: 0 !important;
        font-size: 15px !important;
        color: #222222 !important;
        cursor: pointer !important;
    }
}

/* ============================================
   RATING SELECTOR MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-quick-filters,
    .tkd-rating-selector,
    .tkd-distance-service,
    .tkd-sort-reviews {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .tkd-rating-option,
    .tkd-distance-option,
    .tkd-sort-option {
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        background: #f7f7f7 !important;
        border: 2px solid transparent !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        transition: all 0.2s ease !important;
        cursor: pointer !important;
    }
    
    .tkd-rating-option:active,
    .tkd-distance-option:active,
    .tkd-sort-option:active {
        background: #eeeeee !important;
        transform: scale(0.98) !important;
    }
    
    .tkd-rating-option.active,
    .tkd-distance-option.active,
    .tkd-sort-option.active {
        background: #e8f5e9 !important;
        border-color: var(--tkd-primary, #81d742) !important;
        color: #2e7d32 !important;
        font-weight: 600 !important;
    }
}

/* ============================================
   FILTER CHIPS MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-filter-pills {
        padding: 10px 12px !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .tkd-filter-pills::-webkit-scrollbar {
        display: none !important;
    }
    
    .tkd-filter-pill {
        padding: 6px 10px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
        border-radius: 16px !important;
        min-height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
    }
}

/* Extra small screens - make pills even more compact */
@media (max-width: 480px) {
    .tkd-filter-pills {
        padding: 8px 10px !important;
        gap: 5px !important;
    }
    
    .tkd-filter-pill {
        padding: 5px 8px !important;
        font-size: 10px !important;
        border-radius: 14px !important;
        min-height: 28px !important;
    }
}

/* ============================================
   RESULTS SECTION MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-main-content {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .tkd-content-wrapper {
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    .tkd-results-header {
        padding: 20px 16px !important;
        text-align: center !important;
    }
    
    .tkd-results-count h2 {
        font-size: 20px !important;
        margin-bottom: 4px !important;
    }
    
    .tkd-results-count p {
        font-size: 14px !important;
        color: #666666 !important;
    }
}

/* ============================================
   ZILLOW LAYOUT MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-zillow-layout {
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
        margin-top: 0 !important;
        border-radius: 0 !important;
    }
    
    /* HIDE MAP ON MOBILE - eliminates the grey gap */
    .tkd-map-panel {
        display: none !important;
    }
    
    .tkd-results-panel {
        min-width: 100% !important;
        border-left: none !important;
        border-bottom: none !important;
        max-height: none !important;
    }
    
    .tkd-map-container {
        display: none !important;
    }
}

/* ============================================
   LISTINGS GRID MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-listings-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 16px !important;
    }
    
    /* V71: NO shadow on outer wrapper - shadow ONLY on inner .glass-card-top */
    .tkd-listing-card {
        border-radius: 0 !important;
        overflow: visible !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    
    /* V71: Shadow on inner element which has border-radius */
    .tkd-listing-card .glass-card-top {
        border-radius: 16px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
    }
    
    .tkd-card-image {
        height: 180px !important;
    }
    
    .tkd-card-header {
        padding: 14px 14px 0 !important;
    }
    
    .tkd-business-name {
        font-size: 17px !important;
        line-height: 1.3 !important;
    }
    
    .tkd-card-body {
        padding: 8px 14px !important;
    }
    
    .tkd-card-footer {
        padding: 10px 14px 14px !important;
    }
    
    .tkd-view-details {
        padding: 12px 16px !important;
        font-size: 14px !important;
    }
}

/* ============================================
   STICKY SEARCH ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .tkd-search-widget.tkd-sticky-search {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        background: white !important;
        padding: 12px 0 !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
        animation: slideDown 0.3s ease-out !important;
    }
    
    @keyframes slideDown {
        from {
            transform: translateY(-100%) !important;
        }
        to {
            transform: translateY(0) !important;
        }
    }
    
    .tkd-sticky-search .tkd-search-form {
        margin: 0 12px !important;
        padding: 8px 12px !important;
        border-radius: 100px !important;
    }
    
    .tkd-sticky-search .tkd-search-inputs {
        flex-direction: row !important;
        gap: 4px !important;
        align-items: center !important;
    }
    
    .tkd-sticky-search .tkd-search-field {
        margin-bottom: 0 !important;
        padding: 6px 10px !important;
        min-height: auto !important;
        background: transparent !important;
    }
    
    .tkd-sticky-search .tkd-field-business {
        flex: 1 !important;
        position: relative !important;
        overflow: visible !important;
        min-width: 0 !important;
    }
    
    /* Hide location in sticky mode */
    .tkd-sticky-search .tkd-field-location {
        display: none !important;
    }
    
    /* Show filters as compact chip in sticky mode */
    .tkd-sticky-search .tkd-field-filters {
        display: flex !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        margin: 0 4px !important;
        background: transparent !important;
        border: none !important;
        min-height: auto !important;
        width: auto !important;
        max-width: 120px !important;
    }
    
    .tkd-sticky-search .tkd-filters-selector {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        background: #f0f0f0 !important;
        border-radius: 16px !important;
        padding: 4px 10px !important;
        font-size: 11px !important;
        font-weight: 500 !important;
        color: #333 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        cursor: pointer !important;
        border: none !important;
    }
    
    .tkd-sticky-search .tkd-filters-text {
        font-size: 11px !important;
        max-width: 70px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .tkd-sticky-search .tkd-filters-selector i {
        font-size: 10px !important;
        color: #666 !important;
        margin: 0 !important;
    }
    
    /* Hide the sliders icon, show as dropdown arrow or remove */
    .tkd-sticky-search .tkd-filters-selector i.fa-sliders-h {
        display: none !important;
    }
    
    /* Hide the filters dropdown in sticky mode */
    .tkd-sticky-search .tkd-filters-dropdown {
        display: none !important;
    }
    
    /* Reset/Clear X button - larger and more visible */
    .tkd-sticky-search .tkd-reset-search {
        all: unset !important;
        position: absolute !important;
        right: 4px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        /* Larger size for better touch target */
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        min-height: 26px !important;
        max-width: 26px !important;
        max-height: 26px !important;
        padding: 0 !important;
        margin: 0 !important;
        /* Red/pink circle like desktop */
        border-radius: 50% !important;
        background: #ff6b6b !important;
        border: none !important;
        color: white !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        z-index: 10 !important;
        box-shadow: none !important;
        outline: none !important;
        box-sizing: border-box !important;
    }
    
    .tkd-sticky-search .tkd-reset-search i {
        font-size: 11px !important;
        line-height: 1 !important;
        color: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .tkd-sticky-search .tkd-reset-search:active {
        background: #e55555 !important;
        transform: translateY(-50%) scale(0.95) !important;
    }
    
    /* Input padding to make room for the X button */
    .tkd-sticky-search .tkd-field-business input {
        padding-right: 32px !important;
    }
    
    .tkd-sticky-search .tkd-search-submit {
        width: 40px !important;
        height: 40px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        font-size: 16px !important;
    }
    
    .tkd-sticky-search .tkd-search-submit span {
        display: none !important;
    }
}

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    /* Increase touch targets */
    body.tkd-active button,
    body.tkd-active a,
    body.tkd-active input,
    body.tkd-active select,
    .tkd-filter-pill,
    .tkd-location-option,
    .tkd-checkbox-option {
        min-height: 44px !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Smooth scrolling */
    .tkd-filters-content,
    .tkd-location-content,
    .tkd-filter-pills,
    .tkd-filter-tabs {
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Prevent zoom on input focus */
    body.tkd-active input,
    body.tkd-active select,
    body.tkd-active textarea {
        font-size: 16px !important;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Focus states for keyboard navigation */
    button:focus,
    a:focus,
    input:focus,
    select:focus {
        outline: 2px solid var(--tkd-primary, #81d742) !important;
        outline-offset: 2px !important;
    }
    
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .tkd-search-field,
        .tkd-filter-pill,
        .tkd-location-option,
        .tkd-checkbox-option {
            border: 2px solid #000000 !important;
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ============================================
   SMALL MOBILE DEVICES (≤480px)
   ============================================ */

@media (max-width: 480px) {
    .tkd-hero-title {
        font-size: 22px !important;
    }
    
    .tkd-hero-subtitle {
        font-size: 13px !important;
    }
    
    .tkd-search-form {
        padding: 12px !important;
        margin: 0 12px !important;
    }
    
    .tkd-search-field {
        min-height: 52px !important;
        padding: 10px 14px !important;
    }
    
    .tkd-search-submit {
        height: 52px !important;
    }
    
    .tkd-listings-grid {
        padding: 12px !important;
        gap: 12px !important;
    }
    
    .tkd-card-image {
        height: 160px !important;
    }
}

/* ============================================
   VERY SMALL DEVICES (≤375px)
   ============================================ */

@media (max-width: 375px) {
    .tkd-hero-title {
        font-size: 20px !important;
    }
    
    .tkd-search-form {
        margin: 0 8px !important;
        padding: 10px !important;
    }
    
    .tkd-filter-pill {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
}

/* ============================================
   v2.15.16 — FILTER DROPDOWN FULL-SCREEN MOBILE MODAL
   ============================================
   The .tkd-filters-dropdown is supposed to render as a full-screen
   modal on mobile (per the earlier rules in this file at lines 326-499)
   but real-world rendering on test-wp.shop / Kadence theme shows the
   panel partially overlaying the page with chip content clipped on
   the right edge. Root cause is some combination of:
     - The base desktop rule (position: absolute; top:100%; transform:
       translateX(-50%)) leaking through on mobile.
     - LiteSpeed CSS optimization reordering rules so cascade falls to
       "later wins" — and the desktop-positioning rules can come later
       than the mobile override after minification.
     - The JS-applied setProperty('position','fixed','important') being
       reverted by some other code path mid-frame.

   Fix: max-specificity selectors + !important on every dimensional /
   positioning property so no plausible competing rule can outrank.
   Mobile-only via @media (max-width: 768px). Same treatment for the
   location dropdown which shares the architecture.

   Reference: previous version (v2.0.6) rendered this UI correctly out
   of the box; the user wants that experience restored on mobile. */
@media (max-width: 768px) {

    /* Force the dropdown to a clean full-screen modal whenever .active. */
    html body .tkd-filters-dropdown.active,
    html body .tkd-location-dropdown.active {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
        z-index: 999999 !important;
        background: #ffffff !important;
        display: flex !important;
        flex-direction: column !important;
        border-radius: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Header (title + close button) pinned at top */
    html body .tkd-filters-dropdown.active .tkd-dropdown-header,
    html body .tkd-location-dropdown.active .tkd-dropdown-header {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 14px 16px !important;
        margin: 0 !important;
        border-bottom: 1px solid #e5e7eb !important;
        background: #ffffff !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Scrollable content area fills remaining height */
    html body .tkd-filters-dropdown.active .tkd-filters-content {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 16px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 18px !important;
        grid: none !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }

    /* Actions bar (Clear All / Apply Filters) pinned at bottom */
    html body .tkd-filters-dropdown.active .tkd-filters-actions {
        flex: 0 0 auto !important;
        display: flex !important;
        gap: 12px !important;
        padding: 12px 16px !important;
        margin: 0 !important;
        border-top: 1px solid #e5e7eb !important;
        background: #ffffff !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    html body .tkd-filters-dropdown.active .tkd-filters-actions > button {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        padding: 12px 14px !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
        font-weight: 600 !important;
    }

    /* v2.15.18: REMOVED the aggressive child styling rules.
       The wildcard `* { min-width: 0; max-width: 100% }` was too broad —
       it let flex/grid descendants collapse below their natural sizes
       when active-state classes were toggled, producing the layout chaos
       the user reported (sections overlapping, rating buttons rendering
       empty, etc.).
       The same applies to the chip/rating-button width overrides — the
       existing rules in modern-niche.php inline <style> (lines 1565-1633,
       6529-6568) plus the inline-JS force-styling at template line 9898+
       already give the dropdown a working layout on mobile. The ONLY
       thing those rules lacked was for the dropdown container to BE in
       the viewport — which v2.15.17's body-portal JS now provides.
       So this v2.15.16 block now does ONE thing: ensure the .active
       container is full-screen modal. Children render under the
       existing CSS / JS regime which the previous version (v2.0.6)
       used to deliver the working UX the user wants restored. */
}

/* ============================================
   v2.15.21 — MULTI-SELECT COMPARE TOOLBAR MOBILE
   ============================================
   The bottom-anchored toolbar that appears when 1+ businesses are
   selected for comparison renders fine on desktop, but on a 375px
   mobile viewport its desktop padding (12px 20px) + 3 button labels
   (Compare / Email / Share, each padding 8px 16px) + count text
   ("3 selected") + close X overflows horizontally — the buttons
   visually overlap each other and "Compare" gets clipped by "Email".

   Fix (mobile-only, @media max-width: 768px):
     - Stretch the toolbar to fill the viewport (minus 8px each side)
       instead of letting it center at its natural content width.
     - Tighten paddings + gaps so labels fit on most phones.
     - On the smallest phones (≤ 420px), HIDE the button text labels
       and keep only the icons — the count text + 3 icon-only buttons
       + close X all fit cleanly in ~360px of usable width. The icons
       (balance scale / envelope / share) are universally recognised.
     - Slight visual polish: bump the count font weight and use
       darker semi-transparent background so labels are easier to read.

   Desktop (≥ 769px) untouched — the existing rules at lines 11560+
   of modern-niche.php (padding 12px 20px, gap 12px, button padding
   8px 16px) continue to apply. */
@media (max-width: 768px) {
    /* Stretch toolbar to fill viewport width with small margins. */
    html body .tkd-multiselect-toolbar {
        left: 8px !important;
        right: 8px !important;
        transform: none !important;
        width: auto !important;
        max-width: calc(100vw - 16px) !important;
        padding: 8px 10px !important;
        gap: 6px !important;
        box-sizing: border-box !important;
    }

    /* Slide-up animation needs to keep transform: none in the resting
       state (we removed the centering translateX) so the final
       transform value matches what the static rule above sets. */
    html body .tkd-multiselect-toolbar.show {
        transform: none !important;
    }

    /* Count text: still visible, tighter margin. */
    html body .tkd-multiselect-toolbar .tkd-toolbar-count {
        font-size: 12px !important;
        margin-right: 4px !important;
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }

    /* Buttons: tighter padding, smaller font. */
    html body .tkd-multiselect-toolbar .tkd-toolbar-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        gap: 4px !important;
        flex: 0 1 auto !important;
        min-width: 0 !important;
        white-space: nowrap !important;
    }

    html body .tkd-multiselect-toolbar .tkd-toolbar-btn i {
        font-size: 13px !important;
    }

    /* Close X: small + tight. */
    html body .tkd-multiselect-toolbar .tkd-toolbar-close {
        margin-left: 2px !important;
        padding: 4px 6px !important;
        font-size: 16px !important;
        flex: 0 0 auto !important;
    }
}

/* On phones (≤ 480px, covers iPhone Pro Max and all common Android),
   hide the button text labels and show only icons. The toolbar's count
   text ("3 selected") + 3 icon-only buttons + close X all fit cleanly
   in <360px of usable width. The icons (balance scale / envelope /
   share) are universally recognised. */
@media (max-width: 480px) {
    html body .tkd-multiselect-toolbar .tkd-toolbar-btn {
        padding: 8px 10px !important;
        font-size: 0 !important; /* hides label text but keeps icon visible */
        gap: 0 !important;
    }
    html body .tkd-multiselect-toolbar .tkd-toolbar-btn i {
        font-size: 15px !important;
    }

    /* Make the count text more compact too. */
    html body .tkd-multiselect-toolbar .tkd-toolbar-count {
        font-size: 12px !important;
    }
}

/* ============================================
   v2.15.20 — RATING BUTTON ACTIVE-STATE BACKGROUND
   ============================================
   The active rating button (e.g. "Any Rating" by default, or "4.5+
   Stars" after selecting Top Rated) was rendering white-text-on-white
   because two CSS rules in modern-niche.php's inline <style> apply
   `background: white !important` with higher specificity than the
   .active rule:
     - .tkd-filters-dropdown.active .tkd-filter-section .tkd-rating-btn
       (specificity 0,0,3,0)
     - .tkd-filters-dropdown.active .tkd-filter-section
       .tkd-rating-selector .tkd-rating-btn (specificity 0,0,4,0)

   These rules win over .tkd-rating-btn.active (specificity 0,0,2,0)
   for the background, but the active rule's color: white still
   applies — yielding invisible text on a white box. (The border-color
   from .active does win, so we see a green outline around an empty
   box.)

   Fix: a rule with specificity 0,0,5,2 that beats both. Mobile-only. */
@media (max-width: 768px) {
    html body .tkd-filters-dropdown.active .tkd-filter-section .tkd-rating-selector .tkd-rating-btn.active,
    html body .tkd-filters-dropdown.active .tkd-filter-section .tkd-rating-btn.active {
        background: var(--tkd-accent-color, #00c746) !important;
        border-color: var(--tkd-accent-color, #00c746) !important;
        color: #ffffff !important;
    }
}

