
/* V303 — Fix hàng sản phẩm Lên đơn / Sửa đơn trên desktop.
   Không còn sm:flex-wrap tự nhảy dòng.
   <1100px giữ mobile.
*/

/* Desktop chuẩn / 1920x1080 Scale 125% */
@media (min-width:1280px){

  .order-dialog-content .v303-order-line-fields{
    display:grid!important;
    grid-template-columns:
      minmax(150px,1fr)   /* Sản phẩm */
      96px                /* Số lượng */
      96px                /* ĐVT */
      176px               /* NCC */
      96px                /* VAT nhập */
      128px               /* Giá nhập */
      128px               /* Giá bán */
      112px               /* VAT bán */
      128px               /* Thành tiền */
      34px!important;     /* Xóa */
    align-items:end!important;
    gap:8px!important;
    width:100%!important;
    min-width:0!important;
  }

  .order-dialog-content .v303-order-line-fields > *{
    width:auto!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
  }

  /* Gỡ các width sm:w-* cũ để grid làm chủ vị trí */
  .order-dialog-content .v303-order-line-fields > [class*="sm:w-"]{
    width:auto!important;
  }

  .order-dialog-content .v303-order-line-fields > *:first-child{
    min-width:150px!important;
  }

  .order-dialog-content .v303-order-line-fields input,
  .order-dialog-content .v303-order-line-fields select,
  .order-dialog-content .v303-order-line-fields [data-slot="select-trigger"]{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }

  /* Tên SP/NCC không đẩy cột khác */
  .order-dialog-content .v303-order-line-fields [data-slot="select-value"],
  .order-dialog-content .v303-order-line-fields [class*="truncate"]{
    min-width:0!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }

  /* Nút xóa luôn ở cột cuối, cùng hàng */
  .order-dialog-content .v303-order-line-fields > button:last-child{
    grid-column:10!important;
    width:34px!important;
    min-width:34px!important;
    height:32px!important;
    justify-self:end!important;
    align-self:end!important;
  }

  /* Thành tiền không xuống dòng */
  .order-dialog-content .v303-order-line-fields > *:nth-child(9){
    white-space:nowrap!important;
    text-align:right!important;
  }
}

/* Desktop hẹp 1100–1279: dùng 2 hàng CỐ ĐỊNH, không wrap ngẫu nhiên */
@media (min-width:1100px) and (max-width:1279px){

  .order-dialog-content .v303-order-line-fields{
    display:grid!important;
    grid-template-columns:
      minmax(180px,1.5fr)
      minmax(100px,.7fr)
      minmax(100px,.7fr)
      minmax(180px,1.25fr)
      minmax(100px,.7fr)!important;
    gap:10px!important;
    align-items:end!important;
    width:100%!important;
    min-width:0!important;
  }

  .order-dialog-content .v303-order-line-fields > *{
    width:auto!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
  }

  /* Hàng 1: SP | SL | ĐVT | NCC | VAT nhập */
  .order-dialog-content .v303-order-line-fields > *:nth-child(1){grid-column:1;grid-row:1}
  .order-dialog-content .v303-order-line-fields > *:nth-child(2){grid-column:2;grid-row:1}
  .order-dialog-content .v303-order-line-fields > *:nth-child(3){grid-column:3;grid-row:1}
  .order-dialog-content .v303-order-line-fields > *:nth-child(4){grid-column:4;grid-row:1}
  .order-dialog-content .v303-order-line-fields > *:nth-child(5){grid-column:5;grid-row:1}

  /* Hàng 2: Giá nhập | Giá bán | VAT bán | Thành tiền | Xóa */
  .order-dialog-content .v303-order-line-fields > *:nth-child(6){grid-column:1;grid-row:2}
  .order-dialog-content .v303-order-line-fields > *:nth-child(7){grid-column:2;grid-row:2}
  .order-dialog-content .v303-order-line-fields > *:nth-child(8){grid-column:3;grid-row:2}
  .order-dialog-content .v303-order-line-fields > *:nth-child(9){grid-column:4;grid-row:2;text-align:right}
  .order-dialog-content .v303-order-line-fields > *:nth-child(10){
    grid-column:5;grid-row:2;
    width:34px!important;
    justify-self:end!important;
    align-self:end!important;
  }

  .order-dialog-content .v303-order-line-fields input,
  .order-dialog-content .v303-order-line-fields select,
  .order-dialog-content .v303-order-line-fields [data-slot="select-trigger"]{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
  }
}

/* Large desktop / 2K / ultrawide: tận dụng thêm không gian tên SP và NCC */
@media (min-width:1920px){
  .order-dialog-content .v303-order-line-fields{
    grid-template-columns:
      minmax(240px,1.6fr)
      110px
      110px
      minmax(210px,1.25fr)
      110px
      145px
      145px
      120px
      145px
      36px!important;
    gap:10px!important;
  }
}

/* Mobile giữ nguyên giao diện đã có */
@media (max-width:1099px){
  .order-dialog-content .v303-order-line-fields{
    min-width:0!important;
  }
}
