/*
 * Web layout audit · 20261019r1
 * Load after workbench.css, teacher-workspace.css and page_styles.
 * Presentation only: no role rules, API calls, database changes or hidden data.
 * Do not use body overflow-x:hidden: wide data must remain locally scrollable.
 */

/* Shared shell: let the navigation scroll and content tracks actually shrink. */
.app-body .app-main,
.app-body .app-content,
.app-body .app-content-inner,
.app-body .role-page,
.app-body .workspace-page,
.app-body .admin-content { min-width: 0; }
.app-body .app-nav { min-height: 0; overscroll-behavior: contain; }
.app-body .app-brand,
.app-body .app-nav-bottom { flex-shrink: 0; }
.app-body .app-brand-text { min-width: 0; }
.app-body .app-brand-text strong { overflow-wrap: anywhere; line-height: 1.35; }
.app-body .app-nav-link { min-width: 0; overflow-wrap: anywhere; }
.app-body .app-nav-link i,
.app-body .app-brand-mark,
.app-body .app-user-avatar { flex-shrink: 0; }
.app-body .app-content .row > *,
.app-body .app-content .card,
.app-body .app-content .card-body { min-width: 0; }

/* A header is not a single unbreakable horizontal line. */
.app-body .page-titlebar,
.app-body .workspace-titlebar,
.app-body .config-titlebar { flex-wrap: wrap; }
.app-body .page-titlebar > :first-child,
.app-body .workspace-titlebar > :first-child,
.app-body .config-titlebar > :first-child { flex: 1 1 320px; min-width: 0; }
.app-body .page-titlebar > :not(:first-child),
.app-body .workspace-titlebar > :not(:first-child),
.app-body .config-titlebar > :not(:first-child) { min-width: 0; max-width: 100%; }
.app-body .page-titlebar > .d-flex,
.app-body .workspace-titlebar > .d-flex { flex-wrap: wrap; gap: 8px; }
.app-body .page-titlebar .btn,
.app-body .workspace-titlebar .btn,
.app-body .page-actions .btn,
.app-body .config-actions .btn { white-space: normal; flex-shrink: 0; }
.app-body .page-titlebar h1,
.app-body .page-titlebar h2,
.app-body .workspace-titlebar h1,
.app-body .workspace-titlebar h2 { overflow-wrap: anywhere; }
.app-body .page-titlebar p,
.app-body .workspace-titlebar p { line-height: 1.65; }

/* Panel headings, search forms and toolbars. Explicit opt-in search hooks remove
 * the old 55% / 60% widths without overriding widths of unrelated business forms. */
.app-body .card-header.d-flex,
.app-body .workbench-panel-header,
.app-body .campus-panel-header { flex-wrap: wrap; gap: 10px 14px; }
.app-body .card-header.d-flex > h2,
.app-body .card-header.d-flex > h3,
.app-body .card-header.d-flex > h4,
.app-body .card-header.d-flex > h5 { flex: 1 1 220px; min-width: 0; margin-bottom: 0; }
.app-body .card-header.d-flex > .btn { flex-shrink: 0; }
.app-body .ui-panel-toolbar { gap: 12px 18px; align-items: center; }
.app-body .ui-toolbar-title { flex: 1 1 420px; flex-wrap: wrap; gap: 8px; min-width: 0; }
.app-body .ui-toolbar-title h5 { flex: 1 1 210px; line-height: 1.5; }
.app-body .ui-toolbar-title .btn { margin-left: 0 !important; flex-shrink: 0; }
.app-body .ui-search-form { flex: 1 1 360px; width: auto; min-width: 0; max-width: 100%; }
.app-body .ui-search-form .form-control { flex: 1 1 160px; min-width: 100px; }
.app-body .ui-search-form .btn { flex-shrink: 0; white-space: nowrap; }

/* Parent-width-aware forms. Only marked rows switch from Bootstrap to grid. */
.app-body .ui-filter-grid,
.app-body .ui-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 14px 16px;
  margin: 0;
}
.app-body .ui-field-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.app-body .ui-filter-grid > *,
.app-body .ui-field-grid > * { width: auto; max-width: none; min-width: 0; padding: 0; margin-top: 0; }
.app-body .ui-filter-grid > .ui-filter-full,
.app-body .ui-field-grid > .ui-filter-full,
.app-body .ui-filter-grid > .ui-filter-actions { grid-column: 1 / -1; }
.app-body .ui-filter-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.app-body .ui-filter-actions .btn { flex: 0 0 auto !important; white-space: nowrap; }
.app-body .form-label { font-size: 13px; line-height: 1.5; margin-bottom: 6px; }
.app-body .form-control,
.app-body .form-select { min-width: 0; min-height: 40px; font-size: 14px; }
.app-body .form-control-sm,
.app-body .form-select-sm,
.app-body .input-group-sm > .form-control,
.app-body .input-group-sm > .form-select { min-height: 34px; font-size: 13px; }
.app-body .input-group { min-width: 0; max-width: 100%; }
.app-body .input-group > .form-control,
.app-body .input-group > .form-select { min-width: 0; }
.app-body .input-group-text { font-size: 13px; }
.app-body textarea.form-control { max-width: 100%; resize: vertical; line-height: 1.65; }
.app-body .form-control:disabled,
.app-body .form-select:disabled { color: #778493 !important; background-color: #f0f3f6 !important; opacity: 1; }
.app-body .btn { min-height: 36px; line-height: 1.5; }
.app-body .btn-sm,
.app-body .btn-group-sm > .btn { min-height: 32px; }
.app-body .table .btn { vertical-align: middle; }

/* The classroom switches used Bootstrap's negative float margin after their
 * wrapper replaced the required left padding. Use a contained flex row instead. */
.app-body .classroom-attendance .switch-row.form-check {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; min-height: 44px;
}
.app-body .classroom-attendance .switch-row .form-check-input {
  float: none; flex: 0 0 auto; margin: 3px 0 0;
}
.app-body .classroom-attendance .switch-row .form-check-label {
  margin-left: 0 !important; min-width: 0; line-height: 1.5;
}

/* Keep scrolling on data regions, not on the page. Sticky tables/matrices retain
 * their existing column widths, rather than wrapping every column into a card. */
.app-body .table-responsive,
.app-body .ca-table-wrap,
.app-body .sub-table-scroll { min-width: 0; max-width: 100%; overscroll-behavior-x: contain; }
.app-body .table thead th { font-size: 12px; line-height: 1.5; }
.app-body .ui-schedule-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 4px; }
.app-body .ui-schedule-scroll:focus-visible,
.app-body .table-responsive:focus-visible { outline: 2px solid var(--wb-blue, #2d67a3); outline-offset: 3px; }
.app-body .ui-scroll-hint { line-height: 1.5; }
.app-body .pagination { flex-wrap: wrap; gap: 4px; margin-bottom: 0; }
.app-body .pagination .page-link { min-height: 34px; }

/* Dashboard: eight metrics must not inherit the later seven-column base rule.
 * Wide charts get two tracks; small laptop charts must not be quarter-width. */
.app-body .campus-kpi-grid.operations-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.app-body .campus-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.app-body .campus-dashboard-toolbar { flex-wrap: wrap; align-items: flex-start; }
.app-body .campus-dashboard-toolbar > :first-child { flex: 1 1 280px; min-width: 0; }
.app-body .campus-dashboard-controls { min-width: 0; max-width: 100%; }
.app-body .operations-filter-row {
  flex: 1 1 560px;
  grid-template-columns: auto minmax(120px, 1fr) auto minmax(150px, 1fr) auto;
}
.app-body .campus-chart-panel > header { flex-wrap: wrap; }
.app-body .campus-chart-panel > header > div { min-width: 0; }
.app-body .campus-active-pair { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.app-body .campus-active-item { flex-wrap: wrap; padding: 6px; }
.app-body .campus-active-item span { white-space: normal; }
.app-body .campus-kpi strong,
.app-body .workbench-stat-value,
.app-body #adminStudentOnlineCount { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.app-body #adminStudentOnlinePanel .btn-group { flex-shrink: 0; }
.app-body #adminStudentOnlinePanel .btn-group .btn { white-space: nowrap; }
.app-body #adminStudentOnlinePanel .row.g-3 { align-items: start !important; }
.app-body #adminStudentOnlinePanel .col-md-3 .h-100 { height: auto !important; }

/* Subscription filters must respond to the usable content width, not seven
 * tracks squeezed between a fixed sidebar and large panel paddings. */
.app-body .sub-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.app-body .sub-fields.sub-user-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-body .sub-user-fields .wide,
.app-body .sub-user-fields .sub-class-field { grid-column: 1 / -1; }
.app-body .sub-user-fields .sub-department-field { grid-column: auto; }
.app-body .sc-hero,
.app-body .sub-section-head,
.app-body .sc-savebar,
.app-body .sc-foot { flex-wrap: wrap; }
.app-body .sc-savebar > div { display: flex; flex-wrap: wrap; gap: 8px; }

/* Resume field configuration: the preview must remain reachable when the fixed
 * sidebar leaves less space than the old 290+370+420 minimum three-track layout. */
.app-body .resume-config-page .config-shell {
  grid-template-columns: minmax(220px, .8fr) minmax(280px, 1fr) minmax(340px, 1.2fr);
}
.app-body .resume-config-page .preview-panel { min-width: 0; }
.app-body .resume-config-page .config-actions { justify-content: flex-start; }

/* Forms that serve one person should not be only half of the already-narrow
 * content column on a 1024px screen. Keep comfortable, bounded reading widths. */
.app-body .role-page-student > .row.justify-content-center > [class*="col-"] {
  width: 100%; max-width: 760px;
}
.app-body .public-main > .row { margin-left: 0; margin-right: 0; }
.app-body .ui-auth-shell { margin: 0 !important; padding: 40px 16px; }
.app-body .ui-auth-shell > [class*="col-"] { width: 100%; max-width: 560px; }

/* One layer order for every role, instead of teacher-specific competing values.
 * Existing SweetAlert dialogs deliberately keep their own higher 20000 layer. */
body.app-body .dropdown-menu { z-index: 1060; max-width: calc(100vw - 24px); }
body.app-body .offcanvas-backdrop { z-index: 1065 !important; }
body.app-body .offcanvas { z-index: 1070 !important; max-width: calc(100vw - 24px); }
body.app-body .modal-backdrop { z-index: 1080 !important; }
body.app-body .modal { z-index: 1085 !important; }
.app-body .modal-header { align-items: flex-start; gap: 12px; }
.app-body .modal-header .btn-close { flex-shrink: 0; }
.app-body .modal-title { line-height: 1.5; overflow-wrap: anywhere; }
.app-body .modal-footer { gap: 8px; }
.app-body .modal-footer > * { margin: 0; }
.app-body .modal-dialog-scrollable .modal-body { overscroll-behavior: contain; }
.app-body .modal input,
.app-body .modal select,
.app-body .modal textarea { max-width: 100%; }

@media (min-width: 1800px) {
  .app-body .campus-kpi-grid.operations-kpi-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .app-body .campus-chart-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1439.98px) {
  .app-body .resume-config-page .config-shell { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
  .app-body .resume-config-page .preview-panel { grid-column: 1 / -1; border-top: 1px solid var(--wb-line); }
}
@media (max-width: 1199.98px) {
  .app-body .sub-fields.sub-user-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-body #adminStudentOnlinePanel .col-md-3 { width: 34%; }
  .app-body #adminStudentOnlinePanel .col-md-9 { width: 66%; }
}
@media (max-width: 991.98px) {
  /* Earlier workspace CSS makes these column headers; reset desktop flex bases. */
  .app-body .page-titlebar > :first-child,
  .app-body .workspace-titlebar > :first-child,
  .app-body .config-titlebar > :first-child { flex-basis: auto; width: 100%; }
  .app-body .page-titlebar > :not(:first-child),
  .app-body .workspace-titlebar > :not(:first-child) { max-width: 100%; }
}
@media (max-width: 767.98px) {
  .app-body .page-heading > .col,
  .app-body .page-heading > .col-auto { flex: 0 0 100%; width: 100%; }
  .app-body .page-heading > .col-auto { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .app-body .page-heading > .col-auto .btn { margin-right: 0 !important; }
  .app-body .campus-kpi-grid.operations-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-body .campus-chart-grid { grid-template-columns: minmax(0, 1fr); }
  .app-body .campus-chart-panel-wide { grid-column: auto; }
  .app-body .campus-dashboard-toolbar > :first-child { flex-basis: auto; width: 100%; }
  .app-body .operations-filter-row { flex-basis: auto; width: 100%; grid-template-columns: auto minmax(0, 1fr); }
  .app-body .operations-filter-row .btn { grid-column: 1 / -1; }
  .app-body #adminStudentOnlinePanel .col-md-3,
  .app-body #adminStudentOnlinePanel .col-md-9 { width: 100%; }
  .app-body .resume-config-page .config-shell { grid-template-columns: minmax(0, 1fr); }
  .app-body .resume-config-page .field-panel,
  .app-body .resume-config-page .property-panel { border-right: 0; border-bottom: 1px solid var(--wb-line); }
  .app-body .sub-fields.sub-user-fields { grid-template-columns: minmax(0, 1fr); }
  .app-body .sub-fields .wide { grid-column: 1 / -1; }
  .app-body .classroom-attendance .attendance-form-card { position: static; }
}
@media (max-width: 575.98px) {
  .app-body .ui-search-form { flex-basis: 100%; }
  .app-body .ui-search-form .btn { padding-left: 12px !important; padding-right: 12px !important; }
  .app-body .ui-filter-grid,
  .app-body .ui-field-grid { grid-template-columns: minmax(0, 1fr); }
  .app-body .ui-filter-actions { justify-content: flex-start; }
  .app-body .ui-filter-actions .btn { flex: 1 1 auto !important; }
  .app-body .ui-auth-shell { padding: 24px 4px; }
  .app-body .ui-auth-shell .card { padding: 16px !important; }
  .app-body .ui-auth-shell .card-body { padding: 12px; }
  .app-body .admin-impersonation-banner { flex-wrap: wrap; gap: 8px; }
  .app-body .modal .modal-dialog:not(.modal-fullscreen) { margin: 12px; }
  .app-body .dropdown-menu { min-width: min(10rem, calc(100vw - 24px)); }
}
@media (max-width: 359.98px) {
  .app-body .campus-kpi-grid.operations-kpi-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .app-body .app-nav-link,
  .app-body .module-card,
  .app-body .campus-kpi { transition: none; }
}

/* Page-specific controls that cannot inherit a percentage-based flex width. */
.app-body .ui-section-toolbar { flex-wrap: wrap; gap: 12px; }
.app-body .ui-section-toolbar > :first-child { flex: 1 1 320px; min-width: 0; }
.app-body .ui-section-toolbar > .btn { flex-shrink: 0; white-space: nowrap; }
.app-body .ui-invite-input > .form-control { flex: 1 1 180px; width: auto; }
.app-body .ui-invite-input > .btn { flex: 1 0 auto; margin-left: 0 !important; }
.app-body .ad-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px; margin: 0; }
.app-body .ad-row > [class*="col-"] { width: auto; min-width: 0; max-width: none; margin-top: 0; }
.app-body .ui-modal-form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.app-body .ui-modal-form > .modal-body { min-height: 0; }

/* A populated class roster needs room for three actions beside its metadata.
 * Collapse before the fixed sidebar makes the desktop tracks overflow. */
.app-body .class-detail-page .student-row > * { min-width: 0; }
.app-body .class-detail-page .student-account { overflow-wrap: anywhere; }
.app-body .class-detail-page .student-actions { flex-wrap: wrap; }
@media (max-width: 1199.98px) {
  .app-body .class-detail-page .student-panel-header { flex-wrap: wrap; }
  .app-body .class-detail-page .student-row { grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 16px 8px; }
  .app-body .class-detail-page .student-meta { grid-column: 1 / -1; padding-left: 42px; }
  .app-body .class-detail-page .student-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 42px; }
}
/* The roster's old white-button override otherwise leaves primary text white
 * on white, hiding the “完整档案” action even when the layout itself fits. */
.app-body .class-detail-page .student-actions .btn-primary {
  color: #fff !important;
  background-color: var(--wb-blue, #2d67a3) !important;
  border-color: var(--wb-blue, #2d67a3) !important;
}

/* Dense account/order tables keep readable tracks instead of squeezing a name
 * between badges. Their existing responsive wrappers own horizontal scrolling. */
.app-body .ui-account-table { min-width: 1120px; }
.app-body .ui-account-table td:nth-child(2) { min-width: 240px; max-width: 320px; }
.app-body .ui-account-table td:nth-child(3) { min-width: 220px; max-width: 320px; }
.app-body .ui-account-table td:last-child { min-width: 280px; white-space: normal; }
.app-body .ui-account-name { flex-wrap: wrap; gap: 4px; line-height: 1.5; }
.app-body .ui-account-table td:nth-child(2) .font-monospace { overflow-wrap: anywhere; }
.app-body .ui-account-table td:nth-child(3) .badge { white-space: normal; line-height: 1.5; }
.app-body .ui-order-table { min-width: 960px; }
.app-body .ui-order-table td:first-child { min-width: 260px; max-width: 340px; overflow-wrap: anywhere; }
.app-body .ui-order-table td:nth-child(2) { min-width: 220px; max-width: 280px; overflow-wrap: anywhere; }

/* Retain cyan/amber intent with readable resting labels on light panels. */
.app-body .btn-outline-info:not(:hover):not(:active):not(.active):not(:disabled) { color: #073b49 !important; }
.app-body .btn-outline-warning:not(:hover):not(:active):not(.active):not(:disabled) { color: #805400 !important; }
.app-body .btn-info.text-white { background-color: #08768c !important; border-color: #08768c !important; }
