/* ==========================================================================
   Statis-Gravity: Component Styles
   Tabs, Panels, Stat Cards, Form Inputs, Grid Layouts, and Results
   ========================================================================== */

/* Main Navigation Tab Bar - Two-Row Responsive Layout */
.nav-tab-bar {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
  overflow: visible;
}

.nav-tab-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.tab-btn {
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.79rem;
  font-weight: 600;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 6px;
  flex: 1 1 0%;
  min-width: 0;
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.tab-btn.active {
  color: var(--cyan-primary);
  background: rgba(0, 210, 255, 0.12);
  border-color: var(--cyan-primary);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
  font-weight: 700;
}

[data-theme="light"] .tab-btn {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #475569;
}

[data-theme="light"] .tab-btn:hover {
  background: #e2e8f0;
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .tab-btn.active {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.12);
  border-color: #0284c7;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.25);
}

@media (max-width: 1100px) {
  .nav-tab-row {
    flex-wrap: wrap !important;
  }
  .tab-btn {
    flex: 1 1 calc(33.333% - 0.4rem);
    min-width: 140px;
  }
}

@media (max-width: 640px) {
  .tab-btn {
    flex: 1 1 calc(50% - 0.4rem);
    min-width: 120px;
  }
}

/* Tab Panels */
.tab-content {
  flex: 1;
  padding: 1.5rem 1.75rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-pane.active {
  display: block;
}

/* Tab Pane Upper Right Toolbar */
.tab-pane-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Two-column analysis layout */
.analysis-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .analysis-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards & Surface Containers */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: var(--glass-blur);
}

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

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Inputs & Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.55rem 0.75rem;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
  line-height: 1.4;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.input-row > * {
  flex: 1;
}

/* Stat Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.85rem;
  transition: border-color var(--transition-fast);
}

.metric-card:hover {
  border-color: var(--border-strong);
}

.metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.metric-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Canvas & Chart Container */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  position: relative;
}

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

.chart-canvas {
  width: 100%;
  height: 320px;
  display: block;
  border-radius: 6px;
  background-color: var(--bg-primary);
}

#teachingBayesCanvas {
  height: 540px;
}

/* Clinical Report Box */
.report-box {
  background: rgba(0, 210, 255, 0.04);
  border: 1px solid rgba(0, 210, 255, 0.2);
  border-left: 4px solid var(--cyan-primary);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1rem;
}

.report-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.report-text {
  font-size: 0.84rem;
  color: var(--text-main);
  line-height: 1.6;
  font-family: var(--font-sans);
}

/* Data Tables */
.table-responsive {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.data-table th {
  background-color: var(--bg-surface-elevated);
  padding: 0.55rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-mono);
}

.data-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* 2x2 Matrix Grid */
.matrix-2x2 {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
  text-align: center;
}

.matrix-cell {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
}

.matrix-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.matrix-input {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.matrix-input:focus {
  outline: none;
}

/* Footer Dedication */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.app-footer a {
  color: var(--cyan-primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* Modal Backdrop & Pop-up Window */
.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1.5rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-surface-elevated, var(--bg-surface));
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Teaching & CLT Simulation Dual Charts */
@media (max-width: 900px) {
  .clt-dual-charts {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   Interactive Double-Click Editable Number Badges & Inputs
   ========================================================================== */
.editable-number-badge {
  cursor: pointer !important;
  border-bottom: 1.5px dashed currentColor;
  padding: 1px 4px;
  border-radius: 4px;
  transition: all var(--transition-fast, 0.15s ease);
  display: inline-block;
  user-select: none;
  position: relative;
}

.editable-number-badge:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.25);
}

.editable-number-input {
  display: inline-block;
  background: rgba(15, 23, 42, 0.96) !important;
  border: 1.5px solid var(--cyan-primary, #00d2ff) !important;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.25;
  outline: none !important;
  font-family: inherit;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.45);
  vertical-align: middle;
  box-sizing: border-box;
}

.editable-number-input:focus {
  border-color: var(--cyan-primary, #00d2ff) !important;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.65);
}

/* ==========================================================================
   Randomiser Specific Styles (Clinical Allocation & Concealment Engine)
   ========================================================================== */
.randomiser-subnav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-surface-elevated, #1e293b);
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  width: fit-content;
  margin-bottom: 1.25rem;
}

.randomiser-subnav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s ease);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.randomiser-subnav-btn:hover {
  color: var(--text-main, #f8fafc);
  background: rgba(255, 255, 255, 0.05);
}

.randomiser-subnav-btn.active {
  background: var(--cyan-primary, #00d2ff);
  color: #090d16;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--cyan-glow, rgba(0, 210, 255, 0.3));
}

.allocation-reveal-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(30, 41, 59, 0.85) 100%);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.16));
  border-radius: 16px;
  padding: 1.75rem;
  text-align: center;
  backdrop-filter: blur(16px);
  transition: all 0.3s ease;
}

.allocation-reveal-card.revealed-a {
  border-color: rgba(0, 210, 255, 0.5);
  box-shadow: 0 8px 32px rgba(0, 210, 255, 0.18);
}

.allocation-reveal-card.revealed-b {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.18);
}

.concealment-veil {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.allocation-badge-large {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 2rem;
  font-weight: 800;
  padding: 0.75rem 2rem;
  border-radius: 9999px;
  letter-spacing: -0.02em;
  animation: badgePopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-group-a {
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.2) 0%, rgba(59, 130, 246, 0.2) 100%);
  border: 2px solid var(--cyan-primary, #00d2ff);
  color: var(--cyan-primary, #00d2ff);
  box-shadow: 0 0 25px rgba(0, 210, 255, 0.35);
}

.badge-group-b {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.2) 100%);
  border: 2px solid var(--emerald-primary, #10b981);
  color: var(--emerald-primary, #10b981);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.35);
}

@keyframes badgePopIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.block-slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.block-slot-pill {
  flex: 1;
  min-width: 65px;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.block-slot-pill.assigned-a {
  background: rgba(0, 210, 255, 0.15);
  border-color: rgba(0, 210, 255, 0.4);
  color: var(--cyan-primary, #00d2ff);
}

.block-slot-pill.assigned-b {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--emerald-primary, #10b981);
}

.block-slot-pill.active-slot {
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.block-slot-pill.concealed-slot {
  background: rgba(255, 255, 255, 0.04);
  border-style: dashed;
  color: var(--text-dim);
}

.balance-bar-track {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  background: var(--bg-surface-elevated, #1e293b);
  border: 1px solid var(--border-subtle);
}

.balance-bar-a {
  background: linear-gradient(90deg, #00d2ff, #3b82f6);
  height: 100%;
  transition: width 0.3s ease;
}

.balance-bar-b {
  background: linear-gradient(90deg, #10b981, #059669);
  height: 100%;
  transition: width 0.3s ease;
}

.audit-table-wrapper {
  max-height: 420px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}



