/* AHProfi CZ v650 - shared fixes carried over from verified SK responsive UI.
   Scope: /souhrn-poptavky/ layout, mobile hamburger menu, editor product controls.
   No changes to product feeds, canvas geometry, checkout logic, discounts or currency. */

/* Mobile/tablet header menu: at 1100-1239 px the hamburger is already visible
   but the older styling for its menu items was restricted to <=1099 px.
   Keep one appearance on the setup, editor, checkout and confirmation pages. */
@media (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-action,.ahp-mobile-menu-link) {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border: 0 !important;
    border-radius: 8px !important;
    appearance: none !important;
    box-shadow: none !important;
    background: transparent !important;
    color: #fff !important;
    font: 800 15px/1.35 Arial, sans-serif !important;
    text-align: left !important;
    text-decoration: none !important;
    text-transform: none !important;
    white-space: normal !important;
    cursor: pointer !important;
  }
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-action,.ahp-mobile-menu-link)[hidden] {
    display: none !important;
  }
  html.ahp-layout-v497 .ahp-mobile-header-menu :is(.ahp-mobile-menu-action,.ahp-mobile-menu-link):is(:hover,:focus-visible) {
    background: #1c1c1c !important;
    color: #c11015 !important;
  }
  html.ahp-layout-v497 .ahp-mobile-header-menu .ahp-mobile-menu-social {
    margin-top: 8px !important;
    padding-top: 10px !important;
    border-top: 1px solid #333 !important;
  }
}

/* Checkout: preserve the wide desktop only when a complete product table fits. */
@media (min-width: 1560px) {
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid {
    grid-template-columns: minmax(0, 1fr) 430px !important;
    grid-template-areas: "hero side" "list side" !important;
  }
}

/* Narrow desktops: summary across the top, full product list on the left,
   previews+totals in the right side. Keep a useful width for item titles. */
@media (min-width: 1240px) and (max-width: 1559.98px) {
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 380px) !important;
    grid-template-areas: "hero hero" "list side" !important;
    gap: 20px !important;
    align-items: start !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-hero {
    grid-area: hero !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-list-card {
    grid-area: list !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-grid > .ahp-checkout-side {
    grid-area: side !important;
    min-width: 0 !important;
    max-width: 100% !important;
    position: static !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-row,.ahp-table-head,.ahp-section-total) {
    grid-template-columns: 52px minmax(170px, 1fr) 65px 96px 96px !important;
    gap: 9px !important;
  }
}

/* Tablets, small desktops and split-screen browsers: full-width summary,
   previews/totals, then FULL-WIDTH product table, never a narrow sidebar list. */
@media (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "hero" "side" "list" !important;
    gap: 20px !important;
    align-items: start !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid > .ahp-checkout-hero {
    grid-area: hero !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid > .ahp-checkout-side {
    grid-area: side !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid > .ahp-checkout-list-card {
    grid-area: list !important;
    grid-column: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Avoid oversized preview panels before stacking on smaller phones. */
@media (min-width: 820px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid > .ahp-checkout-side {
    display: grid !important;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr) !important;
    align-items: start !important;
    gap: 16px !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-checkout-side > :is(.ahp-preview-card,.ahp-totals-card) {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}
@media (min-width: 900px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page #checkoutSetupBox {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }
}

/* Restore header tracks in product tables; older 761-1160px styles hid
   the first blank cell and shifted labels onto the wrong columns. */
@media (min-width: 761px) and (max-width: 1239.98px) {
  html.ahp-layout-v497 .ahp-checkout-page :is(.ahp-row,.ahp-table-head,.ahp-section-total) {
    grid-template-columns: 64px minmax(210px, 1fr) 92px 116px 116px !important;
    gap: 12px !important;
  }
}
@media (min-width: 761px) and (max-width: 1559.98px) {
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:first-child {
    display: block !important;
    grid-column: 1 !important;
  }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(2) { grid-column: 2 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(3) { grid-column: 3 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(4) { grid-column: 4 !important; }
  html.ahp-layout-v497 .ahp-checkout-page .ahp-table-head > span:nth-child(5) { grid-column: 5 !important; }
}
html.ahp-layout-v497 .ahp-checkout-page:not(.ahp-sent-page) .ahp-checkout-grid > *,
html.ahp-layout-v497 .ahp-checkout-page .ahp-row-main,
html.ahp-layout-v497 .ahp-checkout-page .ahp-row-title {
  min-width: 0 !important;
  max-width: 100% !important;
}
html.ahp-layout-v497 .ahp-checkout-page .ahp-row-title {
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

/* Mobile editor: align price and quantity controls INSIDE each horizontal
   product card. The catalogue viewport needs room for the bottom row. */
@media (max-width: 899px) and (orientation: portrait) {
  html.ahp-layout-v497 #editorScreen #productList.product-list {
    flex: 0 0 177px !important;
    height: 177px !important;
    min-height: 177px !important;
    max-height: 177px !important;
    grid-auto-rows: max-content !important;
    align-items: start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 7px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-card {
    display: grid !important;
    box-sizing: border-box !important;
    grid-template-areas: "media main" "divider divider" "bottom bottom" !important;
    grid-template-rows: minmax(66px, 1fr) 1px 38px !important;
    align-self: start !important;
    height: 160px !important;
    min-height: 160px !important;
    max-height: 160px !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    grid-area: bottom !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    margin: 0 !important;
    padding: 2px 0 0 !important;
    gap: 3px !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-price {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-controls {
    display: grid !important;
    flex: 0 0 78px !important;
    grid-template-columns: 25px 28px 25px !important;
    width: 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    gap: 0 !important;
    position: static !important;
    transform: none !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-sub,.product-add) {
    width: 25px !important; min-width: 25px !important; max-width: 25px !important;
    height: 30px !important; min-height: 30px !important; max-height: 30px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-count-input {
    width: 28px !important; min-width: 28px !important; max-width: 28px !important;
    height: 30px !important; min-height: 30px !important; max-height: 30px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .price-sale { font-size: 12px !important; }
  html.ahp-layout-v497 #editorScreen #productList .price-old { font-size: 10px !important; }
}
@media (max-width: 359px) and (orientation: portrait) {
  html.ahp-layout-v497 #editorScreen #productList.product-list {
    flex-basis: 194px !important;
    height: 194px !important;
    min-height: 194px !important;
    max-height: 194px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-card {
    height: 178px !important;
    min-height: 178px !important;
    max-height: 178px !important;
    grid-template-rows: minmax(62px, 1fr) 1px 64px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    flex-direction: column !important;
    justify-content: center !important;
    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;
    gap: 2px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-price { flex: 0 1 auto !important; }
  html.ahp-layout-v497 #editorScreen #productList .product-controls { flex: 0 0 30px !important; }
}
