/**
 * Spiegelloft — mobile/tablet filter bottom sheet
 *
 * Classes:
 *   sl-filter-open   → open button
 *   sl-filter-panel  → filter container (sidebar)
 *   sl-filter-close  → optional X
 */

:root {
  --sl-filter-overlay: rgba(0, 0, 0, 0.45);
  --sl-filter-radius: 20px;
  --sl-filter-sheet-max: 88vh;
  --sl-filter-speed: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1025px) {
  .sl-filter-open {
    display: none !important;
  }

  .sl-filter-overlay,
  .sl-filter-handle {
    display: none !important;
  }

  body.sl-filter-open-active {
    overflow: auto !important;
  }

  /* Don't keep mobile scroll wrapper styles on desktop */
  .sl-filter-panel .sl-filter-scroll {
    display: contents;
  }
}

@media (max-width: 1024px) {
  .sl-filter-open {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
  }

  .sl-filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: var(--sl-filter-overlay);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--sl-filter-speed), visibility var(--sl-filter-speed);
  }

  body.sl-filter-open-active .sl-filter-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Bottom sheet shell */
  .sl-filter-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: var(--sl-filter-sheet-max) !important;
    max-height: var(--sl-filter-sheet-max) !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 9999 !important;
    background: #fff !important;
    border-radius: var(--sl-filter-radius) var(--sl-filter-radius) 0 0 !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    transform: translateY(110%);
    transition: transform var(--sl-filter-speed);
    will-change: transform;
  }

  body.sl-filter-open-active .sl-filter-panel {
    transform: translateY(0);
  }

  .sl-filter-panel.is-dragging {
    transition: none !important;
  }

  /* Drag handle only — touch-action here, NOT on whole panel */
  .sl-filter-handle {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 14px 0 10px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    background: #fff;
    position: relative;
    z-index: 2;
  }

  .sl-filter-handle::before {
    content: "";
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: #cfcfcf;
  }

  /* Scroll area */
  .sl-filter-panel .sl-filter-scroll {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0 16px 24px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /*
   * Force ONE column inside the sheet.
   * Elementor often keeps desktop grid/flex row on nested containers.
   */
  .sl-filter-panel,
  .sl-filter-panel .sl-filter-scroll,
  .sl-filter-panel .e-con,
  .sl-filter-panel .e-con-inner,
  .sl-filter-panel .elementor-element,
  .sl-filter-panel .elementor-widget-wrap,
  .sl-filter-panel .elementor-container,
  .sl-filter-panel .elementor-section,
  .sl-filter-panel .elementor-column-wrap {
    /*flex-direction: column !important;*/
    flex-wrap: nowrap !important;
    align-items: stretch !important;
  }

  .sl-filter-panel .e-con,
  .sl-filter-panel .elementor-container,
  .sl-filter-panel .elementor-section {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Kill 2-column grids / columns inside filters */
  .sl-filter-panel .e-grid,
  .sl-filter-panel .elementor-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  .sl-filter-panel .elementor-column,
  .sl-filter-panel .e-con.e-child,
  .sl-filter-panel [data-element_type="container"],
  .sl-filter-panel [data-element_type="column"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
  }

  .sl-filter-panel .elementor-widget,
  .sl-filter-panel .elementor-element {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Remove nested scroll traps / tiny overflow areas */
  .sl-filter-panel .elementor-widget-container,
  .sl-filter-panel .e-con,
  .sl-filter-panel .elementor-element {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }

  .sl-filter-panel .sl-filter-scroll {
    overflow-y: auto !important;
  }

  body.sl-filter-open-active {
    overflow: hidden !important;
  }
}
