/* Responsive adjustments */

/* Mobile-optimized sidebar toggle */
@media (max-width: 768px) {
  #sidebar-toggle {
    padding: 10px;
    margin-right: -5px;
    width: 44px;
    height: 44px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Use a close icon (×) instead of chevron on mobile */
  #sidebar-toggle i.bi-chevron-left {
    display: none;
  }

  #sidebar-toggle::after {
    content: "×";
    font-size: 24px;
    line-height: 1;
    display: block;
  }

  #container-apply-filter-button {
    display:block;
  }
}

/* Non-touch devices - ensure touch-friendly class has no effect */
@media (pointer: fine) {
  .ui-slider .ui-slider-handle.touch-friendly {
    width: 16px;
    height: 16px;
    top: -6px;
    margin-left: -6px;
  }
}

/* Touch devices - apply touch-friendly styles */
@media (pointer: coarse) {
  .ui-slider .ui-slider-handle.touch-friendly {
    width: 24px;
    height: 24px;
    top: -10px;
    margin-left: -12px;
  }

  .ui-slider {
    height: 8px;
    margin: 15px 0;
  }

  .ui-slider .ui-slider-handle {
    width: 26px;
    height: 26px;
    top: -10px;
    margin-left: -13px;
  }
}


@media (max-width: 768px) {
  /* List view layout adjustments for mobile */
  .list-view-layout {
    width: 100%;
  }

  /* Make sidebar fullscreen on mobile when visible */
  #filter-sidebar {
    width: 100%;
    min-width: auto;
    height: 100vh; /* Full screen height */
    padding: 0;
    border-right: none;
    border-bottom: none;
    position: fixed; /* Fixed position to cover the entire screen */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f8f9fa;
    z-index: 1000; /* Above most content */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  }

  /* Fix for collapsed sidebar on mobile - remove from layout flow */
  #filter-sidebar.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: -1; /* Place behind other content */
  }
  
  /* Ensure main content takes full width on mobile */
  .list-main-content {
    margin-left: 0 !important;
    width: 100% !important;
    transition: none !important; /* Disable transitions on mobile for better performance */
  }
  
  /* Reset list container position on mobile */
  #list-container {
    width: 100% !important;
    left: 0 !important;
  }
  
  /* Reset map container on mobile */
  #map {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Make the filter panel take full space on mobile */
  #filter-sidebar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  /* Make the filter panel fill the entire screen */
  #filter-sidebar-container #filter-panel {
    margin: 0;
    border: none;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #filter-sidebar-container .filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    max-height: none; /* Allow content to fill available space */
  }

  /* Add larger header for mobile filter panel */
  #filter-sidebar-container #filter-header {
    padding: 15px;
    height: 60px;
    align-items: center;
    font-size: 18px;
  }

  /* Larger close button in mobile filter header */
  #filter-sidebar-container #sidebar-toggle {
    font-size: 22px;
    padding: 8px;
  }

  /* More spacing between filter sections on mobile */
  #filter-sidebar-container .filter-section {
    margin-bottom: 20px;
  }

  /* Larger touch targets for checkboxes/radio buttons */
  #filter-sidebar-container .form-check {
    padding-left: 2.2rem;
    margin-bottom: 8px;
  }

  /* Simplify toolbar on mobile devices */
  .list-toolbar {
    padding: 8px 0; /* Slightly reduce the padding */
  }

  /* Hide the properties count text on mobile */
  #list-count-toolbar {
    display: none;
  }

  /* Make buttons more compact */
  #list-toolbar .btn-sm {
    padding: 3px 8px;
    font-size: 12px;
  }

  /* More prominent filters button */
  #show-filters-btn {
    font-weight: 500;
    padding: 5px 10px;
  }
}

@media (max-width: 576px) {
  #filter-panel {
    width: 220px;
    top: 10px;
    right: 10px;
  }



  /* Adjust tooltip position on mobile to avoid it going off-screen */
  #filter-header::after {
    top: 100%;
    left: 0;
    transform: none;
  }

  /* Specific positioning for very small screens */
  #filter-panel.collapsed {
    bottom: 10px !important;
    left: 10px !important;
  }

  /* Further simplify toolbar on very small devices */
  .list-toolbar {
    padding: 6px 0; /* Even more compact padding */
  }

  /* More compact buttons on smallest screens */
  #list-toolbar .btn-sm {
    padding: 2px 6px;
    font-size: 11px;
  }

  /* Add space between toolbar items */
  #list-toolbar .container-fluid {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* More compact icon and text */
  #list-toolbar .bi {
    font-size: 0.9em;
  }

  /* Further reduce margins between toolbar items */
  #list-toolbar .me-2 {
    margin-right: 0.4rem !important;
  }

  /* Tighten up spacing in dropdown menu */
  #list-toolbar .dropdown-menu {
    min-width: auto;
    font-size: 0.9rem;
    padding: 0.25rem 0;
  }

  #list-toolbar .dropdown-item {
    padding: 0.25rem 0.75rem;
  }
}

/* Mobile-specific adjustments for filter panel */
@media (pointer: coarse) {
  /* Larger touch targets for mobile */
  #filter-header {
    padding: 12px 16px; /* Larger padding for better touch target */
    min-height: 50px; /* Ensure minimum height for touch target */
  }

  /* Mobile tooltip positioning - shown below instead of above */
  #filter-header::after {
    top: 100%; /* Position below instead of above */
    left: 50%;
    transform: translateX(-50%);
  }

  /* Make drag handle more obvious on mobile */
  /*disabled with a good reason don't uncomment
  /*#filter-header::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    pointer-events: none;
  }*//*disabled for now don't activate*/

  /* Move collapsed filter panel to bottom left on small screens */
  #filter-panel.collapsed {
    bottom: 20px !important;
    top: auto !important;
    left: 20px !important;
    right: auto !important;
  }

}

/* Ensure filter panel stays on screen during orientation change */
@media screen and (orientation: portrait), screen and (orientation: landscape) {
  #filter-panel.transitioning {
    transition: none !important;
  }
}

/* Enhanced filters button for mobile */
@media (max-width: 768px) {
  #show-filters-btn {
    padding: 6px 12px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
  }

  #show-filters-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  }

  /* Add subtle animation to the chevron */
  #show-filters-btn i.bi-chevron-right {
    transition: transform 0.3s ease;
  }

  #show-filters-btn:hover i.bi-chevron-right {
    transform: translateX(3px);
  }
}
