/* ui-kit.css -- T+ 18.0 UI component layer
 *
 * Scope: toolbar / grid / (later) dialog / voucher / list-page.
 * All tokens carry a fallback value because app/web/css/base.css is owned by
 * another developer and may not define them yet. Example:
 *     var(--tj-red, #e8483e)
 *
 * Token values come from spec/css/tokens-meas.json (22 browser-measured tokens)
 * and docs/design/UI-SPEC.md.
 *
 * ASCII-only comments in code files; this CSS uses ASCII comments too so that
 * any tool with non-UTF8 default encoding cannot corrupt it.
 */

/* ==========================================================================
 * 1. Token defaults
 * Values are from UI-SPEC v2 (VM-measured) unless noted. v1 values that were
 * only screenshot-estimated have been replaced; see docs/design/UI-SPEC-v2.md
 * section 0 for the correction table.
 *
 * Note: real T+ hard-codes all colours and defines zero custom properties, so
 * these variables are only our internal organisation. What matters for
 * acceptance is the final computed value, not the variable name.
 * ========================================================================== */
.tj-toolbar,
.tj-grid-wrap {
  /* brand */
  --tj-red: #e8483e;
  --tj-red-dark: #d13a30;
  --brand-red: rgb(254, 81, 87);
  --tj-blue: #2b7de1;

  /* text */
  --text-1: rgb(51, 51, 51);
  --text-2: rgb(153, 153, 153);
  --text-3: #999999;

  /* borders: measured 204, not the v1 guess of #e8e8e8 */
  --border: rgb(204, 204, 204);
  --border-strong: rgb(204, 204, 204);

  /* toolbar tokens (v2 measured: fontSize 14px, padding 0 10px) */
  --tb-h: 30px;
  --tb-item-h: 30px;
  --tb-item-fs: 14px;
  --tb-item-fg: rgb(51, 51, 51);
  --tb-item-lh: 30px;
  --tb-item-pad: 0 10px;
  --tb-item-w: 42px;
  --tb-sep-color: rgb(226, 226, 226);
  --tb-group-margin: 0 20px 0 10px;

  /* grid tokens (v2 measured) */
  --grid-th-bg: rgb(232, 232, 232);
  --grid-th-color: rgb(0, 0, 0);
  --grid-th-fs: 13px;
  --grid-th-fw: 700;
  --grid-th-lh: 14px;
  --grid-th-h: 30px;
  --grid-td-fs: 13px;
  --grid-td-h: 28px;
  --grid-td-pad: 5px;
  --grid-td-color: rgb(0, 0, 0);
  --grid-total-bg: rgb(245, 245, 245);
  --grid-total-fs: 14px;
  --grid-total-fg: rgb(51, 51, 51);

  /* font */
  --font: Arial, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Helvetica, sans-serif;
}

/* ==========================================================================
 * 2. Toolbar (UI-SPEC v2 section 5)
 *   item: height 30 / line-height 30 / padding 0 10px / content-box / width 42
 *         -> real footprint 62px (42 + 10 + 10)
 *   group: margin 0 20px 0 10px
 *   separator: a REAL "|" character coloured rgb(226,226,226), not a border
 * ========================================================================== */
.tj-toolbar {
  /* container is 31px total = 30px content + 1px bottom border */
  height: var(--tb-h, 30px);
  box-sizing: content-box;
  display: flex;
  align-items: center;
  padding: 0 0 0 10px;
  background: rgb(255, 255, 255);
  border-bottom: 1px solid var(--border, rgb(204, 204, 204));
  font-family: var(--font, Arial, "Microsoft YaHei", sans-serif);
  overflow: visible;
}

/* one logical group of buttons; measured margin 0 20px 0 10px */
.tj-tb-group {
  display: inline-flex;
  align-items: center;
  margin: var(--tb-group-margin, 0 20px 0 10px);
}

.tj-tb-item {
  position: relative;
  height: var(--tb-item-h, 30px);
  line-height: var(--tb-item-lh, 30px);
  padding: var(--tb-item-pad, 0 10px);
  /* content-box + width 42 makes the real footprint 62px, matching T+ */
  box-sizing: content-box;
  width: var(--tb-item-w, 42px);
  font-size: var(--tb-item-fs, 14px);
  font-family: inherit;
  color: var(--tb-item-fg, rgb(51, 51, 51));
  background: transparent;
  border: 0;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  overflow: visible;
}

.tj-tb-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.tj-tb-item:active,
.tj-tb-item.tj-open {
  background: rgba(0, 0, 0, 0.07);
}

.tj-tb-item:disabled {
  color: var(--text-2, rgb(153, 153, 153));
  cursor: default;
  background: transparent;
}

.tj-tb-text {
  pointer-events: none;
}

/* dropdown caret: pure CSS triangle (no ticon font available).
   Size/colour follow the measured ticon-down (14px glyph, rgb(51,51,51)). */
.tj-tb-caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 3px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgb(51, 51, 51);
  pointer-events: none;
}

.tj-tb-item:disabled .tj-tb-caret {
  border-top-color: var(--text-2, rgb(153, 153, 153));
}

/* separator: a real "|" character with the same item padding, colour measured
   at rgb(226,226,226). Do NOT implement as border-left (that renders 1px and
   is visually too thin compared with the real glyph). */
.tj-tb-sep {
  display: inline-block;
  height: var(--tb-item-h, 30px);
  line-height: var(--tb-item-lh, 30px);
  padding: var(--tb-item-pad, 0 10px);
  box-sizing: content-box;
  font-size: var(--tb-item-fs, 14px);
  color: var(--tb-sep-color, rgb(226, 226, 226));
  user-select: none;
  cursor: default;
}

/* dropdown */
.tj-tb-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 132px;
  padding: 4px 0;
  margin-top: 1px;
  background: #fff;
  border: 1px solid var(--border-strong, #d0d4da);
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  line-height: normal;
}

.tj-tb-dropdown-item {
  height: 26px;
  line-height: 26px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-1, #333333);
  cursor: pointer;
  white-space: nowrap;
}

.tj-tb-dropdown-item:hover {
  background: #f0f1f3;
  color: var(--tj-red, #e8483e);
}

/* ==========================================================================
 * 3. Data grid (UI-SPEC v2 section 7, VM measured on CS06 list page)
 *   table-layout: fixed; border-collapse: separate
 *   border: 1px solid rgb(204,204,204) with LEFT = 0 (only top/bottom/right)
 *   header 30px / 13px / weight 700 / bg rgb(232,232,232)
 *   data cell 28px / 13px
 * ========================================================================== */
.tj-grid-wrap {
  position: relative;
  width: 100%;
  font-family: var(--font, Arial, "Microsoft YaHei", sans-serif);
}

.tj-grid-scroll {
  width: 100%;
  overflow: auto;
}

.tj-grid {
  width: 100%;
  /* separate, not collapse: T+ relies on per-cell right border so that the
     left-most column has no outer frame line */
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: var(--grid-td-fs, 13px);
  background: #fff;
}

.tj-grid th,
.tj-grid .tj-th {
  background: var(--grid-th-bg, rgb(232, 232, 232));
  color: var(--grid-th-color, rgb(0, 0, 0));
  font-size: var(--grid-th-fs, 13px);
  font-weight: var(--grid-th-fw, 700);
  line-height: normal;
  text-align: center;
  /* left border explicitly 0: only top / bottom / right are drawn */
  border-top: 1px solid var(--border, rgb(204, 204, 204));
  border-bottom: 1px solid var(--border, rgb(204, 204, 204));
  border-left: 0;
  border-right: 1px solid var(--border, rgb(204, 204, 204));
  height: var(--grid-th-h, 30px);
  padding: 0 4px;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.tj-grid-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.tj-th-sortable {
  cursor: pointer;
  user-select: none;
}

.tj-th-sortable:hover {
  background: #dedede;
}

.tj-sort {
  display: inline-block;
  margin-left: 3px;
  font-size: 10px;
  color: #666;
}

/* data cell: 13px, left aligned, padding-left 5px, height 28px */
.tj-grid td,
.tj-grid .tj-td {
  font-size: var(--grid-td-fs, 13px);
  color: var(--grid-td-color, rgb(0, 0, 0));
  text-align: left;
  padding-left: var(--grid-td-pad, 5px);
  padding-right: 4px;
  border-top: 1px solid var(--border, rgb(204, 204, 204));
  border-bottom: 1px solid var(--border, rgb(204, 204, 204));
  border-left: 0;
  border-right: 1px solid var(--border, rgb(204, 204, 204));
  height: var(--grid-td-h, 28px);
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tj-grid .tj-align-right {
  text-align: right;
  padding-right: var(--grid-td-pad, 5px);
}

.tj-grid .tj-align-center {
  text-align: center;
}

.tj-grid .tj-align-left {
  text-align: left;
}

.tj-td-check,
.tj-th-check,
.tj-td-no,
.tj-th-no {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
}

.tj-grid-row:hover > td {
  background: #f7f9fc;
}

.tj-grid-row.tj-selected > td {
  background: #eef4fd;
}

/* total row: bg rgb(245,245,245) / 14px / rgb(51,51,51) */
.tj-grid tr.tj-grid-total > td,
.tj-grid tfoot td {
  background: var(--grid-total-bg, rgb(245, 245, 245));
  font-size: var(--grid-total-fs, 14px);
  color: var(--grid-total-fg, rgb(51, 51, 51));
  font-weight: 600;
  height: var(--grid-th-h, 30px);
}

.tj-grid-empty > td {
  background: #fff;
  font-size: 13px;
}

/* checkbox sizing inside grid */
.tj-grid input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
  vertical-align: middle;
  cursor: pointer;
}
