
/* V305 — Làm lại sạch bố cục sản phẩm trong Tạo/Sửa đơn.
   Mục tiêu chính: 1920x1080 + Windows Scale 125%.
   Không để tổng width cột vượt form; toàn hàng luôn vừa 100%.
*/

/* Desktop chung */
@media (min-width:1100px){

  .order-dialog-content{
    width:96vw!important;
    max-width:96vw!important;
  }

  .order-dialog-content .order-dialog-body{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
  }

  .order-dialog-content .v303-order-line-fields{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    display:grid!important;
    align-items:end!important;
    overflow:visible!important;
  }

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

  .order-dialog-content .v303-order-line-fields [data-slot="select-value"],
  .order-dialog-content .v303-order-line-fields [class*="truncate"]{
    min-width:0!important;
    max-width:100%!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }

  .order-dialog-content .v303-order-line-fields > *:nth-child(9){
    white-space:nowrap!important;
    text-align:right!important;
  }

  .order-dialog-content .v303-order-line-fields > button:last-child{
    width:32px!important;
    min-width:32px!important;
    max-width:32px!important;
    height:32px!important;
    justify-self:end!important;
  }

  /* Popup tìm/tạo sản phẩm rộng theo desktop */
  .v305-order-product-search-popover{
    width:min(46vw,760px)!important;
    max-width:min(46vw,760px)!important;
    min-width:520px!important;
  }

  .v305-order-products-toolbar{
    width:100%!important;
    min-width:0!important;
  }
}

/* 1100–1279: 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{
    grid-template-columns:
      minmax(0,2.1fr)
      minmax(0,.85fr)
      minmax(0,.85fr)
      minmax(0,1.55fr)
      minmax(0,.8fr)!important;
    gap:10px!important;
  }

  .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}

  .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}
  .order-dialog-content .v303-order-line-fields > *:nth-child(10){grid-column:5;grid-row:2}
}

/* 1280–1599:
   Đây là vùng quan trọng cho 1920x1080 + Scale 125%.
   Tất cả 10 cột vừa đúng 100%, không bị cắt bên phải. */
@media (min-width:1280px) and (max-width:1599px){
  .order-dialog-content .v303-order-line-fields{
    grid-template-columns:
      minmax(0,2.55fr)  /* Sản phẩm */
      minmax(0,.76fr)   /* Số lượng */
      minmax(0,.76fr)   /* ĐVT */
      minmax(0,1.55fr)  /* NCC */
      minmax(0,.78fr)   /* VAT nhập */
      minmax(0,1.02fr)  /* Giá nhập */
      minmax(0,1.02fr)  /* Giá bán */
      minmax(0,.82fr)   /* VAT bán */
      minmax(0,1.05fr)  /* Thành tiền */
      34px!important;   /* Xóa */
    column-gap:10px!important;
    row-gap:8px!important;
  }

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

  .order-dialog-content .v303-order-line-fields > *:nth-child(4){
    min-width:0!important;
  }
}

/* Desktop rộng 1600–2199 */
@media (min-width:1600px) and (max-width:2199px){
  .order-dialog-content .v303-order-line-fields{
    grid-template-columns:
      minmax(0,2.8fr)
      minmax(0,.78fr)
      minmax(0,.78fr)
      minmax(0,1.75fr)
      minmax(0,.8fr)
      minmax(0,1.05fr)
      minmax(0,1.05fr)
      minmax(0,.85fr)
      minmax(0,1.1fr)
      36px!important;
    column-gap:12px!important;
    row-gap:8px!important;
  }
}

/* 2K / ultrawide */
@media (min-width:2200px){
  .order-dialog-content{
    width:97vw!important;
    max-width:97vw!important;
  }

  .order-dialog-content .v303-order-line-fields{
    grid-template-columns:
      minmax(0,3.1fr)
      minmax(0,.8fr)
      minmax(0,.8fr)
      minmax(0,2fr)
      minmax(0,.82fr)
      minmax(0,1.1fr)
      minmax(0,1.1fr)
      minmax(0,.88fr)
      minmax(0,1.15fr)
      38px!important;
    column-gap:14px!important;
  }

  .v305-order-product-search-popover{
    width:min(40vw,860px)!important;
    max-width:min(40vw,860px)!important;
  }
}

/* Mobile giữ nguyên các bản trước */
@media (max-width:1099px){
  .v305-order-product-search-popover{
    min-width:0!important;
    width:calc(100vw - 24px)!important;
    max-width:calc(100vw - 24px)!important;
  }
}
