/**
 * Mobile storefront polish. Loads after responsive.css.
 */

@media (max-width: 991px) {

  html,
  body {
    overflow-x: hidden;
  }

  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-header-actions {
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    justify-content: space-around;
    align-items: center;
    z-index: 99990;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.gallery-open .mobile-header-actions {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* ----- Mega menu: sheet above any dim layer ----- */
  body.mega-menu-open .main-header,
  body.mega-menu-open .main-header.sticky {
    z-index: 100050 !important;
    overflow: visible;
  }

  .mega-menu-overlay,
  .mega-menu-overlay.active {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

  .category-wrapper .category-dropdown,
  .category-dropdown,
  .category-dropdown.active {
    z-index: 100051 !important;
    background: #fff;
    isolation: isolate;
    pointer-events: auto !important;
  }

  .mega-menu-sheet-head {
    background: #fff;
    border-bottom: 1px solid #eee;
  }

  .mega-menu-search {
    background: #f6f6f6;
    border-bottom: 1px solid #eee;
  }

  .mega-menu-search-input {
    background: #fff;
    border: 1px solid #e8e8e8;
  }

  .category-list > li > a {
    border-bottom: 1px solid #f0f0f0;
  }

  .category-list > li > a:active,
  .category-list > li.has-submenu.active > a {
    background: #fff8dc;
    box-shadow: inset 3px 0 0 var(--primary);
  }

  /* ----- Cart drawer above bottom bar ----- */
  .cart-overlay.active {
    z-index: 100060;
  }

  .cart-sidebar {
    z-index: 100061;
  }

  .cart-body {
    height: auto !important;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cart-footer {
    flex: none;
  }

  /* ----- Shop filters ----- */
  .mobile-filter-overlay {
    pointer-events: none;
  }

  .mobile-filter-overlay.active {
    z-index: 100070;
    pointer-events: auto;
  }

  .products-listing-section .filter-header {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  body:has(.main-header.sticky) .products-listing-section .filter-header {
    top: var(--bl-header-height, 64px);
  }

  .products-listing-section .filter-btn {
    position: relative;
    z-index: 6;
    pointer-events: auto !important;
  }

  .filter-modal-overlay:not(.active),
  .ajax-loader:not(.active) {
    pointer-events: none !important;
  }

  .mobile-filter,
  .mobile-filter.active {
    z-index: 100071;
  }

  /* "Εμφάνιση (N)" belongs only inside an open filter sheet.
     It was leaking onto the shop bar and over the category menu. */
  .mobile-filter:not(.active) {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .mobile-filter:not(.active) .mobile-filter-footer,
  .mobile-filter:not(.active) .apply-filter-btn,
  body.mega-menu-open .mobile-filter,
  body.mega-menu-open .apply-filter-btn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .mobile-filter .filter-clear-all,
  .mobile-filter .product-sidebar.filter-clear-all {
    display: none !important;
    position: static !important;
  }

  .mobile-filter .sidebar-wrapper {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    min-height: 100%;
    height: auto !important;
    align-items: stretch;
    background: #fff;
  }

  .mobile-filter .product-sidebar {
    width: 100% !important;
    background: #fff !important;
    border-right: none !important;
  }

  .mobile-filter .product-sidebar .sidebar-content,
  .mobile-filter .product-sidebar.active .sidebar-content {
    position: static !important;
    left: auto !important;
    width: 100% !important;
    height: auto !important;
  }

  .mobile-filter-footer {
    display: flex !important;
    width: 100% !important;
    margin: 0 !important;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-filter-clear {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 12px 18px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    font-weight: 600;
  }

  .mobile-filter .apply-filter-btn {
    flex: 1;
    min-height: 48px;
    border-radius: 10px;
  }

  .mobile-filter .product-sidebar.active .sidebar-content {
    min-height: 180px;
    justify-content: flex-start;
    padding: 20px 16px 24px !important;
  }

  .mobile-filter .price-range-slider {
    margin-top: 12px;
  }

  /* Chip dropdowns on the shop listing must not cover the page */
  .products-listing-section .product-sidebar .sidebar-content {
    z-index: 30;
  }

  /* ----- Account ----- */
  .woocommerce-account .woocommerce-MyAccount-content,
  .woocommerce .woocommerce-MyAccount-content,
  .woocommerce-account .account-content,
  .my-account .account-content,
  .woocommerce-MyAccount-content {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .account-grid,
  .account-grid > *,
  .account-sidebar,
  .account-content,
  .bb-account-dashboard,
  .bb-dashboard-header,
  .bb-user-info,
  .dashboard-header {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .bb-dashboard-header {
    display: block;
    margin-bottom: 24px;
    text-align: left;
  }

  .bb-user-info h2,
  .dashboard-header h2 {
    font-size: clamp(22px, 6.4vw, 30px) !important;
    line-height: 1.25 !important;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: break-word;
    word-break: break-word;
    margin: 0 0 8px;
  }

  .bb-user-info p,
  .dashboard-header p {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.5;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .account-sidebar {
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
  }

  .account-sidebar .woocommerce-MyAccount-navigation,
  nav.woocommerce-MyAccount-navigation {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .account-sidebar .woocommerce-MyAccount-navigation ul,
  nav.woocommerce-MyAccount-navigation ul {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .account-sidebar .woocommerce-MyAccount-navigation li,
  nav.woocommerce-MyAccount-navigation li {
    flex: 0 0 auto;
    min-width: max-content;
  }

  .woocommerce .account-sidebar .woocommerce-MyAccount-navigation a,
  .account-sidebar .woocommerce-MyAccount-navigation a,
  nav.woocommerce-MyAccount-navigation ul li a {
    box-shadow: none;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
  }

  .woocommerce .account-sidebar .woocommerce-MyAccount-navigation li.is-active a,
  .account-sidebar .woocommerce-MyAccount-navigation li.is-active a {
    background: #fff3c4;
    box-shadow: none;
  }

  .bb-stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }

  .stat-box {
    padding: 16px 12px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .stat-box strong,
  .stat-box span {
    display: block;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .stat-box strong {
    font-size: 28px;
  }

  .bb-account-grid,
  .dashboard-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .account-card {
    padding: 18px;
  }

  .account-card h4 {
    font-size: 18px;
  }

  /* ----- Product / shop cards ----- */
  .product-cart-row {
    width: 100%;
  }

  .product-add-cart {
    min-height: 48px;
  }

  .feature-item {
    min-width: 0;
    max-width: 100%;
  }

  .contact-wrapper,
  .blog-grid,
  .blog-layout {
    grid-template-columns: 1fr;
    min-width: 0;
  }

}

@media (max-width: 576px) {
  .bb-stats {
    grid-template-columns: 1fr;
  }
}

@media screen and (max-width: 782px) {
  html.admin-bar .main-header.sticky {
    top: 46px;
  }

  html.admin-bar .category-dropdown.active {
    padding-top: 46px;
  }

  html.admin-bar body:has(.main-header.sticky) .products-listing-section .filter-header,
  html.admin-bar body:has(.main-header.sticky) .tabs {
    top: calc(var(--bl-header-height, 64px) + 46px);
  }
}

@media (min-width: 783px) and (max-width: 991px) {
  html.admin-bar body:has(.main-header.sticky) .products-listing-section .filter-header {
    top: calc(var(--bl-header-height, 64px) + 32px);
  }
}

/*
 * Cross-width mobile pass (320–991). Prefer ranges the theme already
 * uses. Desktop ≥992 is unchanged.
 */

@media (max-width: 991px) {

  .container,
  .wrapper,
  .products-listing-section,
  .products-listing-grid,
  .products-grid,
  .product-card,
  .product-content,
  .product-actions,
  .ajax-cart-form,
  .cart-table,
  .cart-table-item,
  .checkout-content-wrapper,
  .hero-section-call {
    min-width: 0;
    max-width: 100%;
  }

  .category-wrapper .category-dropdown,
  .category-dropdown,
  .category-dropdown.active {
    width: 100% !important;
    max-width: 100% !important;
  }

  .products-listing-grid .products-grid,
  .related-products .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-card,
  .product-content,
  .product-title,
  .product-title a,
  .products-price {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .product-card .products-cart-btn,
  .product-card .product-add-cart {
    min-width: 0;
    min-height: 48px;
    padding: 10px 8px;
    font-size: 12px;
    gap: 6px;
    justify-content: center;
  }

  .product-card .products-cart-btn .btn-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .product-card .quantity-box {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  .product-card .quantity-btn {
    width: 44px;
    height: 44px;
    flex: 1 1 0;
    max-width: 48px;
  }

  .products-listing-section .filter-header .sort-btn {
    min-width: 0;
  }

  .products-listing-section .filter-header .sort-content,
  .products-listing-section .filter-header .selected-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-btn {
    flex: 0 0 auto;
  }

  .main-header.sticky .main-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
  }

  .main-header.sticky .logo,
  .main-header.sticky .category-wrapper,
  .main-header.sticky .header-search,
  .main-header.sticky .mobile-search-bar {
    min-width: 0;
  }

  .main-header.sticky .logo img {
    max-width: 100%;
    height: auto;
  }

  .main-header.sticky .category-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .search-toggle {
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .tabs {
    top: var(--bl-header-height, 64px);
  }

  .pagination-wrapper,
  .pagination-wrapper ul {
    max-width: 100%;
    flex-wrap: wrap;
  }

  .hero-section-call {
    min-width: 0;
    max-width: 100%;
  }

  .feature-item {
    min-width: 0;
  }

}

@media (max-width: 768px) {

  .cart-sidebar {
    width: 100%;
    max-width: 100%;
    right: -100%;
  }

  .cart-sidebar.active {
    right: 0;
  }

  .cart-item,
  .item-content,
  .item-content h6,
  .cart-table .product-title,
  .cart-table .product-title a {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .cart-item img {
    width: 72px;
    flex-shrink: 0;
  }

  .cart-table .quantity-box {
    min-width: 0;
    width: auto;
    max-width: 100%;
  }

  .mobile-header-actions {
    min-height: 56px;
  }

  .mobile-header-actions .header-icon-box,
  .mobile-header-actions .cart-box {
    width: auto;
    min-width: 48px;
    min-height: 48px;
    padding: 10px;
    box-sizing: border-box;
  }

  .mobile-header-actions .cart-box {
    gap: 4px;
  }

  .products-grid.list-view .product-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }

  .products-grid.list-view .product-image {
    width: 100%;
    flex: none;
    min-width: 0;
  }

  .products-grid.list-view .product-actions {
    width: 100%;
  }

  .blog-bottom {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 767px) {

  .main-header.sticky .main-header-inner {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .main-header.sticky .logo {
    flex: 0 1 auto;
  }

  .main-header.sticky .category-wrapper {
    flex: 1 1 auto;
    min-width: 0;
  }

  .main-header.sticky .mobile-search-bar,
  .main-header.sticky .search-toggle {
    flex: 0 0 auto;
  }

  .products-listing-section .filter-header .sort-label,
  .products-listing-section .filter-header .sort-divider {
    display: none;
  }

  .deal-product-card,
  .new-products-card {
    width: min(280px, calc(100vw - 40px));
    max-width: 100%;
    box-sizing: border-box;
  }

}

@media (max-width: 480px) {

  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .logo img {
    width: min(140px, 38vw);
  }

  .main-header.sticky .logo img {
    width: min(118px, 34vw);
  }

  .main-header.sticky .category-btn {
    gap: 8px;
    padding: 10px 10px;
  }

  .products-listing-grid .products-grid,
  .products-grid,
  .related-products .products-grid {
    gap: 8px;
  }

  .product-content {
    padding: 8px;
  }

  .product-title {
    font-size: 13px;
    line-height: 1.35;
  }

  .product-card .products-cart-btn,
  .product-card .product-add-cart {
    min-height: 44px;
    padding: 8px 6px;
    font-size: 11px;
  }

  .filter-btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  .pagination-wrapper a,
  .pagination-wrapper span {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .pagination-wrapper .prev,
  .pagination-wrapper .next {
    padding: 0 10px;
  }

  .account-sidebar .woocommerce-MyAccount-navigation a,
  nav.woocommerce-MyAccount-navigation ul li a {
    min-height: 44px;
    padding: 10px 12px;
  }

  .cart-table .cart-table-item {
    padding: 12px;
  }

  .cart-header,
  .cart-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .cart-body {
    padding-left: 16px;
    padding-right: 16px;
  }

}
