/* FITPLAN V808 - Builder overflow fix + Super Admin release.
   Loaded after V807. Keeps the builder inside its card and prevents nested history
   tables from inheriting the main exercise-table column widths. */

/* Main V702 builder table: 9 content columns. Actions are rendered in the detail row. */
#builder .draft-excel-wrap-v702{
  width:100%!important;
  max-width:100%!important;
  overflow-x:auto!important;
  overflow-y:visible!important;
  padding-bottom:6px!important;
}
#builder .draft-excel-table-v702{
  width:100%!important;
  min-width:1120px!important;
  table-layout:fixed!important;
}
#builder .draft-excel-table-v702 > thead > tr > th,
#builder .draft-excel-table-v702 > tbody > tr.main-row > td{
  box-sizing:border-box!important;
  overflow:visible!important;
}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(1),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(1){width:4%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(2),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(2){width:12%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(3),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(3){width:27%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(4),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(4){width:7%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(5),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(5){width:9%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(6),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(6){width:8%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(7),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(7){width:9%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(8),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(8){width:10%!important;min-width:0!important}
#builder .draft-excel-table-v702 > thead > tr > th:nth-child(9),
#builder .draft-excel-table-v702 > tbody > tr.main-row > td:nth-child(9){width:14%!important;min-width:0!important}

/* The V808 action strip lives under the row, beside progression/running controls. */
#builder .draft-excel-table-v702 tr.draft-subrow-v702 > td[colspan]{
  width:auto!important;
  min-width:0!important;
  max-width:none!important;
  overflow:visible!important;
}
#builder .draft-row-mini-v702{
  align-items:flex-end!important;
}
#builder .draft-actions-strip-v808{
  margin-left:auto!important;
  display:grid!important;
  gap:6px!important;
  min-width:min(100%,390px)!important;
  max-width:100%!important;
}
#builder .draft-actions-strip-v808 > .mini-label{
  display:block!important;
  color:var(--theme-muted)!important;
}
.coach-ux-v769 #builder .draft-actions-strip-v808 .draft-table-actions,
#builder .draft-actions-strip-v808 .draft-table-actions{
  display:grid!important;
  grid-template-columns:repeat(5,minmax(58px,1fr))!important;
  gap:7px!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  padding:0!important;
  border:0!important;
  background:transparent!important;
  overflow:visible!important;
}
.coach-ux-v769 #builder .draft-actions-strip-v808 .draft-table-actions .btn,
#builder .draft-actions-strip-v808 .draft-table-actions .btn{
  width:100%!important;
  min-width:0!important;
  max-width:none!important;
  height:38px!important;
  min-height:38px!important;
  padding:0 8px!important;
  border-radius:10px!important;
  overflow:visible!important;
  white-space:nowrap!important;
}

/* Critical V808 fix: nested history table must NOT inherit nth-child widths from the
   outer exercise table. This was the cause of the row spilling out of the popover. */
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743{
  width:min(540px,calc(100vw - 72px))!important;
  max-width:min(540px,calc(100vw - 72px))!important;
  max-height:360px!important;
  overflow:auto!important;
  box-sizing:border-box!important;
  z-index:500!important;
}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table{
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  table-layout:auto!important;
  border-collapse:collapse!important;
}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th,
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td{
  width:auto!important;
  min-width:0!important;
  max-width:none!important;
  padding:7px 6px!important;
  overflow-wrap:anywhere!important;
  white-space:normal!important;
}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th:nth-child(1),
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td:nth-child(1){width:17%!important}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th:nth-child(2),
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td:nth-child(2){width:37%!important}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th:nth-child(3),
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td:nth-child(3){width:10%!important}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th:nth-child(4),
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td:nth-child(4){width:14%!important}
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table th:nth-child(5),
#builder .draft-excel-table-v702 .draft-ex-history-popover-v743 table td:nth-child(5){width:22%!important}
#builder .draft-excel-table-v702 .draft-ex-history-loadbar-v743{
  width:100%!important;
  max-width:100%!important;
}

@media(max-width:1180px){
  #builder .draft-excel-table-v702{min-width:980px!important}
  #builder .draft-actions-strip-v808{margin-left:0!important;min-width:100%!important}
}
@media(max-width:760px){
  #builder .draft-excel-table-v702{min-width:900px!important}
  .coach-ux-v769 #builder .draft-actions-strip-v808 .draft-table-actions,
  #builder .draft-actions-strip-v808 .draft-table-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  #builder .draft-actions-strip-v808 .draft-table-actions .btn:last-child{grid-column:1/-1!important}
  #builder .draft-excel-table-v702 .draft-ex-history-popover-v743{
    position:static!important;
    width:100%!important;
    max-width:100%!important;
    margin-top:8px!important;
  }
}
