/* Desktop / default (unchanged) */
.d9-action-bar{
    display:flex;
    gap:10px;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    margin-bottom:12px;
}
.d9-input, .d9-btn, select {
    height:40px;
    padding:0 12px;
    border-radius:6px;
    border:1px solid #ccc;
    font-size:14px;
    background:#fff;
    cursor:pointer;
}
.d9-btn.primary{ background:#2b7cff; color:#fff; border-color:#1a6be8; }

/* Table - desktop look preserved */
.d9-product-table{ width:100%; border-collapse:collapse; margin-top:6px; }
.d9-product-table th{ background:#2b7cff; color:#fff; text-align:center; padding:10px; }
.d9-product-table td{ padding:8px; border:1px solid #e6e6e6; vertical-align:middle; }
.d9-zoomable{
    max-width:90px;
    height:auto;
    cursor:zoom-in;
    display:block;
    margin:0 auto;
    transition: transform .18s ease, box-shadow .18s ease;
}
.d9-zoomable:hover{ transform: scale(1.04); box-shadow: 0 10px 28px rgba(0,0,0,0.12); }

/* Hover preview */
.d9-hover-wrap{ pointer-events:none; }
.d9-hover-wrap .d9-hover-preview{ display:block; width:100%; height:100%; object-fit:contain; }

/* Modal */
.d9-modal{ position:fixed; left:0; right:0; top:0; bottom:0; background: rgba(0,0,0,0.45); display:flex; align-items:center; justify-content:center; z-index:9999; }
.d9-modal-inner{ background:#fff; padding:18px; border-radius:8px; min-width:340px; box-shadow:0 12px 28px rgba(0,0,0,.35); }

/* Pagination */
.d9-page-number, .d9-page-btn{ padding:6px 10px; border:1px solid #eee; border-radius:6px; text-decoration:none; margin:0 4px; display:inline-block; }
.d9-page-number.current{ background:#2b7cff; color:#fff; border-color:#1a6be8; }

/* ---------------------- Mobile-only modern block view ----------------------
   Only changes below; desktop/tablet keeps original appearance.
------------------------------------------------------------------------- */
@media (max-width: 800px) {

  /* Hide header and convert tbody to block mode */
  .d9-product-table thead { display: none; }
  .d9-product-table { border: 0; }
  .d9-product-table tbody { display: block; }

  /* Card container: 3-column grid for precise placement */
  .d9-product-table tr {
    display: grid;
    grid-template-columns: 56px 130px 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "sno image title"
      "select image title"
      ". sku qty"
      "price price price";
    gap: 10px;
    align-items: start;
    margin: 14px 8px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(43,124,255,0.08);
    background: linear-gradient(180deg,#ffffff,#fbfdff);
    box-shadow: 0 12px 36px rgba(43,124,255,0.06);
    transition: transform .14s ease, box-shadow .14s ease;
    page-break-inside: avoid;
    break-inside: avoid;
    position: relative;
  }
  .d9-product-table tr:hover { transform: translateY(-2px); box-shadow: 0 18px 45px rgba(43,124,255,0.08); }

  /* Reset td display and map them to grid areas by order:
     td1 -> sno ; td2 -> select ; td3 -> image ; td4 -> title
     td5 -> sku ; td6 -> qty ; td7 -> price
  */
  .d9-product-table td { display: block; border: 0; padding: 0; vertical-align: top; }

  .d9-product-table td:nth-child(1) { grid-area: sno; display:flex; align-items:flex-start; justify-content:center; padding-right:6px; font-weight:800; font-size:14px; color:#0f1724; }
  .d9-product-table td:nth-child(2) { grid-area: select; display:flex; align-items:flex-start; justify-content:center; padding-right:6px; }
  .d9-product-table td:nth-child(3) { grid-area: image; display:flex; align-items:center; justify-content:center; padding-right:6px; }
  .d9-product-table td:nth-child(4) { grid-area: title; padding-left:6px; display:flex; align-items:flex-start; }
  .d9-product-table td:nth-child(5) { grid-area: sku; }
  .d9-product-table td:nth-child(6) { grid-area: qty; }
  .d9-product-table td:nth-child(7) { grid-area: price; }

  /* Modern larger image */
  .d9-product-table td:nth-child(3) img {
    width: 120px;
    height: 120px;
    object-fit: cover; /* modern cropped look */
    border-radius: 10px;
    background: linear-gradient(180deg,#f8fafc,#ffffff);
    display: block;
    box-shadow: 0 8px 22px rgba(2,6,23,0.06);
    transition: transform .18s ease, box-shadow .18s ease;
  }
  /* gentle zoom on hover (desktop emulation), long-press on mobile handled by JS */
  .d9-product-table td:nth-child(3) img:hover { transform: scale(1.03); box-shadow: 0 14px 36px rgba(2,6,23,0.08); }

  /* Title styling */
  .d9-product-table td.d9-title-cell {
    font-weight:800;
    font-size:16px;
    color:#071133;
    line-height:1.15;
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:normal;
  }

  /* Style select checkbox into a modern circular toggle */
  .d9-product-table td:nth-child(2) .d9-select-row {
    -webkit-appearance: none;
    appearance: none;
    width:42px;
    height:42px;
    border-radius:50%;
    border:2px solid #cfe3ff;
    background:#fff;
    cursor:pointer;
    box-shadow: 0 6px 14px rgba(43,124,255,0.04);
    position:relative;
    outline:none;
    transition: background .12s ease, border-color .12s ease, transform .12s ease;
  }
  .d9-product-table td:nth-child(2) .d9-select-row:hover { transform: translateY(-2px); }
  .d9-product-table td:nth-child(2) .d9-select-row::after {
    content: "✓";
    color: transparent;
    font-weight:800;
    font-size:16px;
    line-height:42px;
    text-align:center;
    display:block;
  }
  .d9-product-table td:nth-child(2) .d9-select-row:checked {
    background: linear-gradient(180deg,#2b7cff,#1a6be8);
    border-color: #1a6be8;
    color:#fff;
  }
  .d9-product-table td:nth-child(2) .d9-select-row:checked::after { color: #fff; }

  /* SKU block */
  .d9-product-table td:nth-child(5) {
    display:flex;
    align-items:center;
    gap:8px;
    background:linear-gradient(180deg,#f8fbff,#ffffff);
    border-radius:10px;
    padding:10px;
    font-size:13px;
    color:#0f1724;
    margin-top:6px;
  }
  .d9-product-table td:nth-child(5)::before {
    content: "SKU";
    display:block;
    font-size:11px;
    color:#6b7280;
    margin-right:6px;
  }

  /* Available Qty block */
  .d9-product-table td:nth-child(6) {
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(180deg,#f8fbff,#ffffff);
    border-radius:10px;
    padding:10px;
    font-size:13px;
    color:#0f1724;
    margin-top:6px;
  }
  .d9-product-table td:nth-child(6)::before {
    content: "Available Qty";
    display:block;
    font-size:11px;
    color:#6b7280;
    margin-bottom:6px;
  }

  /* Price block (prominent pill) */
  .d9-product-table td:nth-child(7) {
    display:flex;
    align-items:center;
    justify-content:flex-end;
    padding:12px;
    margin-top:10px;
  }
  .d9-product-table td:nth-child(7) .d9-rate-input,
  .d9-product-table td:nth-child(7) input.d9-rate-input {
    min-width:140px;
    padding:10px 14px;
    border-radius:999px;
    border:1px solid rgba(252,240,240,0.9);
    background: linear-gradient(180deg,#fff6f6,#fff1f1);
    color:#c00;
    font-weight:800;
    font-size:15px;
    text-align:right;
    box-shadow: 0 8px 20px rgba(243, 83, 83, 0.04);
  }

  /* Selected visual */
  .d9-product-row.d9-selected,
  .d9-product-table tr.d9-selected {
    box-shadow: 0 18px 48px rgba(43,124,255,0.08);
    border-color: rgba(43,124,255,0.12);
    transform: translateY(-2px);
  }

  /* Sticky action bar at bottom (uses existing .d9-action-bar) */
  .d9-action-bar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 12px;
    z-index: 140000;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 24px 50px rgba(2,6,23,0.06);
    display:flex;
    gap:8px;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
  }
  .d9-action-bar > div:first-child { flex:1 1 auto; min-width:120px; }
  .d9-action-bar .d9-input, .d9-action-bar .d9-btn { height:40px; font-size:14px; }

  .d9-pagination { padding-bottom: 110px; } /* give room for sticky bar */

  /* Small phone tuning */
  @media (max-width:420px) {
    .d9-product-table tr { grid-template-columns: 48px 96px 1fr; gap:8px; padding:10px; }
    .d9-product-table td:nth-child(3) img { width:96px; height:96px; border-radius:8px; }
    .d9-product-table td:nth-child(1) { font-size:13px; width:48px; }
    .d9-product-table td:nth-child(2) .d9-select-row { width:38px; height:38px; }
    .d9-action-bar { left:6px; right:6px; bottom:8px; padding:8px; }
  }
}

/* Ensure desktop unaffected */
@media (min-width: 801px) {
  .d9-product-row.d9-selected { box-shadow:none; border-color:transparent; transform:none; }
}