/* v706 - Cân lại bố cục form tìm kiếm và các form quản trị cũ.
   Mục tiêu: nhãn không đè lên cột Not/control, control nằm sát đúng nhãn. */

/* 1) Các bảng tìm kiếm kiểu cũ: cột nhãn đủ rộng, cột Not ổn định. */
#data-search table#table1 > tbody > tr > td:first-child,
#data-search table#table1 > tr > td:first-child,
#data-search table[id^="table"] > tbody > tr > td:first-child,
#data-search table[id^="table"] > tr > td:first-child,
#data-search > table.table > tbody > tr > td:first-child,
#data-search > table.table > tr > td:first-child {
  width: 220px !important;
  min-width: 220px !important;
  max-width: 220px !important;
  white-space: normal !important;
  overflow-wrap: normal;
  line-height: 1.35;
  padding-right: 10px !important;
}

#data-search table#table1 > tbody > tr > td:nth-child(2),
#data-search table#table1 > tr > td:nth-child(2),
#data-search table[id^="table"] > tbody > tr > td:nth-child(2),
#data-search table[id^="table"] > tr > td:nth-child(2),
#data-search > table.table > tbody > tr > td:nth-child(2),
#data-search > table.table > tr > td:nth-child(2) {
  width: 64px !important;
  min-width: 64px !important;
  max-width: 64px !important;
  white-space: nowrap !important;
  text-align: center;
  padding-left: 4px !important;
  padding-right: 8px !important;
}

/* Nếu dòng chỉ có label + control thì không ép control thành cột Not. */
#data-search table tr > td:nth-child(2):last-child {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  text-align: left;
}

/* Cặp chọn trường tìm + nội dung tìm luôn nằm cùng một hàng trên desktop. */
#data-search .ntt-search-control-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
#data-search .ntt-search-control-line > select {
  flex: 0 0 180px;
  width: 180px !important;
  min-width: 180px !important;
  margin: 0 !important;
}
#data-search .ntt-search-control-line > input.form-control,
#data-search .ntt-search-control-line > input[type="text"] {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
}

/* 2) addtvmn: không để bảng tự chia 50/50 làm ô nhập chạy sang giữa màn hình. */
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form {
  padding-left: 14px;
  padding-right: 14px;
}
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  box-sizing: border-box;
  table-layout: auto !important;
}
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table > tbody > tr > td:first-child:not([colspan]),
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table > tr > td:first-child:not([colspan]) {
  width: 230px !important;
  min-width: 230px !important;
  max-width: 230px !important;
  padding-right: 12px !important;
  white-space: normal !important;
}
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table > tbody > tr > td:last-child:not(:first-child),
body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table > tr > td:last-child:not(:first-child) {
  width: auto !important;
  min-width: 0 !important;
}
body[data-code="addtvmn"] #data-addchuphong input[name="usnchuphong"],
body[data-code="addtvmn"] #data-addchuphong select[name="thembot"] {
  width: 100% !important;
  max-width: 660px;
}

/* 3) addremoveoldusers: file chiếm cả hàng; label Add/Remove sát select. */
body[data-code="addremoveoldusers"] form.ntt-legacy-form table#table1 {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  box-sizing: border-box;
  table-layout: auto !important;
}
body[data-code="addremoveoldusers"] form.ntt-legacy-form table#table1 > tbody > tr > td:first-child:not([colspan]),
body[data-code="addremoveoldusers"] form.ntt-legacy-form table#table1 > tr > td:first-child:not([colspan]) {
  width: 250px !important;
  min-width: 250px !important;
  max-width: 250px !important;
  padding-right: 12px !important;
  white-space: normal !important;
}
body[data-code="addremoveoldusers"] form.ntt-legacy-form table#table1 td[colspan] {
  width: 100% !important;
  max-width: none !important;
}
body[data-code="addremoveoldusers"] form.ntt-legacy-form select[name="thembot"] {
  width: 100% !important;
  max-width: 420px;
}

@media (max-width: 767px) {
  #data-search table#table1 > tbody > tr > td:first-child,
  #data-search table#table1 > tr > td:first-child,
  #data-search table[id^="table"] > tbody > tr > td:first-child,
  #data-search table[id^="table"] > tr > td:first-child,
  #data-search > table.table > tbody > tr > td:first-child,
  #data-search > table.table > tr > td:first-child,
  #data-search table#table1 > tbody > tr > td:nth-child(2),
  #data-search table#table1 > tr > td:nth-child(2),
  #data-search table[id^="table"] > tbody > tr > td:nth-child(2),
  #data-search table[id^="table"] > tr > td:nth-child(2) {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    text-align: left;
  }
  #data-search .ntt-search-control-line {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  #data-search .ntt-search-control-line > select {
    width: 100% !important;
    min-width: 0 !important;
  }

  body[data-code="addtvmn"] #data-addchuphong form.ntt-legacy-form .ntt-form-grid-table,
  body[data-code="addremoveoldusers"] form.ntt-legacy-form table#table1 {
    width: 100% !important;
    max-width: 100% !important;
  }
}


/* CODE.NTT v777 - form tìm kiếm: nhãn nằm sát control, không để table tự giãn cột nhãn. */
#data-search > table,
#data-search > table.table{
  width:100% !important;
  table-layout:fixed !important;
}
#data-search > table > tbody > tr > td:first-child,
#data-search > table > tr > td:first-child,
#data-search > table.table > tbody > tr > td:first-child,
#data-search > table.table > tr > td:first-child{
  width:210px !important;
  min-width:210px !important;
  max-width:210px !important;
  padding-right:10px !important;
  white-space:normal !important;
  vertical-align:middle !important;
}
#data-search > table > tbody > tr > td:nth-child(2):not(:last-child),
#data-search > table > tr > td:nth-child(2):not(:last-child),
#data-search > table.table > tbody > tr > td:nth-child(2):not(:last-child),
#data-search > table.table > tr > td:nth-child(2):not(:last-child){
  width:58px !important;
  min-width:58px !important;
  max-width:58px !important;
  padding-left:2px !important;
  padding-right:8px !important;
  text-align:center !important;
  vertical-align:middle !important;
}
#data-search > table > tbody > tr > td:nth-child(3),
#data-search > table > tr > td:nth-child(3),
#data-search > table.table > tbody > tr > td:nth-child(3),
#data-search > table.table > tr > td:nth-child(3){
  width:auto !important;
  min-width:0 !important;
  padding-left:4px !important;
  vertical-align:middle !important;
}
#data-search > table > tbody > tr > td:nth-child(3) > .form-control,
#data-search > table > tr > td:nth-child(3) > .form-control,
#data-search > table > tbody > tr > td:nth-child(3) > input[type="text"],
#data-search > table > tr > td:nth-child(3) > input[type="text"]{
  margin-left:0 !important;
}
@media (max-width:767px){
  #data-search > table,
  #data-search > table.table{
    table-layout:auto !important;
  }
  #data-search > table > tbody > tr > td:first-child,
  #data-search > table > tr > td:first-child,
  #data-search > table > tbody > tr > td:nth-child(2),
  #data-search > table > tr > td:nth-child(2),
  #data-search > table > tbody > tr > td:nth-child(3),
  #data-search > table > tr > td:nth-child(3){
    width:auto !important;
    min-width:0 !important;
    max-width:none !important;
  }
}

/* CODE.NTT v855 - one spacing contract for two-column legacy form grids.
   The common form skin already treats column 1 as the label and column 2 as
   the control. Fixed layout prevents long labels from pushing controls across
   the page (e.g. dsqtweb) while preserving the mobile stacked layout. */
form.ntt-legacy-form .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child),
form.ntt-legacy-form .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child),
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child),
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child){
  table-layout:fixed !important;
}
form.ntt-legacy-form .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child) > tbody > tr > :first-child,
form.ntt-legacy-form .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child) > tr > :first-child,
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child) > tbody > tr > :first-child,
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child) > tr > :first-child{
  width:190px !important;
  min-width:190px !important;
  max-width:190px !important;
  padding-right:12px !important;
  white-space:normal !important;
  vertical-align:middle !important;
}
form.ntt-legacy-form .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child) > tbody > tr > :nth-child(2),
form.ntt-legacy-form .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child) > tr > :nth-child(2),
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tbody > tr:first-child > :nth-child(2):last-child) > tbody > tr > :nth-child(2),
.ntt-legacy-form-shell .ntt-form-grid-table:has(> tr:first-child > :nth-child(2):last-child) > tr > :nth-child(2){
  width:auto !important;
  min-width:0 !important;
}
@media (max-width:767px){
  form.ntt-legacy-form .ntt-form-grid-table,
  .ntt-legacy-form-shell .ntt-form-grid-table{
    table-layout:auto !important;
  }
  form.ntt-legacy-form .ntt-form-grid-table > tbody > tr > :first-child,
  form.ntt-legacy-form .ntt-form-grid-table > tr > :first-child,
  .ntt-legacy-form-shell .ntt-form-grid-table > tbody > tr > :first-child,
  .ntt-legacy-form-shell .ntt-form-grid-table > tr > :first-child{
    width:auto !important;
    min-width:0 !important;
    max-width:none !important;
  }
}
