/**
 * responsive.css — EmbSupply ultimate mobile (v5)  marker: RESPONSIVE_V5_MARKER
 *
 * Paired with mobile-shop.js, which rebuilds the X-Cart product matrix
 * (4 <tr> per group: image/name/price/buynow) into .m-card elements inside
 * a .m-product-grid. CSS Grid then lays them out responsively with image,
 * title, price, and button correctly grouped per product.
 *
 * Desktop (>1024px) is unchanged — all rules live in max-width queries,
 * except the Recently-Viewed spacing fix (a genuine desktop bug) which is global.
 */

#content-container img, #header img { max-width: 100%; height: auto; }

/* ---- Recently Viewed spacing (global; fixes desktop gaps too) ---- */
.menu-rviewed-section .content .item {
  display: block; overflow: hidden; padding: 8px 0; margin: 0; border-bottom: 1px solid #eee;
}
.menu-rviewed-section .content .item .image { float: left; width: 70px; margin-right: 10px; }
.menu-rviewed-section .content .item .image img { max-width: 65px; height: auto; }
.menu-rviewed-section .content .item .product-title { display: block; padding-top: 4px; }
.menu-rviewed-section .content .item img.separator { display: none; }
.menu-rviewed-section .content .item:last-child { border-bottom: none; }

/* ==========================================================================
   <=1024px : drop desktop min-width; single column via flex order
   ========================================================================== */
@media (max-width: 1024px) {
  html, body { min-width: 0 !important; overflow-x: hidden; }
  #page-container, #page-container2, #content-container { width: auto !important; max-width: 100%; box-sizing: border-box; }

  #content-container2 { display: flex; flex-direction: column; width: 100% !important; right: auto !important; }
  #center      { order: 2; left: auto !important; width: 100% !important; float: none !important; }
  #center-main { margin: 0 !important; padding: 0 10px !important; }
  #left-bar    { order: 3; float: none !important; width: 100% !important; margin: 0 0 10px 0 !important; right: auto !important; }
  #right-bar   { order: 4; float: none !important; width: 100% !important; margin: 0 0 10px 0 !important; }

  #page-container2 { display: flex; flex-direction: column; }
  #content-container { order: 2; }
  #header { order: 1; }
  #footer { order: 3; }
}

/* ==========================================================================
   <=768px : mobile
   ========================================================================== */
@media (max-width: 768px) {

  /* ---- HEADER ---- */
  #header { height: auto !important; position: static !important; padding: 6px 0 !important; border-bottom: 1px solid #e3e3e3; }
  #header .line1 { height: auto !important; text-align: center; }
  #header .line1 .logo { margin: 0 !important; padding-top: 6px; text-align: center; float: none !important; }
  #header .line1 .logo img { max-width: 220px; width: 60%; height: auto; }

  /* nav tabs -> centered wrap, real tap targets */
  #header .tabs { position: static !important; width: 100% !important; height: auto !important; text-align: center; margin: 6px 0 0; }
  #header .tabs ul { padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; }
  #header .tabs li { float: none !important; display: inline-block; background: none !important; height: auto !important; margin: 0; }
  #header .tabs a { background: none !important; height: auto !important; min-height: 40px; line-height: 1.3; font-size: 14px; padding: 9px 12px; display: inline-block; color: #1b3f73; }

  #header .phones { text-align: center; padding: 4px 0; font-size: 13px; }
  #header .phones span { display: inline-block; margin: 0 6px; }

  /* ---- SEARCH: sticky full-width bar ---- */
  #header .line2 { padding: 8px 10px; background: #f7941d; position: sticky; top: 0; z-index: 50; }
  #header .line2 .search { width: 100%; }
  #header .line2 .search .valign-middle { display: block; }
  #header .line2 .search span.search { display: none; }  /* drop the "Search:" label, placeholder is enough */
  #header .line2 .search form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  #header .line2 .search input[type="text"],
  #header input[name="posted_data[substring]"] {
    flex: 1 1 100%; width: 100% !important; box-sizing: border-box; font-size: 16px;
    min-height: 44px; padding: 10px 12px; border: 1px solid #d98a10; border-radius: 6px; margin: 0;
  }
  #header .line2 .search .image-button { display: none; }
  #header .line2 .search a.search { flex: 0 0 auto; color: #5a2d00; font-size: 13px; text-decoration: underline; }

  /* ====================================================================
     PRODUCT CARDS (built by mobile-shop.js) — responsive grid
     ==================================================================== */
  .m-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);   /* 2 per row on phones */
    gap: 10px;
    padding: 10px 0;
  }
  .m-card {
    display: flex; flex-direction: column; align-items: center;
    border: 1px solid #e6e6e6; border-radius: 10px; padding: 12px 8px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.05); text-align: center;
  }
  .m-card-image { min-height: 90px; display: flex; align-items: center; justify-content: center; }
  .m-card-image img { max-width: 100%; max-height: 110px; height: auto; width: auto; }
  .m-card-name { margin: 8px 0 4px; }
  .m-card-name a, .m-card-name .product-title { font-size: 14px; font-weight: 600; color: #16489c; text-decoration: none; line-height: 1.3; }
  .m-card-price { margin: 2px 0 8px; font-size: 14px; }
  .m-card-price .price { color: #555; }
  .m-card-price .price-value, .m-card-price .currency { color: #c00; font-weight: 700; }
  .m-card-buynow { margin-top: auto; width: 100%; }
  .m-card-buynow .buy-now, .m-card-buynow form { width: 100%; }
  .m-card-buynow .button, .m-card-buynow button {
    width: 100%; box-sizing: border-box; min-height: 44px; font-size: 15px;
  }
  .m-card-buynow .quantity-empty { display: none; }

  /* fallback: if JS didn't run, at least stop the table from forcing 5 cols */
  table.products.products-table:not([data-mcard-done]) td.product-cell { padding: 6px !important; }

  /* ---- generic tap targets ---- */
  .button, button, input[type="submit"], input[type="button"], a.button { min-height: 44px; padding: 10px 16px; font-size: 16px; }
  input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="search"], input[type="tel"], select, textarea {
    font-size: 16px; min-height: 42px; max-width: 100%; box-sizing: border-box;
  }

  /* ---- CART page: stack line items into cards ---- */
  .products.cart table.item, .products.cart table.item tbody, .products.cart table.item tr { display: block; width: 100%; }
  .products.cart table.item td { display: block; width: 100% !important; text-align: left; box-sizing: border-box; padding: 6px 0; }
  .products.cart table.item td.image { text-align: center; }
  .products.cart table.item td.image img { max-width: 140px; height: auto; }
  table.cart-totals, .order-details table, .downloads table {
    display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }

  /* ---- forms: labels above fields (checkout/register) ---- */
  .form-field label, .register-form label, .checkout label { display: block; margin-bottom: 4px; }

  /* ---- product detail page: image + info stack ---- */
  .product-details .product-img-wrap, .product-details .image { float: none !important; width: 100% !important; text-align: center; margin: 0 0 12px; }
  .product-details .product-img-wrap img, .product-details .image img { max-width: 100%; height: auto; }

  /* ====================================================================
     COLLAPSIBLE menus (.menu-dialog > .title-bar + .content)
     ==================================================================== */
  .menu-dialog { margin-bottom: 8px; }
  .menu-dialog .title-bar { cursor: pointer; position: relative; -webkit-user-select: none; user-select: none; }
  .menu-dialog .title-bar::after {
    content: "\25BC"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    transition: transform .2s; font-size: 12px; color: #fff; opacity: .85;
  }
  .menu-dialog.mnav-collapsed .title-bar::after { transform: translateY(-50%) rotate(-90deg); }
  .menu-dialog.mnav-collapsed .content { display: none !important; }

  /* category list inside the menu: bigger tap targets */
  .menu-fancy-categories-list .content ul.fancycat-icons-level-0 li a { padding: 10px 8px; display: flex; align-items: center; font-size: 15px; }
  .menu-fancy-categories-list .content ul.fancycat-icons-level-0 li a img { margin-right: 8px; }
}

/* ==========================================================================
   <=480px : tighten
   ========================================================================== */
@media (max-width: 480px) {
  #center-main { padding: 0 8px !important; }
  .m-product-grid { gap: 8px; }
  .m-card { padding: 10px 6px; }
}

/* ==========================================================================
   <=360px : 1 card per row
   ========================================================================== */
@media (max-width: 360px) {
  .m-product-grid { grid-template-columns: 1fr; }
}
