/**
 * BazaarVerse POS — mobile layout v2
 * Builds on pos-mobile-v1.css. Fixes inventory horizontal scroll,
 * denser cart rows, and catalogue price visibility without crushing columns.
 */

/* -------------------------------------------------------------------------- */
/* Inventory: scroll wide tables instead of crushing columns                  */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  /*
   * Page-level overflow-x clip in v1 stops accidental page swipe, but the
   * inventory table must still pan inside its own scrollport.
   */
  .bv-inv-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: thin;
  }

  .bv-inv-table {
    width: max-content !important;
    min-width: 960px !important;
    max-width: none !important;
    table-layout: auto !important;
  }

  .bv-inv-table th,
  .bv-inv-table td {
    white-space: nowrap;
  }

  /* Product name may wrap; keep other cells readable */
  .bv-inv-table td.bv-inv-product-cell,
  .bv-inv-table td.bv-inv-product-cell p {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .bv-inv-table .truncate {
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
  }

  /* ------------------------------------------------------------------ */
  /* Sales cart — denser, touch-friendly rows (not global scale)        */
  /* ------------------------------------------------------------------ */
  .bv-sales-cart-panel {
    display: flex !important;
    flex-direction: column !important;
  }

  .bv-sales-cart-scroll {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .bv-sales-cart-scroll .divide-y > div {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  .bv-sales-cart-scroll .divide-y > div > div:first-child {
    margin-bottom: 0.35rem !important;
    align-items: flex-start !important;
    gap: 0.35rem !important;
  }

  /* Long names wrap instead of shoving controls off-screen */
  .bv-sales-cart-line-name {
    white-space: normal !important;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    word-break: break-word;
    font-size: 0.8125rem !important;
  }

  .bv-sales-cart-line-controls {
    margin-left: 0 !important;
    padding-left: 1.35rem;
    gap: 0.35rem !important;
    row-gap: 0.35rem !important;
    align-items: center !important;
  }

  .bv-sales-cart-line-controls .ml-auto {
    margin-left: auto !important;
    flex-shrink: 0;
  }

  .bv-sales-cart-line-total {
    flex-shrink: 0 !important;
    text-align: right;
    min-width: 4.5rem;
  }

  /* Qty / rate / discount chips — slightly tighter on narrow screens */
  .bv-sales-cart-line-controls > div {
    flex-shrink: 0;
  }

  .bv-sales-cart-line-controls input[type="number"] {
    min-height: 1.75rem;
  }

  /* ------------------------------------------------------------------ */
  /* Catalogue / product cards — keep price fully visible               */
  /* ------------------------------------------------------------------ */
  .bv-sales-product-grid > button {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    min-width: 0;
  }

  .bv-sales-product-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.15rem;
    min-width: 0;
    width: 100%;
    position: relative;
    z-index: 1;
  }

  .bv-sales-product-price {
    position: relative;
    z-index: 2;
    flex-shrink: 0 !important;
    display: block !important;
    width: 100%;
    text-align: center;
    line-height: 1.2;
    overflow: visible !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  .bv-sales-product-stock {
    flex-shrink: 0 !important;
    position: relative;
    z-index: 1;
    max-width: 100%;
  }

  /* Extra clearance so last-row prices aren't covered by View Cart FAB */
  .bv-sales-product-scroll {
    padding-bottom: 6.25rem !important;
  }
}

/* Ultra-narrow: allow cart totals to sit on their own row cleanly */
@media (max-width: 359.98px) {
  .bv-sales-cart-line-controls {
    padding-left: 0 !important;
  }

  .bv-sales-cart-line-total {
    width: 100%;
    margin-left: 0 !important;
    margin-top: 0.15rem;
  }

  .bv-inv-table {
    min-width: 900px !important;
  }
}

/* Tablets: still allow inventory swipe if needed, without phone cart chrome */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .bv-inv-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .bv-inv-table {
    min-width: 920px;
    width: max-content;
    max-width: none;
    table-layout: auto !important;
  }
}
