/* ============================================================
   Lux Design System — components.css
   Product-neutral primitives that lux.css did not cover.
   Extracted from ads-console (design-prototype/console.css and
   public/assets/app.css), where they were first proven, and
   re-expressed against the shared tokens.

   Load AFTER lux.css. Does not redefine anything in lux.css.
   ============================================================ */

@import url('./tokens.css');

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--lux-line-soft);
  margin-bottom: 20px;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lux-ink-4);
  transition:
    color 150ms ease,
    border-color 150ms ease;
}
.tab:hover {
  color: var(--lux-ink);
}
.tab.active {
  color: var(--lux-ink);
  border-bottom-color: var(--lux-accent);
}
.tab .cnt {
  color: var(--lux-ink-6);
  margin-left: 5px;
  font-family: var(--lux-mono);
}

/* ---------- Toolbar (above a table) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .spacer {
  flex: 1;
}
.toolbar .search {
  width: 260px;
  padding: 7px 10px;
}

/* Native select, restyled. Caret is an inline SVG so it inherits nothing. */
.sel {
  border: 1px solid var(--lux-line);
  background-color: var(--lux-surface);
  padding: 7px 28px 7px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--lux-ink);
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--lux-caret);
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.sel:focus {
  outline: 0;
  border-color: var(--lux-ink);
}
.sel.sm {
  padding: 5px 24px 5px 8px;
  font-size: 11px;
}

/* ---------- Bulk action bar ---------- */
.bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--lux-ink);
  color: var(--lux-ink-inv);
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 12px;
}
.bulkbar .n {
  font-family: var(--lux-mono);
}
.bulkbar .spacer {
  flex: 1;
}
.bulkbar button {
  background: transparent;
  border: 1px solid var(--lux-ink-3);
  color: var(--lux-ink-inv);
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
}
.bulkbar button:hover {
  border-color: var(--lux-ink-inv);
}
.bulkbar button.x {
  border: 0;
  color: var(--lux-ink-6);
}

/* ---------- Table extras ---------- */
.tbl th.num,
.tbl td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tbl th.chk,
.tbl td.chk {
  width: 32px;
  padding-left: 8px;
  padding-right: 4px;
}
.tbl th.sort {
  cursor: pointer;
  user-select: none;
}
.tbl th.sort:hover {
  color: var(--lux-ink);
}
.tbl th.sort.asc::after {
  content: ' ↑';
}
.tbl th.sort.desc::after {
  content: ' ↓';
}
.tbl td .name {
  font-weight: 500;
}
.tbl td .sub {
  display: block;
  font-size: 11px;
  color: var(--lux-ink-4);
  margin-top: 2px;
}
.tbl tr.paused td .name {
  color: var(--lux-ink-4);
}
.tbl tr.selected td {
  background: var(--lux-bg-4);
}
.tbl td.actions {
  text-align: right;
  white-space: nowrap;
}
.tbl td.actions button,
.rowbtn {
  background: transparent;
  border: 1px solid var(--lux-line);
  padding: 4px 9px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lux-ink-2);
  cursor: pointer;
  font-family: inherit;
  margin-left: 4px;
}
.tbl td.actions button:hover,
.rowbtn:hover {
  border-color: var(--lux-ink);
  color: var(--lux-ink);
}
.tbl.dense td {
  padding: 8px 12px;
}
.tbl.dense th {
  padding: 6px 12px 10px;
}
.tbl td.wrap {
  white-space: normal;
}

/* ---------- Inline-editable cell ---------- */
.editable {
  cursor: text;
  border-bottom: 1px dashed transparent;
  padding-bottom: 1px;
}
.tbl tr:hover .editable {
  border-bottom-color: var(--lux-line-strong);
}
.edit-input {
  border: 1px solid var(--lux-ink);
  background: var(--lux-surface);
  padding: 3px 6px;
  font: inherit;
  font-size: 12.5px;
  font-family: var(--lux-mono);
  width: 90px;
  text-align: right;
}
.edit-input:focus {
  outline: 0;
}
.queued-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.queued-cell .old {
  color: var(--lux-ink-6);
  text-decoration: line-through;
  font-size: 11px;
}
.queued-cell .new {
  color: var(--lux-ink);
}
.queued-cell .q {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lux-accent);
  border: 1px solid var(--lux-accent);
  padding: 1px 5px;
}
.delta-pos {
  color: var(--lux-ok);
}
.delta-neg {
  color: var(--lux-err);
}

/* ---------- Checkbox ---------- */
input[type='checkbox'].cb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--lux-line-strong);
  background: var(--lux-surface);
  cursor: pointer;
  vertical-align: middle;
  position: relative;
}
input[type='checkbox'].cb:checked {
  background: var(--lux-ink);
  border-color: var(--lux-ink);
}
input[type='checkbox'].cb:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--lux-ink-inv);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* ---------- Toggle switch ---------- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}
.toggle .sw {
  width: 30px;
  height: 16px;
  border: 1px solid var(--lux-line-strong);
  background: var(--lux-surface);
  position: relative;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}
.toggle .sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--lux-ink-6);
  transition:
    transform 150ms ease,
    background 150ms ease;
}
.toggle.on .sw {
  background: var(--lux-ink);
  border-color: var(--lux-ink);
}
.toggle.on .sw::after {
  background: var(--lux-ink-inv);
  transform: translateX(14px);
}
.toggle.warn.on .sw {
  background: var(--lux-warn);
  border-color: var(--lux-warn);
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 24px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label,
.field > span:first-child {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lux-ink-4);
}
.field input,
.field textarea,
.field select.sel {
  border: 1px solid var(--lux-line);
  background: var(--lux-surface);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--lux-ink);
}
.field input:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--lux-ink);
}
.field .hint {
  font-size: 11px;
  color: var(--lux-ink-6);
}
.field.full {
  grid-column: 1 / -1;
}
.field textarea.code-edit {
  font-family: var(--lux-mono);
  font-size: 12px;
  line-height: 1.6;
  min-height: 260px;
  background: var(--lux-code-bg);
  color: var(--lux-code-ink);
  border-color: var(--lux-code-bg);
}
.form-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--lux-divider);
}

/* ---------- Notice ---------- */
.notice {
  border: 1px solid var(--lux-line-soft);
  border-left: 3px solid var(--lux-warn);
  background: var(--lux-surface);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.notice.err {
  border-left-color: var(--lux-err);
}
.notice.info {
  border-left-color: var(--lux-info);
}
.notice.ok {
  border-left-color: var(--lux-ok);
}
.notice .spacer {
  flex: 1;
}

/* ---------- Progress / meter bar ---------- */
.bar {
  height: 4px;
  background: var(--lux-bg-3);
  position: relative;
  overflow: hidden;
  width: 100%;
}
.bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--lux-ink);
  display: block;
}
.bar i.warn {
  background: var(--lux-warn);
}
.bar i.err {
  background: var(--lux-err);
}
.bar .mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--lux-accent);
}

/* ---------- Status dots ---------- */
.sdot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lux-line-mid);
  vertical-align: middle;
}
.sdot.ok {
  background: var(--lux-ok);
}
.sdot.warn {
  background: var(--lux-warn);
}
.sdot.err {
  background: var(--lux-err);
}
.sdot.info {
  background: var(--lux-info);
}
.sdot.neutral {
  background: var(--lux-ink-6);
}

/* ---------- Tag ---------- */
.tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border: 1px solid var(--lux-line);
  border-radius: 2px;
  color: var(--lux-ink-3);
  background: var(--lux-bg);
  margin-right: 4px;
}

/* ---------- Numbered steps ---------- */
.steps {
  list-style: none;
  counter-reset: s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}
.steps li {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.steps li::before {
  counter-increment: s;
  content: counter(s, decimal-leading-zero);
  font-family: var(--lux-mono);
  font-size: 10.5px;
  color: var(--lux-ink-6);
}

/* ---------- Keycap ---------- */
kbd.k {
  font-family: var(--lux-mono);
  font-size: 10px;
  color: var(--lux-ink-4);
  border: 1px solid var(--lux-line);
  padding: 1px 5px;
  background: var(--lux-bg);
}

/* ---------- Inline-SVG charts ---------- */
.flow {
  display: block;
  width: 100%;
  height: 240px;
}
.flow-sm {
  height: 160px;
}
.flow .gridline {
  stroke: var(--lux-line-soft);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.flow .series-1 {
  fill: none;
  stroke: var(--lux-ink);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.flow .series-2 {
  fill: none;
  stroke: var(--lux-accent);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.flow .bar {
  fill: var(--lux-ink);
}
/* lux.css already defines .legend with an 8x8 dot. For line charts the
   swatch should be a rule, not a dot — additive modifier, no override. */
.legend i.line {
  width: 12px;
  height: 2px;
  margin-right: 5px;
}

/* ---------- Layout utilities ---------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row.wrap {
  flex-wrap: wrap;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.spacer {
  flex: 1;
}
.mt {
  margin-top: 16px;
}
.mb0 {
  margin-bottom: 0;
}
.right {
  text-align: right;
}
.w-100 {
  width: 100%;
}
[x-cloak] {
  display: none !important;
}

@media (max-width: 1100px) {
  .grid-3,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
