/**
 * WooCommerce Mobile Filter Drawer Stylesheet
 * Theme: Astra Child
 * Note: Applies ONLY on mobile screens (max-width: 768px).
 * Desktop styling is 100% untouched.
 */

/* Hide mobile-specific filter UI on desktop */
.ast-shop-toolbar-top-row {
  display: contents;
}

.ast-mobile-filter-bar,
.ast-mobile-filter-floating-btn,
.ast-filter-drawer-overlay,
.ast-drawer-header {
  display: none !important;
}



/* ==========================================================================
   ONLY FOR MOBILE SCREENS (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {

  .ast-left-sidebar #primary {
    padding-bottom: 0;
    margin-bottom: 0;
  }

  /* 1. Toolbar Top Row: Result Count on Left, Filter Button on Right (Red Box) */
  .ast-shop-toolbar-top-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    margin: 0 0 12px 0 !important;
    gap: 12px !important;
    box-sizing: border-box !important;
  }

  .ast-shop-toolbar-top-row .woocommerce-result-count,
  .woocommerce-result-count {
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #666666 !important;
    flex: 1 1 auto !important;
  }

  /* Toolbar filter bar beside result count */
  .ast-shop-toolbar-top-row .ast-mobile-filter-bar,
  .ast-mobile-filter-bar {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
  }

  /* Compact button fitting right in the top toolbar red box */
  .ast-mobile-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: var(--brand-purple, #98339A);
    color: #FFFFFF !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(152, 51, 154, 0.25);
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .ast-mobile-filter-btn:hover,
  .ast-mobile-filter-btn:active,
  .ast-mobile-filter-btn[aria-expanded="true"] {
    background-color: var(--brand-green, #349635);
    color: #FFFFFF !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 150, 53, 0.35);
  }

  .ast-mobile-filter-btn .ast-filter-btn-icon {
    font-size: 14px;
    line-height: 1;
    display: inline-block;
  }

  /* Full width ordering dropdown below the top row */
  .woocommerce-ordering {
    float: none !important;
    width: 100% !important;
    margin: 0 0 18px 0 !important;
    clear: both !important;
  }

  .woocommerce-ordering select.orderby {
    width: 100% !important;
  }

  /* 2. Fixed Sticky Filter Button (Mobile Left Side) */
  .ast-mobile-filter-floating-btn {
    position: fixed !important;
    bottom: 24px !important;
    left: 16px !important;
    right: auto !important;
    top: auto !important;
    z-index: 99999 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    background-color: var(--brand-purple, #98339A) !important;
    background: var(--brand-purple, #98339A) !important;
    color: #FFFFFF !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    padding: 12px 20px !important;
    border-radius: 50px !important;
    border: 2px solid #FFFFFF !important;
    cursor: pointer !important;
    box-shadow: 0 4px 18px rgba(152, 51, 154, 0.45) !important;
    transition: background-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    text-decoration: none !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
  }

  .ast-mobile-filter-floating-btn:hover,
  .ast-mobile-filter-floating-btn:active,
  .ast-mobile-filter-floating-btn[aria-expanded="true"] {
    background-color: var(--brand-green, #349635) !important;
    background: var(--brand-green, #349635) !important;
    color: #FFFFFF !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 22px rgba(52, 150, 53, 0.45) !important;
  }

  .ast-mobile-filter-floating-btn .ast-filter-btn-icon {
    font-size: 16px !important;
    line-height: 1 !important;
    display: inline-block !important;
  }

  .ast-mobile-filter-floating-btn .ast-filter-btn-text {
    font-size: 14px !important;
    line-height: 1 !important;
    color: #FFFFFF !important;
  }

  /* When drawer is open, hide sticky button so it doesn't overlap drawer content */
  body.ast-filter-drawer-open .ast-mobile-filter-floating-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.85) !important;
  }

  /* 3. Collapse Sidebar Container in Page Flow on Mobile (No display: none) */
  #secondary,
  .widget-area.secondary {
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    position: static !important;
    overflow: visible !important;
    float: none !important;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
  }

  .sidebar-main {
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    position: static !important;
    overflow: visible !important;
    float: none !important;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
  }

  /* 4. Sliding Drawer Container (.ast-filter-wrap) */
  .ast-filter-wrap {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 85% !important;
    max-width: 360px !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    background-color: #FFFFFF !important;
    z-index: 99999 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;

    /* Smooth Slide In/Out Animation */
    transform: translateX(-100%) !important;
    visibility: hidden !important;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease !important;
    box-shadow: 6px 0 28px rgba(24, 20, 81, 0.18) !important;

    /* Independent Touch Scrolling */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;

    display: flex !important;
    flex-direction: column !important;
  }

  /* Drawer Active State */
  .ast-filter-wrap.is-active,
  body.ast-filter-drawer-open .ast-filter-wrap {
    transform: translateX(0) !important;
    visibility: visible !important;
  }

  /* Custom Scrollbar for Drawer */
  .ast-filter-wrap::-webkit-scrollbar {
    width: 5px;
  }

  .ast-filter-wrap::-webkit-scrollbar-thumb {
    background: #d8dbe0;
    border-radius: 4px;
  }

  /* 5. Sticky Drawer Header */
  .ast-drawer-header {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 16px 20px !important;
    background-color: #FFFFFF !important;
    border-bottom: 1px solid rgba(148, 92, 148, 0.2) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
  }

  .ast-drawer-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--brand-navy, #181451) !important;
    letter-spacing: -0.2px;
    line-height: 1.2 !important;
  }

  .ast-drawer-close {
    background: none !important;
    border: none !important;
    font-size: 26px !important;
    line-height: 1 !important;
    color: var(--brand-navy, #181451) !important;
    cursor: pointer !important;
    padding: 4px 8px !important;
    margin: 0 !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s, color 0.2s !important;
    -webkit-tap-highlight-color: transparent;
  }

  .ast-drawer-close:hover,
  .ast-drawer-close:active {
    background-color: #f1f3f6 !important;
    color: var(--brand-purple, #98339A) !important;
  }

  /* 6. Filter Widgets Inside Drawer */
  .ast-filter-wrap .ast-woo-sidebar-widget {
    padding: 18px 20px !important;
    margin: 0 !important;
    border-bottom: 1px solid #f0f2f5 !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  .ast-filter-wrap .ast-woo-sidebar-widget:last-child {
    border-bottom: none !important;
    padding-bottom: 40px !important;
  }

  .ast-filter-wrap .ast-woo-sidebar-widget .widget-title,
  .ast-filter-wrap .ast-woo-sidebar-widget h2,
  .ast-filter-wrap .ast-woo-sidebar-widget h3,
  .ast-filter-wrap .ast-woo-sidebar-widget h4 {
    color: var(--brand-navy, #181451) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    margin-bottom: 12px !important;
  }

  /* 7. Semi-Transparent Backdrop Overlay */
  .ast-filter-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(24, 20, 81, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  body.ast-filter-drawer-open .ast-filter-drawer-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}