/* Quality ERP - Equipment Management UI Standard V1.6.0
   Scope: equipment_master blueprint only.
   Purpose: standardize equipment-management UI without affecting other ERP modules. */

body.equipment-module {
  /* Main action buttons */
  --eq-btn-font-size: 14px;
  --eq-btn-font-weight: 700;
  --eq-btn-height: 38px;
  --eq-btn-radius: 8px;
  --eq-btn-pad-x: 14px;
  --eq-btn-gap: 8px;

  /* Small/table action buttons */
  --eq-btn-sm-font-size: 13px;
  --eq-btn-sm-height: 32px;
  --eq-btn-sm-pad-x: 10px;

  /* Forms */
  --eq-control-font-size: 14px;
  --eq-control-height: 42px;
  --eq-control-radius: 8px;
  --eq-control-pad-x: 11px;
  --eq-label-font-size: 13px;

  /* Typography */
  --eq-page-title-size: 24px;
  --eq-page-desc-size: 13px;
  --eq-section-title-size: 18px;
  --eq-card-title-size: 17px;
  --eq-help-size: 13px;

  /* Tables */
  --eq-table-head-pad-y: 11px;
  --eq-table-body-pad-y: 10px;
}

/* ------------------------------------------------------------------
   1. MAIN ACTION BUTTONS
   Includes legacy/new equipment page-specific button class names.
   ------------------------------------------------------------------ */
body.equipment-module :is(
  .btn,
  .d-btn,
  .f-btn,
  .h-btn,
  .action-btn,
  .cm-btn,
  .cr-btn,
  .tm-btn,
  .pv-btn,
  .car-btn,
  .cd-btn,
  .cf-btn,
  .tr-btn,
  .ch-btn,
  .ct-btn,
  .it-btn,
  .ext-btn,
  .history-btn,
  .rc-btn,
  .repair-btn,
  .iv-inner-tabs a,
  .iv-tabs a,
  button.btn,
  a.btn
) {
  box-sizing: border-box;
  min-height: var(--eq-btn-height) !important;
  height: var(--eq-btn-height) !important;
  padding: 0 var(--eq-btn-pad-x) !important;
  border-radius: var(--eq-btn-radius) !important;
  font-size: var(--eq-btn-font-size) !important;
  font-weight: var(--eq-btn-font-weight) !important;
  line-height: 1.2 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Buttons made intentionally large in the calibration extension panel
   are brought back to the same equipment standard. */
body.equipment-module .ext-btn {
  min-height: var(--eq-btn-height) !important;
  height: var(--eq-btn-height) !important;
  font-size: var(--eq-btn-font-size) !important;
  padding-inline: var(--eq-btn-pad-x) !important;
}

/* Action groups */
body.equipment-module :is(
  .iv-inner-tabs,
  .iv-tabs,
  .header-actions,
  .page-actions,
  .d-actions,
  .f-actions,
  .cr-actions,
  .cr-footer-actions,
  .cm-actions,
  .tm-actions,
  .pv-actions,
  .car-actions,
  .cd-actions,
  .cf-actions
) {
  gap: var(--eq-btn-gap) !important;
}

/* ------------------------------------------------------------------
   2. SMALL/TABLE/ATTACHMENT BUTTONS
   Keep compact controls compact rather than forcing 38px everywhere.
   ------------------------------------------------------------------ */
body.equipment-module :is(
  table .btn,
  table .d-btn,
  table .cm-btn,
  table .cr-btn,
  table .tm-btn,
  table .tr-btn,
  table .ch-btn,
  table .ct-btn,
  table .it-btn,
  .iv-table .btn,
  .eq-attach-btn,
  .attachment-actions .btn,
  .file-actions .btn,
  .btn.audit,
  .btn.danger
) {
  min-height: var(--eq-btn-sm-height) !important;
  height: var(--eq-btn-sm-height) !important;
  padding: 0 var(--eq-btn-sm-pad-x) !important;
  font-size: var(--eq-btn-sm-font-size) !important;
  border-radius: 7px !important;
}

/* ------------------------------------------------------------------
   3. FORM CONTROLS
   Standard input/select height; textarea remains content-driven.
   Checkbox/radio/file are excluded.
   ------------------------------------------------------------------ */
body.equipment-module :is(
  .cm-field,
  .cr-field,
  .tm-field,
  .car-field,
  .iv-field,
  .rc-field,
  .cf-field,
  .ext-grid
) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  select
),
body.equipment-module form :is(
  input.form-control:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  select.form-control
) {
  box-sizing: border-box;
  min-height: var(--eq-control-height) !important;
  height: var(--eq-control-height) !important;
  padding: 0 var(--eq-control-pad-x) !important;
  border-radius: var(--eq-control-radius) !important;
  font-size: var(--eq-control-font-size) !important;
  line-height: 1.25 !important;
}

body.equipment-module :is(
  .cm-field,
  .cr-field,
  .tm-field,
  .car-field,
  .iv-field,
  .rc-field,
  .cf-field,
  .ext-grid
) textarea {
  box-sizing: border-box;
  padding: 10px 11px !important;
  border-radius: var(--eq-control-radius) !important;
  font-size: var(--eq-control-font-size) !important;
  line-height: 1.5 !important;
}

body.equipment-module :is(
  .cm-field,
  .cr-field,
  .tm-field,
  .car-field,
  .iv-field,
  .rc-field,
  .cf-field,
  .ext-grid
) label {
  font-size: var(--eq-label-font-size) !important;
  line-height: 1.35;
}

/* File inputs keep browser-native layout but use common text size. */
body.equipment-module input[type="file"] {
  font-size: 13px !important;
}

/* ------------------------------------------------------------------
   4. PAGE / SECTION TYPOGRAPHY
   ------------------------------------------------------------------ */
body.equipment-module :is(
  .cm-title h1,
  .cr-title h1,
  .page-title h1,
  .header-title h1
) {
  font-size: var(--eq-page-title-size) !important;
  line-height: 1.25 !important;
}

body.equipment-module :is(
  .cm-title p,
  .cr-title p,
  .page-title p,
  .header-title p
) {
  font-size: var(--eq-page-desc-size) !important;
  line-height: 1.5 !important;
}

body.equipment-module :is(
  .cm-section-title h2,
  .cr-section-title h2,
  .section-title h2,
  .tm-card > h2
) {
  font-size: var(--eq-section-title-size) !important;
  line-height: 1.3 !important;
}

body.equipment-module :is(
  .cd-card h2,
  .d-card h3,
  .card-title,
  .panel-title
) {
  font-size: var(--eq-card-title-size) !important;
  line-height: 1.35 !important;
}

body.equipment-module :is(
  .cm-section-title p,
  .cr-section-title p,
  .help-text,
  .field-help,
  .guide-text
) {
  font-size: var(--eq-help-size) !important;
  line-height: 1.5 !important;
}

/* ------------------------------------------------------------------
   5. TABLE SPACING / ALIGNMENT
   Font size is intentionally NOT forced here. Each equipment page keeps
   its original table typography so dense screens do not break.
   ------------------------------------------------------------------ */
body.equipment-module table:not(.no-equipment-standard) th {
  line-height: 1.3 !important;
  vertical-align: middle !important;
}

body.equipment-module table:not(.no-equipment-standard) td {
  line-height: 1.35 !important;
  vertical-align: middle !important;
}

body.equipment-module :is(
  .cm-table,
  .cr-table,
  .tm-table,
  .tr-table,
  .ch-table,
  .ct-table,
  .it-table,
  .iv-table,
  .history-table,
  .eq-attach-table
) th {
  padding-top: var(--eq-table-head-pad-y) !important;
  padding-bottom: var(--eq-table-head-pad-y) !important;
}

body.equipment-module :is(
  .cm-table,
  .cr-table,
  .tm-table,
  .tr-table,
  .ch-table,
  .ct-table,
  .it-table,
  .iv-table,
  .history-table,
  .eq-attach-table
) td {
  padding-top: var(--eq-table-body-pad-y) !important;
  padding-bottom: var(--eq-table-body-pad-y) !important;
}


/* ------------------------------------------------------------------
   5-1. LIST TABLE WRAPPING POLICY
   Restore each page's original font size. Only operational list tables
   are protected from accidental line wrapping introduced by font-size
   changes. Report/data-entry tables (.cr-table/.pv-table etc.) keep
   their own wrapping rules.
   ------------------------------------------------------------------ */
body.equipment-module :is(
  .iv-table,
  .history-table,
  .ch-table,
  .ct-table,
  .it-table,
  .tr-table,
  .eq-attach-table
) :is(th,td) {
  white-space: nowrap;
}

/* Long text cells may opt back into wrapping where the page already
   uses one of these semantic helpers. */
body.equipment-module :is(
  .wrap,
  .allow-wrap,
  .cell-wrap,
  .text-wrap,
  .description-cell,
  .reason-cell,
  .memo-cell
) {
  white-space: normal !important;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------
   6. STATUS BADGES
   ------------------------------------------------------------------ */
body.equipment-module :is(.badge,.status-badge,.pill) {
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
}

/* ------------------------------------------------------------------
   7. MODAL / PANEL HEADER CONTROLS
   ------------------------------------------------------------------ */
body.equipment-module :is(.cm-modal-close,.modal-close,.panel-close) {
  width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  font-size: 20px !important;
}

/* The calibration exception side-panel used 48px controls; normalize
   while preserving native date picker behavior. */
body.equipment-module .ext-grid :is(input:not([type="checkbox"]),select) {
  min-height: var(--eq-control-height) !important;
  height: var(--eq-control-height) !important;
  font-size: var(--eq-control-font-size) !important;
  padding-inline: var(--eq-control-pad-x) !important;
}
body.equipment-module .ext-grid input[type="date"] {
  height: var(--eq-control-height) !important;
}

/* ------------------------------------------------------------------
   8. TABULATOR / RESPONSIVE
   Table engine has its own detailed standard file; only preserve
   equipment font consistency here.
   ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  body.equipment-module {
    --eq-btn-pad-x: 12px;
    --eq-control-pad-x: 10px;
  }
}
