/**
 * Keifa Rebar Calculator — extended UI styles (BBS+, optimization, project).
 * Loaded after styles.css so it only adds new components.
 */

.hint-line { color: var(--text-muted); font-size: .85rem; margin: .5rem 0; }
.dim { color: var(--text-dim); }
.amber { color: var(--amber-primary); }
.mini-tag {
  display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 6px;
  border-radius: 999px; background: rgba(245, 158, 11, .18); color: #b45309;
  vertical-align: middle;
}
.mini-tag.ok { background: rgba(16, 185, 129, .16); color: #047857; }
.empty-cell { text-align: center; padding: 2rem 1rem; color: var(--text-dim); }
.warn-line { color: #b45309; background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .3); border-radius: 8px; padding: .5rem .75rem; font-size: .82rem; margin: .4rem 0; }
.total-row td { font-weight: 800; border-top: 2px solid var(--border-soft, rgba(148,163,184,.3)); }
.chip {
  display: inline-block; font-size: .72rem; padding: 2px 8px; margin: 2px 4px 2px 0;
  border-radius: 999px; background: rgba(56,189,248,.14); color: #0369a1;
}

/* ---- Optimization settings ---- */
.opt-settings-grid, .proj-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .9rem; margin-top: .5rem;
}
.opt-actions, .proj-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .9rem; }
.opt-status { font-size: .82rem; color: var(--cyan-primary, #0891b2); font-weight: 600; }
.chk-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .35rem; }
.chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }

/* ---- Stat boxes ---- */
.stat-grid-2, .proc-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-top: .5rem; }
.stat-box {
  border: 1px solid var(--border-soft, rgba(148,163,184,.28));
  border-radius: 10px; padding: .6rem .75rem; display: flex; flex-direction: column; gap: .2rem;
}
.stat-box-label { font-size: .74rem; color: var(--text-muted); }
.stat-box-val { font-size: 1.05rem; font-weight: 800; }
.stat-box-val small { font-size: .7rem; color: var(--text-muted); }
.opt-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.opt-group-head h4 { margin: 0; font-size: 1rem; }
.opt-sub { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin: .75rem 0 .35rem; text-transform: uppercase; letter-spacing: .04em; }
.proc-controls { display: grid; grid-template-columns: auto minmax(160px, 260px) auto minmax(90px, 140px); gap: .5rem; align-items: center; margin: .6rem 0; }

/* ---- Tables ---- */
.rebar-table.compact th, .rebar-table.compact td { font-size: .8rem; padding: .4rem .5rem; }
.readout {
  border: 1px dashed var(--border-soft, rgba(148,163,184,.4));
  border-radius: 8px; padding: .5rem .6rem; font-size: .85rem; min-height: 2.2rem;
}

/* ---- Row editor dialog ---- */
.keifa-dialog {
  border: none; border-radius: 16px; padding: 0; max-width: min(1040px, 96vw);
  width: 1040px; background: var(--surface, #fff); color: var(--text-main, #0f172a);
  box-shadow: 0 24px 70px rgba(2, 6, 23, .35);
}
.keifa-dialog::backdrop { background: rgba(2, 6, 23, .55); backdrop-filter: blur(2px); }
.dialog-body { padding: 1rem 1.15rem 1.15rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.dialog-head h3 { margin: 0; font-size: 1.05rem; }
.icon-btn { background: none; border: none; font-size: 1rem; cursor: pointer; color: var(--text-muted); }
.dialog-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.dialog-foot { display: flex; gap: .5rem; margin-top: .6rem; }
.svg-viewport.sm { min-height: 150px; }
.calc-details { border-top: 1px solid var(--border-soft, rgba(148,163,184,.25)); margin-top: .5rem; padding-top: .5rem; }
.calc-details-head { font-size: .8rem; font-weight: 700; color: var(--text-muted); margin-bottom: .35rem; }
.calc-steps { font-size: .82rem; display: flex; flex-direction: column; gap: .25rem; }
.calc-step { display: flex; justify-content: space-between; gap: .5rem; }
.calc-step.total { border-top: 1px solid var(--border-soft, rgba(148,163,184,.25)); padding-top: .3rem; font-weight: 800; }

/* ---- Code preview ---- */
.code-preview {
  margin-top: .6rem; padding: .7rem; border-radius: 10px; font-size: .78rem;
  background: rgba(2, 6, 23, .06); color: var(--text-main);
  max-height: 240px; overflow: auto; white-space: pre-wrap; direction: ltr; text-align: start;
}

.disclaimer {
  font-size: .78rem; color: var(--text-dim); line-height: 1.7;
  border-top: 1px solid var(--border-soft, rgba(148,163,184,.25)); padding-top: .6rem; margin-top: .5rem;
}

/* ---- Accessibility ---- */
:focus-visible {
  outline: 2px solid var(--amber-primary, #f59e0b);
  outline-offset: 2px;
  border-radius: 4px;
}
.keifa-dialog:focus-visible { outline: none; }

/* Keep technical tokens LTR inside RTL */
.mono, .code-preview, .tag-dia, .standard-badge { direction: ltr; unicode-bidi: embed; }

/* ---- Mobile ---- */
@media (max-width: 860px) {
  .dialog-grid { grid-template-columns: 1fr; }
  .keifa-dialog { width: 96vw; }
  .proc-controls { grid-template-columns: 1fr; }
  .section-nav { overflow-x: auto; flex-wrap: nowrap; }
  .nav-tab { white-space: nowrap; }
}
@media (max-width: 640px) {
  .rebar-table thead { display: none; }
  .rebar-table tr { display: block; border: 1px solid var(--border-soft, rgba(148,163,184,.3)); border-radius: 10px; margin-bottom: .5rem; padding: .4rem .6rem; }
  .rebar-table td { display: flex; justify-content: space-between; gap: .5rem; border: none; padding: .25rem 0; }
  .rebar-table td::before { content: attr(data-label); font-size: .72rem; color: var(--text-muted); }
}
