/* Mobile Filter Enhancements for Skladujto - Subtle Professional Design */

/* Enhanced Mobile Filter Row - Force immediate application and height matching */
.c-category-filters__mobile .c-category-filters__row {
    display: flex !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    align-items: stretch !important;
    min-height: 56px !important; /* Force minimum row height */
}

.c-category-filters__mobile .c-category-filters__item {
    flex: 1 !important;
    display: flex !important;
    align-items: stretch !important;
}

.c-category-filters__mobile .c-category-filters__item:last-child {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: stretch !important;
    min-width: 56px !important; /* Force minimum width to match height */
}

/* Enhanced Search/Date Button */
.c-category-filters__place {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 12px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    color: inherit !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    text-align: center !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    /* Remove forced height - let it be natural size from text content */
}

.c-category-filters__place:hover {
    border-color: #bbb;
    background: #f8f9fa;
}

.c-category-filters__place .w-icon {
    width: 16px;
    height: 16px;
    color: #666;
    flex-shrink: 0;
}

.c-category-filters__place span {
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* Enhanced Filter Button */
.c-category-filters__filter {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 16px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    color: inherit !important;
    font-size: 14px !important;
    position: relative !important;
    transition: all 0.2s ease !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    height: 100% !important; /* Stretch to match the place button height */
    min-width: 60px !important; /* Make it rectangular - wider than tall */
}

.c-category-filters__filter:hover {
    border-color: #bbb;
    background: #f8f9fa;
}

.c-category-filters__filter .w-icon {
    width: 16px;
    height: 16px;
    color: #666;
}

/* Filter Badge */
.c-filter-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #dc3545;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    line-height: 1;
}

/* Mobile Selection Menu */
.c-mobile-selection-menu {
    padding: 20px;
    background: #fff;
}

/* Hide selection menu only on large screens (desktop 1200px+) */
@media (min-width: 1200px) {
    .c-mobile-selection-menu {
        display: none !important;
    }
}

/* Hide desktop filters completely on mobile */
@media (max-width: 767px) {
    /* Hide the main desktop filter container */
    .c-category-filters__desktop {
        display: none !important;
    }
    
    /* CRITICAL: Hide the main filter content container by default on mobile */
    .js-filters-content-filters {
        display: none !important;
    }
    
    /* CRITICAL: Hide date and location content by default on mobile */
    .js-filters-content-date {
        display: none !important;
    }
    
    .js-filters-content-city {
        display: none !important;
    }
    
    /* Hide any remaining filter sections that might leak through */
    .c-filter-filter__section {
        display: none !important;
    }
    
    /* Only show when explicitly opened by JavaScript (inline style will override) */
    .js-filters-content-filters[style*="display: block"] {
        display: block !important;
    }
    
    .js-filters-content-date[style*="display: block"] {
        display: block !important;
    }
    
    .js-filters-content-city[style*="display: block"] {
        display: block !important;
    }
    
    /* Ensure filter sections show when parent is explicitly shown */
    .js-filters-content-filters[style*="display: block"] .c-filter-filter__section {
        display: block !important;
    }
}

.c-mobile-selection-header {
    text-align: center;
    margin-bottom: 24px;
}

.c-mobile-selection-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.c-mobile-selection-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.c-mobile-selection-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.c-mobile-selection-option:hover {
    background: #e9ecef;
    border-color: #ddd;
    transform: translateY(-1px);
}

.c-mobile-selection-option:active {
    transform: translateY(0);
}

/* Mobile: hide tablet category grid and tablet button rows,
   but keep mobile filter icons visible */
@media (max-width: 767px) {
    /* Hide tablet categories and tablet-specific rows */
    .c-category-filters__desktop .c-filter-category__wrapper,
    .c-category-filters__desktop .c-filter-category,
    .c-category-filters__desktop .c-category-filters__btn-row {
        display: none !important;
    }

    /* Restore mobile icons that were hidden earlier */
    .c-category-filters__place .w-icon,
    .c-category-filters__filter .w-icon {
        display: inline-block !important;
    }

    /* Restore spacing around icon + text */
    .c-category-filters__place,
    .c-category-filters__filter {
        gap: 8px !important;
        justify-content: center !important;
        text-align: center !important;
    }
}

/* --- Unify mobile with tablet layout ---
   We no longer use a separate mobile selection menu. On small screens,
   render the same filters/content as on tablet. */
@media (max-width: 767px) {
    /* Hide the special mobile selection sheet entirely */
    .c-mobile-selection-menu {
        display: none !important;
    }

    /* Show the standard filter containers just like tablet */
    .c-category-filters__desktop {
        display: block !important;
    }

    .js-filters-content-filters,
    .js-filters-content-date,
    .js-filters-content-city,
    .c-filter-filter__section {
        display: block !important;
    }

    /* Ensure any mobile-only footers are hidden to match tablet behavior */
    .c-mobile-filter-signpost__footer,
    .c-mobile-date-footer,
    .c-mobile-location-footer {
        display: none !important;
    }
}

/* Position the filter modal at the top with 10px margin */
#modal-filter-date-place[style*="display: block"] .l-alert__cnt {
    position: fixed !important;
    top: 10px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    height: calc(100% - 7rem) !important; /* requested modal height */
    max-height: calc(100% - 7rem) !important;
    overflow: auto !important;
    z-index: 10001 !important;
}

/* Ensure height applies regardless of opener context */
.l-alert__item--show .l-alert__cnt {
    height: calc(100% - 7rem) !important;
    max-height: calc(100% - 7rem) !important;
}

#modal-filter-date-place[style*="display: block"] .js-simple-alert-content {
    min-height: calc(100vh - 40px) !important;
    max-height: calc(100vh - 40px) !important;
    overflow-y: auto !important;
}

.c-mobile-selection-option-icon {
    width: 40px;
    height: 40px;
    background: #f8f9fa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

.c-mobile-selection-option-icon .w-icon {
    width: 20px;
    height: 20px;
    color: #666;
}

.c-mobile-selection-option-content {
    flex: 1;
    min-width: 0;
}

.c-mobile-selection-option-title {
    font-size: 14px;
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.c-mobile-selection-option-value {
    font-size: 13px;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.c-mobile-selection-option-arrow {
    margin-left: 8px;
    flex-shrink: 0;
}

.c-mobile-selection-option-arrow .w-icon {
    width: 16px;
    height: 16px;
    color: #6c757d;
}

.c-mobile-selection-actions {
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.c-mobile-selection-clear {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.c-mobile-selection-clear:hover {
    background: #e9ecef;
    color: #495057;
}

.c-mobile-selection-clear .w-icon {
    width: 14px;
    height: 14px;
}

/* Selection Menu Footer */
.c-mobile-selection-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

.c-mobile-selection-submit {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

/* Mobile Date Modal */
.c-mobile-date-modal {
    background: #fff;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}

.c-mobile-date-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: none; /* Hidden by default, shown by JavaScript */
}

.c-mobile-date-info {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: #fff3cd;
    border-radius: 8px;
    font-size: 13px;
    color: #856404;
    gap: 8px;
}

.c-mobile-date-info .w-icon {
    width: 16px;
    height: 16px;
    color: #856404;
    flex-shrink: 0;
}

.c-mobile-date-actions {
    display: flex;
    gap: 12px;
}

/* Mobile Location Modal */
.c-mobile-location-modal {
    background: #fff;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}

.c-mobile-location-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: none; /* Hidden by default, shown by JavaScript */
}

/* Mobile Filter Footer Styling - High Specificity */
.c-mobile-filter-signpost__footer.c-mobile-date-footer,
.c-mobile-filter-signpost__footer.c-mobile-location-footer,
.c-mobile-filter-signpost__footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 16px 20px !important;
    background: #f8f9fa !important;
    border-top: 1px solid #e9ecef !important;
    flex-direction: row !important;
}

.c-mobile-filter-signpost__footer-back {
    color: #6c757d !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    order: 1 !important;
}

.c-mobile-filter-signpost__footer-back:hover {
    color: #495057 !important;
    text-decoration: none !important;
}

.c-mobile-filter-signpost__footer button,
.c-mobile-filter-signpost__footer .btn {
    order: 2 !important;
    margin-left: auto !important;
}

/* Override any existing padding */
.c-mobile-date-footer,
.c-mobile-location-footer {
    padding: 0 !important;
}

/* Ensure proper modal isolation */
.js-filters-content-date .c-mobile-filter-signpost__footer:not(.c-mobile-date-footer) {
    display: none !important;
}

.js-filters-content-city .c-mobile-filter-signpost__footer:not(.c-mobile-location-footer) {
    display: none !important;
}

/* Hide all footers by default, show only when explicitly activated */
.c-mobile-filter-signpost__footer {
    display: none !important;
}

.c-mobile-filter-signpost__footer.c-mobile-date-footer,
.c-mobile-filter-signpost__footer.c-mobile-location-footer {
    display: none !important; /* Will be overridden by JavaScript when needed */
}

/* Ensure date footer is visible when in date selection mode */
.js-filters-content-date[style*="display: block"] .c-mobile-date-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

/* Ensure location footer is visible when in location selection mode */
.js-filters-content-city[style*="display: block"] .c-mobile-location-footer {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.c-mobile-location-actions {
    display: flex;
    gap: 12px;
}

/* Ensure Lokalita suggestions overlay the calendar without pushing layout */
.c-mobile-filter-signpost .w-style-suggest {
    position: relative !important;
    z-index: 10010 !important;
}

/* Common autocomplete/suggest dropdowns - make them overlay */
.c-mobile-filter-signpost .ui-autocomplete,
.c-mobile-filter-signpost .suggest,
.c-mobile-filter-signpost .suggest-list,
.c-mobile-filter-signpost .w-suggest-list {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10020 !important;
    width: 100% !important;
    max-height: 50vh !important;
    overflow: auto !important;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12) !important;
}

/* Keep calendar under overlays */
.c-mobile-filter-signpost .js-filter-available-calendar-items,
.c-mobile-filter-signpost .c-availability__calendars {
    position: relative !important;
    z-index: 1 !important;
}

/* Ensure calendar month nav arrows are clickable above any overlays */
.c-mobile-filter-signpost .c-availability__nav {
    position: relative !important;
    z-index: 10030 !important;
    pointer-events: auto !important;
}

.c-mobile-filter-signpost .c-availability__nav .c-availability__nav-item {
    pointer-events: auto !important;
}

/* Lower c-filter-city min-height, keep height on modal container so menu persists */
@media (max-width: 767px) {
    .c-filter-city {
        min-height: 0 !important;
    }
}

/* Mobile Buttons */
.c-mobile-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.c-mobile-btn--primary {
    background: #007bff;
    color: white;
}

.c-mobile-btn--primary:hover {
    background: #0056b3;
}

.c-mobile-btn--secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #e9ecef;
}

.c-mobile-btn--secondary:hover {
    background: #e9ecef;
    color: #495057;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .c-category-filters__mobile .c-category-filters__row {
        padding: 6px 12px !important;
        gap: 6px !important;
    }
    
    .c-category-filters__place {
        padding: 8px 10px !important;
        font-size: 13px !important;
        /* Keep natural height from text content on mobile too */
    }
    
    .c-category-filters__filter {
        padding: 8px 12px !important;
        font-size: 13px !important;
        height: 100% !important; /* Stretch to match place button on mobile */
        min-width: 50px !important; /* Rectangular on mobile too */
    }
    
    .c-mobile-selection-option {
        padding: 14px;
    }
    
    .c-mobile-btn {
        padding: 14px 16px;
        font-size: 15px;
    }
}

/* Screen reader improvements */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus improvements */
.c-category-filters__place:focus,
.c-category-filters__filter:focus,
.c-mobile-selection-option:focus,
.c-mobile-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Animation for better UX */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Prevent close button flashing during modal close */
.js-simple-alert-close {
    transition: opacity 0.1s ease !important;
}

.js-simple-alert-close.closing {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Prevent flashing during menu transitions - INSTANT UPDATES */
.c-mobile-selection-option {
    transition: none !important; /* Remove transitions for instant updates */
}

.c-mobile-selection-option-value {
    transition: none !important; /* Instant text updates */
}

.c-mobile-selection-menu {
    transition: none !important; /* Instant menu display */
}

/* Ensure smooth but fast transitions for user interactions only */
.c-mobile-selection-option:hover {
    transition: all 0.1s ease !important; /* Fast hover only */
}

/* Hide content during updates to prevent flashing */
.c-mobile-selection-updating {
    visibility: hidden !important;
}

.c-mobile-selection-updating.ready {
    visibility: visible !important;
}

.c-mobile-selection-option {
    animation: slideInUp 0.3s ease forwards;
}

.c-mobile-selection-option:nth-child(2) {
    animation-delay: 0.1s;
}

/* Active state styling */
.c-category-filters__place:active {
    transform: translateY(1px);
}

.c-category-filters__filter:active {
    transform: translateY(1px);
}

.c-mobile-selection-option:active {
    transform: translateY(0);
}

/* Load More Button - Mobile Responsive */
@media (max-width: 767px) {
    .js-load-more-rents {
        padding: 10px 20px !important;
        font-size: 14px !important;
    }
    
    .js-load-more-rents .btn__text {
        font-size: 14px !important;
    }
    
    #snippet--loadMoreButton {
        padding: 1.5rem 0 !important;
        margin-bottom: 1rem !important;
    }
}