/* ==========================================================================
   scale_reliability.css — Scale Reliability & Factor Analysis Styles
   ========================================================================== */

/* ── Stepper Navigation ──────────────────────────────────────────────────── */

.stepper-container {
  margin: 1.5rem 0 2rem 0;
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stepper-nav {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin: 0;
  list-style: none;
}

.stepper-step {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  color: var(--color-text-muted, #64748b);
  position: relative;
}

.stepper-step:hover {
  background: var(--color-surface-hover, #f8fafc);
  color: var(--color-text, #1e293b);
}

.stepper-step--active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
}

.stepper-step--completed .stepper-step__num {
  background: #10b981;
  color: #ffffff;
}

.stepper-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.stepper-step--active .stepper-step__num {
  background: #2563eb;
  color: #ffffff;
}

.stepper-step__title {
  font-size: 0.82rem;
  line-height: 1.25;
  margin-bottom: 0.25rem;
}

.stepper-step__badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 500;
}

.stepper-step--active .stepper-step__badge {
  background: #dbeafe;
  color: #1e40af;
}

/* ── Stage Panels ────────────────────────────────────────────────────────── */

.stage-panel {
  display: block;
}

.stage-panel.is-hidden {
  display: none !important;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.stage-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text, #0f172a);
  margin: 0;
}

.stage-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ── KPI & Metric Grid ───────────────────────────────────────────────────── */

.kpi-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem 0;
}

.kpi-metric-card {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.kpi-metric-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.kpi-metric-card__label {
  font-size: 0.85rem;
  color: var(--color-text-muted, #64748b);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.kpi-metric-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text, #0f172a);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-metric-card__subtext {
  font-size: 0.8rem;
  color: var(--color-text-muted, #64748b);
  margin-top: 0.4rem;
}

.kpi-metric-card--highlight {
  border-color: #93c5fd;
  background: #f8fafc;
}

/* ── Alpha Builder & Item Tables ─────────────────────────────────────────── */

.item-table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 8px;
  border: 1px solid var(--color-border, #e2e8f0);
}

.interactive-item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.interactive-item-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.interactive-item-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.interactive-item-table tr:hover {
  background: #f8fafc;
}

.interactive-item-table tr.is-omitted {
  opacity: 0.5;
  background: #f1f5f9;
}

.interactive-item-table tr.is-dud {
  background: #fff7ed;
}

.interactive-item-table tr.is-dud:hover {
  background: #ffedd5;
}

.alpha-up-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #15803d;
  font-weight: 700;
}

.alpha-down-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #b91c1c;
}

.reverse-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 0.35rem;
}

/* ── Purification & Undo Bar ─────────────────────────────────────────────── */

.purification-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin: 1rem 0;
  font-size: 0.88rem;
  color: #166534;
}

.purification-bar__history {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.purification-chip {
  background: #ffffff;
  border: 1px solid #86efac;
  border-radius: 9999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #15803d;
}

/* ── Factor Loadings Matrix Table ────────────────────────────────────────── */

.loadings-table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.loadings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.loadings-table th, .loadings-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.loadings-table th:first-child, .loadings-table td:first-child,
.loadings-table th:nth-child(2), .loadings-table td:nth-child(2) {
  text-align: left;
}

.loadings-table thead th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.loading-cell {
  font-weight: 500;
}

.loading-cell--primary {
  background: #dbeafe;
  color: #1e40af;
  font-weight: 700;
  border-radius: 4px;
}

.loading-cell--suppressed {
  color: #94a3b8;
  font-style: italic;
}

.chip-flag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.chip-flag--crossload {
  background: #fee2e2;
  color: #991b1b;
}

.chip-flag--weak {
  background: #fef3c7;
  color: #92400e;
}

.chip-flag--lowcomm {
  background: #ffedd5;
  color: #9a3412;
}

.btn-drop-item {
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  border: 1px solid #f87171;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-drop-item:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

/* ── Factor Cards Grid (Stage 6) ─────────────────────────────────────────── */

.factor-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.factor-card {
  background: var(--color-surface, #ffffff);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.factor-card__header {
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.factor-name-input {
  width: 100%;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  margin-top: 0.35rem;
}

.factor-name-input:focus {
  outline: 2px solid #2563eb;
  border-color: transparent;
}

.factor-metrics-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.factor-metric-item {
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

.factor-metric-item__label {
  font-size: 0.72rem;
  color: #64748b;
  text-transform: uppercase;
}

.factor-metric-item__value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}

/* ── Fornell-Larcker Validity Table ──────────────────────────────────────── */

.validity-table-container {
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.validity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: right;
}

.validity-table th, .validity-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.validity-table th:first-child, .validity-table td:first-child {
  text-align: left;
}

.validity-table thead th {
  background: #f1f5f9;
  font-weight: 700;
  color: #334155;
}

.validity-diagonal {
  background: #dbeafe;
  font-weight: 700;
  color: #1e40af;
}

.badge-pass {
  background: #dcfce7;
  color: #15803d;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-fail {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ── General Interactive Helpers ─────────────────────────────────────────── */

.callout-box {
  border-left: 4px solid #3b82f6;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  padding: 0.9rem 1.15rem;
  margin: 1rem 0;
}

.callout-box--warning {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.callout-box--danger {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.callout-box--success {
  border-left-color: #10b981;
  background: #f0fdf4;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-nav--primary {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #1d4ed8;
}

.btn-nav--primary:hover {
  background: #1d4ed8;
}

.btn-nav--secondary {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-nav--secondary:hover {
  background: #f1f5f9;
}

/* ── Heatmap & Plotly Charts ─────────────────────────────────────────────── */

.chart-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
  margin: 1rem 0;
  min-height: 380px;
}
