/* ZooMag r30.6 — mobile catalogue correction.
   Loaded after r30.5. This file consolidates the category controls, makes
   two-column product cards genuinely narrow-screen safe, and repairs the
   product quick-facts block. */

#product-category .zm-category-content-top {
  display: contents;
}

@media (max-width: 767.98px) {
  /* The category already has its own title, breadcrumbs and mandatory filter.
     Layout modules in content_top repeat "Категории / Фильтры" on phones. */
  #product-category .zm-category-content-top,
  #product-category > .row.g-4 > #column-left,
  #product-category #column-left,
  #product-category .zm-sidebar-toggle {
    display: none !important;
  }

  #product-category.zoomag-category-page {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: auto !important;
    padding-inline: 12px !important;
    overflow-x: clip !important;
  }

  #product-category > .row.g-4 {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    margin: 0 !important;
    --bs-gutter-x: 0 !important;
    --bs-gutter-y: 0 !important;
  }

  #product-category #content,
  #product-category .zoomag-category-content {
    order: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* One filter entry instead of three competing mobile controls. */
  #product-category > .row.g-4 > .zoomag-filter-sidebar-container,
  #product-category > .row.g-4 > #column-right,
  #product-category .zoomag-filter-sidebar-container {
    order: 1 !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 2px !important;
    padding: 0 !important;
    transform: none !important;
  }

  #product-category .zoomag-filter-sidebar {
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 128, 84, .2) !important;
    border-radius: 16px !important;
    background: rgba(255, 255, 255, .96) !important;
    box-shadow: 0 8px 22px rgba(76, 54, 36, .08) !important;
    overflow: hidden !important;
  }

  #product-category .zoomag-filter-header {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 7px !important;
    background: linear-gradient(90deg, rgba(255, 247, 241, .98), rgba(244, 255, 252, .98)) !important;
    border: 0 !important;
  }

  #product-category .zoomag-filter-header .zoomag-header-content {
    display: block !important;
    min-height: 0 !important;
  }

  #product-category .zoomag-filter-header :is(.zoomag-header-kicker, .zoomag-header-title, .zoomag-header-meta) {
    display: none !important;
  }

  #product-category .zoomag-mobile-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: #78423d !important;
    font-size: 14px !important;
    line-height: 1 !important;
    font-weight: 850 !important;
    box-shadow: none !important;
  }

  #product-category .zoomag-mobile-toggle::after {
    content: "Показать";
    margin-left: auto;
    color: #728177;
    font-size: 11px;
    font-weight: 750;
  }

  #product-category .zoomag-mobile-toggle[aria-expanded="true"]::after {
    content: "Скрыть";
  }

  #product-category .zoomag-filter-panel {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    border-top: 1px solid rgba(76, 205, 196, .14) !important;
  }

  #product-category .zoomag-filter-panel:not(.is-open) {
    display: none !important;
  }

  #product-category .zoomag-filter-panel.is-open {
    display: block !important;
    max-height: min(72dvh, 620px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  /* Calm, compact category heading. */
  #product-category .zoomag-category-header {
    min-height: 0 !important;
    margin: 4px 0 10px !important;
    padding: 14px 15px !important;
    border: 1px solid rgba(82, 67, 99, .1) !important;
    border-radius: 17px !important;
    background: linear-gradient(120deg, #fff 0%, #fff9f5 54%, #f4fffc 100%) !important;
    box-shadow: 0 8px 20px rgba(74, 55, 44, .07) !important;
    overflow: hidden !important;
  }

  #product-category .zoomag-category-header > .row,
  #product-category .zoomag-category-header [class*="col-"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #product-category .zoomag-category-title-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
  }

  #product-category .zoomag-category-title {
    margin: 0 !important;
    color: #352f3b !important;
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
    text-shadow: none !important;
    transform: none !important;
    animation: none !important;
    font-size: clamp(1.35rem, 6.4vw, 1.8rem) !important;
    line-height: 1.1 !important;
    font-weight: 850 !important;
    text-align: left !important;
  }

  #product-category .zoomag-category-icon,
  #product-category .zoomag-category-thumb {
    width: 54px !important;
    min-width: 54px !important;
    height: 54px !important;
    border-radius: 14px !important;
  }

  #product-category .zoomag-category-accordion {
    margin: 0 0 10px !important;
    border: 1px solid rgba(76, 205, 196, .2) !important;
    border-radius: 16px !important;
    box-shadow: 0 6px 16px rgba(46, 120, 113, .06) !important;
  }

  #product-category .zoomag-accordion-header {
    min-height: 48px !important;
    padding: 8px 12px !important;
  }

  #product-category .zoomag-accordion-icon-wrapper {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border-radius: 10px !important;
  }

  #product-category .zoomag-accordion-title {
    font-size: 14px !important;
    line-height: 1.2 !important;
  }

  #product-category .zoomag-divider {
    display: none !important;
  }

  /* Sorting and page-size controls: one short row, no empty panel. */
  #product-category .zoomag-controls-panel {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 10px 0 12px !important;
    padding: 9px !important;
    border: 1px solid rgba(76, 205, 196, .18) !important;
    border-radius: 16px !important;
    background: rgba(255, 255, 255, .92) !important;
    box-shadow: 0 7px 18px rgba(44, 84, 79, .06) !important;
    overflow: visible !important;
  }

  #product-category .zoomag-controls-panel > .row {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
  }

  #product-category .zoomag-controls-panel > .row > :first-child,
  #product-category .zoomag-controls-panel .zoomag-view-control,
  #product-category .zoomag-controls-panel .col-auto:has(.zoomag-view-toggle),
  #product-category .zoomag-view-toggle {
    display: none !important;
  }

  #product-category .zoomag-controls-panel > .row > :last-child {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #product-category .zoomag-controls-panel .row.g-3 {
    display: grid !important;
    grid-template-columns: minmax(0, 1.5fr) minmax(96px, .7fr) !important;
    align-items: end !important;
    gap: 8px !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
  }

  #product-category .zoomag-controls-panel .col-auto,
  #product-category .zoomag-select-group,
  #product-category .zoomag-select-wrapper {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #product-category .zoomag-select-label {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    min-height: 18px !important;
    margin: 0 0 5px !important;
    color: #58505e !important;
    font-size: 10px !important;
    line-height: 1 !important;
    font-weight: 750 !important;
  }

  #product-category .zoomag-select {
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 28px 0 10px !important;
    border: 1px solid rgba(76, 205, 196, .45) !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: #3f3945 !important;
    font-size: 11px !important;
    line-height: 1.1 !important;
    box-shadow: none !important;
  }

  #product-category .zoomag-select-arrow {
    right: 10px !important;
    font-size: 11px !important;
  }

  /* Two columns remain useful only when every internal control is compact. */
  #product-category #product-list,
  body.zm-final-grid-mode #product-category #product-list,
  body #product-category #product-list.zm-final-grid,
  body #product-category #product-list.zoomag-products-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 0 16px !important;
  }

  #product-category #product-list .zoomag-product-item {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  #product-category #product-list .petz-product-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(70, 129, 89, .12) !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, #fff 0%, #fffefa 100%) !important;
    box-shadow: 0 6px 18px rgba(56, 55, 73, .07) !important;
    overflow: hidden !important;
  }

  #product-category #product-list .petz-image-section {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    aspect-ratio: 1 / 1 !important;
    padding: 7px 7px 0 !important;
  }

  #product-category #product-list :is(.petz-image-link, .petz-image-container) {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 11px !important;
  }

  #product-category #product-list .petz-product-image {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    object-fit: contain !important;
    transform: none !important;
  }

  #product-category #product-list .petz-image-overlay,
  #product-category #product-list .petz-quick-view,
  #product-category #product-list .petz-decoration {
    display: none !important;
  }

  #product-category #product-list .petz-content-section {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    gap: 7px !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 9px !important;
  }

  #product-category #product-list .petz-header {
    min-width: 0 !important;
  }

  #product-category #product-list .petz-category {
    display: inline-flex !important;
    align-items: center !important;
    width: fit-content !important;
    max-width: 100% !important;
    margin: 0 0 5px !important;
    padding: 3px 7px !important;
    overflow: hidden !important;
    border-radius: 999px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }

  #product-category #product-list .petz-category span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #product-category #product-list .petz-product-name {
    display: block !important;
    min-width: 0 !important;
    min-height: calc(1.25em * 3) !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  #product-category #product-list .petz-product-name a {
    display: -webkit-box !important;
    min-width: 0 !important;
    overflow: hidden !important;
    color: #302d35 !important;
    font-size: clamp(13px, 3.75vw, 15px) !important;
    line-height: 1.25 !important;
    font-weight: 750 !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
  }

  #product-category #product-list .petz-features {
    display: none !important;
  }

  #product-category #product-list .petz-pricing-section,
  #product-category #product-list .petz-price-block {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #product-category #product-list :is(.petz-price-main, .petz-special-price) {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    color: #2c4050 !important;
    font-size: clamp(16px, 4.65vw, 20px) !important;
    line-height: 1.12 !important;
    font-weight: 850 !important;
    letter-spacing: -.02em !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }

  #product-category #product-list .petz-price-special {
    display: block !important;
    min-width: 0 !important;
  }

  #product-category #product-list :is(.petz-old-price, .petz-savings-badge, .petz-rating-block) {
    margin-top: 4px !important;
    font-size: 10px !important;
  }

  #product-category #product-list .petz-actions-section {
    width: 100% !important;
    min-width: 0 !important;
    margin-top: auto !important;
  }

  #product-category #product-list .petz-quantity-control {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 0 7px !important;
  }

  #product-category #product-list .petz-quantity-control > label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
  }

  #product-category #product-list .petz-quantity-selector {
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) 34px !important;
    align-items: center !important;
    gap: 3px !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 2px !important;
    border: 1px solid rgba(76, 175, 80, .18) !important;
    border-radius: 10px !important;
    background: #f8fbf8 !important;
  }

  #product-category #product-list :is(.petz-qty-btn, .petz-qty-input) {
    width: 100% !important;
    min-width: 0 !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 8px !important;
    font-size: 12px !important;
  }

  #product-category #product-list .petz-product-form,
  #product-category #product-list .petz-action-buttons {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  #product-category #product-list .petz-cart-btn {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 6px 8px !important;
    border-radius: 11px !important;
  }

  #product-category #product-list .petz-cart-btn .petz-btn-content {
    justify-content: center !important;
    min-width: 0 !important;
    gap: 5px !important;
  }

  #product-category #product-list .petz-cart-btn .petz-btn-text {
    min-width: 0 !important;
    overflow: hidden !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
    text-align: center !important;
  }

  #product-category #product-list .petz-secondary-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    margin-top: 6px !important;
  }

  #product-category #product-list .petz-secondary-actions :is(.petz-btn, .petz-btn-secondary) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  #product-category #product-list .petz-secondary-actions .petz-btn::after {
    display: none !important;
    content: none !important;
  }

  #product-category .zoomag-products-footer {
    margin-top: 12px !important;
  }

  /* Fixed assistant remains available but no longer covers a large part of a card. */
  body:has(#product-category) #zoomag-ai-assistant.zoomag-ai-assistant {
    right: max(6px, env(safe-area-inset-right, 0px)) !important;
    width: 48px !important;
  }

  body:has(#product-category) #zoomag-ai-assistant .zm-ai-dock-toggle {
    width: 48px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 16px 16px 0 0 !important;
  }

  /* Product quick facts: brand/model stay paired, stock gets the full row. */
  .zoohub-product-showcase .zoohub-facts-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .zoohub-product-showcase .zoohub-fact-item {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 68px !important;
    padding: 9px !important;
    overflow: hidden !important;
  }

  .zoohub-product-showcase .zoohub-fact-item--stock,
  .zoohub-product-showcase .zoohub-fact-item:has(#stock-status) {
    grid-column: 1 / -1 !important;
    min-height: 58px !important;
  }

  .zoohub-product-showcase .zoohub-fact-icon {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 12px !important;
    font-size: 16px !important;
  }

  .zoohub-product-showcase .zoohub-fact-content {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .zoohub-product-showcase :is(.zoohub-fact-label, .zoohub-fact-value) {
    display: block !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none !important;
  }

  .zoohub-product-showcase .zoohub-fact-label {
    margin-bottom: 3px !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
  }

  .zoohub-product-showcase .zoohub-fact-value {
    font-size: 13px !important;
    line-height: 1.2 !important;
  }

  .zoohub-product-showcase #stock-status.zoohub-stock-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    width: auto !important;
    max-width: 100% !important;
    min-height: 32px !important;
    margin: 0 !important;
    padding: 6px 9px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }
}

@media (max-width: 359.98px) {
  #product-category #product-list,
  body.zm-final-grid-mode #product-category #product-list,
  body #product-category #product-list.zm-final-grid,
  body #product-category #product-list.zoomag-products-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #product-category .zoomag-controls-panel .row.g-3 {
    grid-template-columns: minmax(0, 1fr) 92px !important;
  }

  .zoohub-product-showcase .zoohub-facts-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .zoohub-product-showcase .zoohub-fact-item--stock,
  .zoohub-product-showcase .zoohub-fact-item:has(#stock-status) {
    grid-column: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #product-category .zoomag-category-title,
  #product-category #product-list .petz-product-card {
    animation: none !important;
    transition: none !important;
  }
}
