/* =======================================================
   responsive.css (desktop-first)
   Breakpoint: 1280 / 1024 / 768 / 480
   NOTE: product-buy ALLINEATO A DESTRA anche su schermi stretti
======================================================= */

/* ======================
   Base (safe)
====================== */

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, svg, canvas, iframe {
  max-width: 100%;
  height: auto;
}

/* (safe) evita scroll orizzontale mentre sistemi i colpevoli */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* ======================
   Layout
====================== */

@media (max-width: 768px) {
  .layout-main {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 480px) {
  .layout-main {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ======================
   Header
====================== */

@media (max-width: 1024px) {
  .demo-header-top {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center;
    gap: 16px !important;
  }

  .demo-header-top > * {
    min-width: 0;
  }

  .demo-header-search,
  .demo-header-top .demo-search-wrap,
  .demo-header-top #mainSearchForm {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }

  .demo-menu-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
  }

  .demo-menu-link {
    white-space: nowrap;
  }

  .demo-header-actions {
    display: flex !important;
    align-items: center;
    gap: 10px !important;
    margin-left: auto;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
  }
}

@media (max-width: 768px) {
  .demo-header-inner {
    padding: 14px 16px;
  }

  .demo-header-top {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 12px !important;
  }

  .demo-logo-wrap {
    justify-content: center;
  }

  .demo-logo-wrap img {
    height: 40px !important;
  }

  .demo-menu-bar {
    gap: 8px 12px;
  }

  .demo-menu-link {
    font-size: 14px;
  }

  .demo-header-search,
  .demo-search-wrap,
  .demo-header-top #mainSearchForm {
    width: 100%;
    max-width: 100%;
  }

 
  .demo-header-actions {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: flex-end !important;
    gap: 8px !important;
    margin-left: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }


  .demo-header-actions .demo-menu-link {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .demo-header-actions {
    gap: 6px !important;
  }

  .demo-user-icon,
  .cart-menu__btn .demo-cart-icon {
    width: 22px;
    height: 22px;
  }

  .demo-header-actions .demo-menu-link {
    font-size: 13px;
  }
}

/* ======================
   Searchbox
====================== */

@media (max-width: 768px) {
  #mainSearchForm {
    padding: 8px 14px !important;
    gap: 10px !important;
  }

  #mainSearchForm #searchInput {
    font-size: 14px !important;
    min-width: 0 !important;
    flex: 1 1 auto;
  }

  #mainSearchForm button[type="submit"] {
    padding: 8px 16px !important;
    font-size: 14px !important;
    flex: 0 0 auto;
  }

  #searchSuggestions {
    padding: 14px 14px 10px !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 480px) {
  #mainSearchForm {
    padding: 8px 12px !important;
  }

  #mainSearchForm button[type="submit"] {
    padding: 8px 12px !important;
  }
}

/* ======================
   Megamenu (pannello <= 1024)
   (unica definizione mobile)
====================== */

@media (max-width: 1024px) {
  .menu-products-wrapper > :not(.menu-products-toggle) {
    display: none;
  }

  .menu-products-wrapper.is-open > :not(.menu-products-toggle) {
    display: block;
  }

  .menu-products-wrapper.is-open > :not(.menu-products-toggle) {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    z-index: 10000 !important;

    border-radius: 0 !important;
    background: var(--color-bg) !important;
    padding: 16px !important;

    box-sizing: border-box !important;
  }

  .menu-products-wrapper.is-open,
  .menu-products-wrapper.is-open * {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .menu-products-wrapper.is-open .pmenu-right-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .menu-products-wrapper.is-open .pmenu-right-panel {
    width: 100% !important;
    max-width: 100% !important;
  }

  .menu-products-wrapper.is-open a,
  .menu-products-wrapper.is-open .pmenu-right-name,
  .menu-products-wrapper.is-open .pmenu-left a {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  .menu-products-wrapper.is-open a {
    display: block;
    padding: 10px 10px !important;
    border-radius: 10px !important;
  }

  .menu-products-wrapper.is-open .pmenu-left,
  .menu-products-wrapper.is-open .pmenu-right {
    padding: 0 !important;
    margin: 0 !important;
  }

  body.is-megamenu-open {
    overflow: hidden;
    touch-action: none;
  }
}

@media (max-width: 480px) {
  .menu-products-wrapper.is-open > :not(.menu-products-toggle) {
    padding: 12px !important;
  }

  .menu-products-wrapper.is-open a {
    padding: 10px 8px !important;
  }
}

/* ======================
   Footer top (colonne)
====================== */

.rd-footer-top-grid {
  display: grid;
  gap: 16px;
}

@media (max-width: 1024px) {
  .rd-footer-top-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .rd-footer-top-grid {
    grid-template-columns: 1fr;
  }

  .rd-foot-img img {
    max-width: 220px;
    width: 100%;
    height: auto;
  }

  .rd-foot-col {
    padding-bottom: 8px;
  }
}

/* ======================
   Footer map
====================== */

.rd-footer-map {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rd-footer-map iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 0;
  height: 360px;
}

@media (max-width: 768px) {
  .rd-footer-map iframe {
    height: 280px;
  }
}

@media (max-width: 480px) {
  .rd-footer-map iframe {
    height: 220px;
  }
}

/* ======================
   Category: righe prodotto
====================== */

/* base: robustezza */
.product-row,
.product-row * {
  min-width: 0;
}

.product-info {
  overflow: hidden;
}

.product-info a,
.product-info strong,
.product-info span {
  overflow-wrap: anywhere;
}

/* desktop baseline */
.product-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

/* BUY sempre a destra */
.product-buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 8px;
}

.product-buy > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.product-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* <= 1024: immagine + info, buy sotto (MA sempre a destra) */
@media (max-width: 1024px) {
  .product-row {
    grid-template-columns: 160px minmax(0, 1fr);
  }

  .product-buy {
    grid-column: 2 / -1;
    align-items: flex-end;
    text-align: right;
  }

  .product-buy > div {
    justify-content: flex-end;
  }
}

/* <= 768: tutto in colonna (MA buy a destra) */
@media (max-width: 768px) {
  .product-row {
    grid-template-columns: 1fr;
  }

  .product-buy {
    grid-column: auto;
    width: 100%;
    align-items: flex-end;
    text-align: right;
  }

  .product-buy > div {
    width: 100%;
    justify-content: flex-end;
  }
}

/* <= 480: non full-width sul bottone (se vuoi “a destra” deve restare naturale) */
@media (max-width: 480px) {
  .qty-input {
    width: 64px;
  }

}

/* =======================================================
   FIX mobile overflow product-row (buy che sfora a destra)
   Scoped: solo liste con listClass="category-products-list"
   (MA buy resta allineato a DESTRA)
======================================================= */

@media (max-width: 768px) {
  .category-products-list .product-row {
    display: grid !important;
    grid-template-columns: 1fr !important;

    padding: 16px 14px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    margin-bottom: 14px;
    background: var(--color-bg);
    box-shadow: var(--shadow-soft);
  }

  .category-products-list .product-row,
  .category-products-list .product-row * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .category-products-list .product-buy {
    width: 100% !important;
    max-width: 100% !important;
    text-align: right !important;
    align-items: flex-end !important;
  }

  .category-products-list .product-buy > div,
  .category-products-list .product-buy .buy-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
  }

  .category-products-list .product-image {
    display: flex;
    justify-content: center;
  }

  .category-products-list .product-image img {
    max-width: 180px;
    width: 100%;
    height: auto;
  }

  .category-products-list .product-info {
    font-size: 14px;
    line-height: 1.35;
  }

  .category-products-list .qty-btn {
    width: 34px;
    height: 34px;
    line-height: 32px;
  }

  .category-products-list .qty-input {
    width: 72px;
    height: 34px;
    font-size: 15px;
  }

}

/* ======================
   Home: griglia prodotti
====================== */

.grid-products {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1280px) {
  .grid-products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .grid-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .grid-products {
    grid-template-columns: 1fr;
  }
}

/* ======================
   Home: card (safe)
====================== */

.grid-products a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.grid-products a > div {
  min-width: 0;
}

.grid-products strong {
  word-break: break-word;
}

@media (max-width: 480px) {
  .grid-products a > div {
    padding: 12px !important;
  }
}

/* ======================
   Product page
====================== */

/* Prezzo sopra ai controlli (desktop + tutti i viewport) */
.buy-box {
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 10px !important;
}

.buy-prices {
  text-align: right !important;
  min-width: 0 !important;
}

@media (max-width: 768px) {
  .product-container {
    padding: 18px !important;
    margin: 18px auto !important;
  }

  .product-image-box {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  .product-details {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  /* anche qui: a destra */
  .buy-box {
    align-items: flex-end !important;
  }

  .buy-prices {
    text-align: right !important;
  }

  .buy-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .qty-btn {
    width: 34px !important;
    height: 34px !important;
    line-height: 32px !important;
  }

  .qty-input {
    width: 72px !important;
    height: 34px !important;
  }

}

/* ======================
   Contatti
====================== */

@media (max-width: 768px) {
  .contact-form{
    grid-template-columns: 1fr !important;
  }

  .contact-actions{
    grid-column: auto !important;
    justify-content: flex-start;
  }

  .contact-label{
    padding-top: 0;
  }

  .contact-wrap{
    margin: 24px auto;
  }
}

@media (max-width: 480px) {
  .contact-wrap{
    margin: 18px auto;
  }

  .contact-submit{
    width: 100%;
  }
}

/* ======================
   Home: searchsuggestion responsive
====================== */
@media (max-width: 768px) {
  #searchSuggestions > div[style*="display:grid"] {
    grid-template-columns: 1fr !important;
  }
}