/*
  Risk Matrix Optimizer — CSS (Visual Look & Layout)
  --------------------------------------------------
  This stylesheet controls the overall appearance: colors, spacing,
  and layout grids. If you don’t know CSS, read comments like this:
  - Variables (under :root) define the color palette.
  - Utility classes (e.g., .btn, .panel) are reusable building blocks.
  - Component classes (.matrix, .scale-list) format specific parts of the UI.
*/

/*
  THEME VARIABLES
  Named colors are defined once and reused everywhere below.
  You can adjust the branding by changing values here.
*/
:root {
  --ming: #467082;
  --ming-dark: #1a4e5a;
  --orange: #f19a3e;
  --yellow: #f2cd5c; /* warm yellow for R2 */
  --coral: #ff6f61; /* coral for R4 */
  --white: #ffffff;
  --gray-light: #f5f7fa;
  --gray-medium: #9ca3af;
  --gray-dark: #1f2937;
  --alert-red: #c62828;
  /* RGB helpers for translucent uses based on named colors */
  --gray-dark-rgb: 31, 41, 55;
  --gray-medium-rgb: 156, 163, 175;
  --alert-red-rgb: 198, 40, 40;

  --color-lime: #a3d948;
  --color-emerald: #10b981;
  --color-sky: #60a5fa;
  --color-midnight: #0e0e52;
  --color-byzantium: #7a3b69;
  --color-coral: #ef4444;
  --color-spanish-orange: #e36414;
  --color-burgundy: #780116;
}
/* Page container: limits overall width and adds breathing room */
.rmo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* Simple breadcrumb line at the top of the app */
.breadcrumb {
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--gray-medium);
}
.breadcrumb a {
  color: var(--ming);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--orange);
}
.breadcrumb-separator {
  margin: 0 0.5rem;
  color: var(--gray-dark);
}

/* Card-like panel blocks and a lighter subpanel for grouped inputs */
.panel {
  background: var(--white);
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 1rem;
  box-shadow: 0 2px 8px rgba(var(--gray-dark-rgb), 0.08);
}
.subpanel {
  background: var(--gray-light);
  border: 1px solid var(--gray-medium);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.75rem;
}
.subpanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Generic form layout helpers */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field label {
  font-weight: 600;
  color: var(--gray-dark);
}
.field input {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--gray-medium);
  border-radius: 6px;
}

/* Button styles: default and primary */
.btn {
  background: var(--gray-light);
  color: var(--gray-dark);
  border: 1px solid var(--gray-medium);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(0.97);
}
.btn.primary {
  background: var(--ming);
  color: var(--white);
  border-color: var(--ming-dark);
}

/* Delegation row layout: name, numeric limit, remove button */
.delegations {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.deleg-row {
  display: grid;
  grid-template-columns: 1fr 200px 40px;
  gap: 0.5rem;
  align-items: center;
}
.deleg-row input {
  padding: 0.45rem;
  border: 1px solid var(--gray-medium);
  border-radius: 6px;
}
.deleg-row button {
  height: 36px;
}

/* Action buttons container below parameters */
.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.summary {
  margin-bottom: 0.75rem;
  color: var(--gray-dark);
}

/* Scale lists: three blocks (Probability, Impact, Risk) side by side */
.scales {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.scale-block {
  background: var(--gray-light);
  border: 1px solid var(--gray-medium);
  border-radius: 10px;
  padding: 0.5rem;
}
.scale-list {
  display: grid;
  gap: 0.4rem;
}
.scale-item {
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  border: 1px solid rgba(var(--gray-dark-rgb), 0.06);
}
.pill {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(var(--gray-medium-rgb), 0.2);
}

/* Matrix (risk table) visuals: spacing and band coloring */
.matrix-block {
  margin-top: 1rem;
}
.matrix {
  overflow: auto;
  border: 1px solid var(--gray-medium);
  border-radius: 8px;
}
.matrix table {
  border-collapse: separate;
  border-spacing: 2px;
  width: 100%;
}
.matrix th,
.matrix td {
  text-align: center;
  padding: 0.4rem;
}
.matrix .cell {
  min-width: 60px;
  min-height: 36px;
  border-radius: 6px;
  color: var(--gray-dark);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.matrix .cell.dark {
  color: var(--white);
  text-shadow: 0 1px 2px rgba(var(--gray-dark-rgb), 0.5);
}

/* Gradients (decorative mini-bars, available if needed) */
.grad-prob {
  background: linear-gradient(90deg, var(--white), rgba(var(--gray-dark-rgb), 1));
  height: 8px;
  border-radius: 999px;
}
.grad-impact {
  background: linear-gradient(90deg, var(--gray-light), var(--ming-dark));
  height: 8px;
  border-radius: 999px;
}

/* Utility text styles */
.muted {
  color: var(--gray-dark);
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Generic table and fieldset polish to match site look */
fieldset {
  border: 1px solid var(--gray-medium);
  margin: 0.5rem 0 1rem;
  padding: 0.75rem;
  border-radius: 4px;
}
legend {
  padding: 0 0.5rem;
  font-weight: 700;
  color: var(--ming-dark);
}
.boxed {
  border: 1px solid var(--gray-medium);
  border-radius: 4px;
  width: 100%;
  table-layout: fixed;
}
.boxed.small th,
.boxed.small td {
  font-size: 0.8rem;
}
.TOC_head {
  background: var(--gray-light);
  color: var(--gray-dark);
  font-family: "Poppins", sans-serif;
  font-size: 0.8rem;
  width: 28%;
}
.comment {
  background: var(--white);
}
.comment input {
  border-radius: 4px;
  font-size: 0.8rem;
}
.boxed td {
  padding: 0.4rem;
}

/* Two-column results pane; left=matrices, right=lists */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
.left-pane,
.right-pane {
  min-width: 0;
}
.table-wrap {
  max-height: 360px;
  overflow: auto;
}

/* Collapsed mode: hide parameters to give results more space */
.params-collapsed #paramsPanel {
  display: none;
}
.params-collapsed .results-grid {
  grid-template-columns: 1fr;
}

/* Progress bar and scenario ticker shown during runs */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.progress {
  flex: 1;
  background: var(--gray-light);
  border-radius: 10px;
  height: 20px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--gray-medium);
  width: 80%;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--gray-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-dark);
  font-weight: 700;
  transition: width 0.15s ease;
}
.progress-label {
  font-size: 0.75rem;
  padding-left: 20px;
}

.scenario-count {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--gray-dark);
  opacity: 0.9;
}

/* Optional strip of small matrix thumbnails (if used) */
.thumb-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.thumb {
  border: 1px solid var(--gray-medium);
  border-radius: 4px;
  background: var(--white);
  padding: 2px;
}
.thumb canvas {
  display: block;
}

.run-controls {
  margin-top: 0.5rem;
}
.btn.tiny {
  padding: 2px 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

/* Status/information messages shown above inputs */
.msg {
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--ming-dark);
  background: var(--gray-light);
  border: 1px solid var(--ming);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  display: none;
}
.msg.error {
  color: var(--alert-red);
  background: rgba(var(--alert-red-rgb), 0.1);
  border-color: var(--alert-red);
  display: block;
}
.msg.info {
  display: block;
}
.msg.warn {
  display: block;
  color: #7a3b00;
  background: rgba(227, 100, 20, 0.12); /* orange-ish */
  border-color: #e36414;
}

/* Colored chips that label risk bands (R1..Rk) */
.band-legend {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 0.25rem;
}
.band-legend .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Current/best loss numeric display and table header look */
.current-loss {
  margin-top: 0.5rem;
  font-weight: 600;
}
.table_head {
  position: sticky;
  top: 0;
  left:0;
  right: 0;
  width: 100%;
  background-color: var(--ming);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  
}

/* Panel title with right-aligned small controls */
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.panel-title-actions { display: flex; align-items: center; gap: 0.75rem; }
.panel-title-actions .chk { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.hidden { display: none !important; }
.panel.collapsed .panel-body { display: none; }

/* Inline numeric hint showing formatted money next to/below inputs */
.money-hint {
  font-size: 0.8rem;
  color: var(--gray-dark);
  opacity: 0.8;
  margin-top: 2px;
}

/* GPU badge shown when prefilter is active */
.gpu-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; border: 1px solid transparent; }
.gpu-on { background: rgba(16,185,129,.15); color:#065f46; border-color: rgba(16,185,129,.35); }
.gpu-off { background: rgba(198,40,40,.15); color: #7f1d1d; border-color: rgba(198,40,40,.35); }
.gpu-status-msg { font-size: 0.8rem; color: var(--alert-red); }
.gpu-active-msg { font-size: 0.8rem; color: #065f46; }
