/* ============================================================
   Solubility Matrix — bulk drug × polymer heat map.
   Re-uses polymer-lab.css (hero, pills, buttons, feature tiles).
   ============================================================ */

.sm-input-section {
  max-width: 1100px;
  margin: -2.5rem auto 2rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 5;
}
.sm-input-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: 0 20px 45px rgba(10, 14, 39, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
}
.sm-form-field label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: var(--text-primary, #1f2937);
}
.sm-textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.88rem;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 10px;
  background: var(--input-bg, #fff);
  color: var(--text-primary, #111827);
  resize: vertical;
  min-height: 140px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sm-textarea:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}
.sm-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.9rem;
}
.sm-cost {
  font-weight: 700;
  font-size: 1.05rem;
  color: #7c3aed;
  padding-top: 0.3rem;
}
.sm-form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

/* --------- Results section --------- */

.sm-results-section {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.sm-progress {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1rem;
}

.sm-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.75rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
}
.sm-toolbar-spacer { flex: 1; }
.sm-toolbar-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.sm-sort-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
}
.sm-sort-label select {
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color, #d1d5db);
  background: var(--input-bg, #fff);
  color: var(--text-primary, #111827);
  font-size: 0.82rem;
}
.sm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted, #4b5563);
}
.sm-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.sm-legend-swatch {
  width: 14px; height: 14px; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(0,0,0,0.08);
}

/* --------- The matrix itself --------- */

.sm-matrix-wrap {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
}
.sm-matrix-scroll {
  overflow: auto;
  max-height: 70vh;
}
.sm-matrix {
  border-collapse: collapse;
  font-size: 0.75rem;
  width: max-content;
  min-width: 100%;
}
.sm-matrix th, .sm-matrix td {
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 0;
  text-align: center;
}
/* Frozen first column — drug labels */
.sm-matrix th.sm-corner,
.sm-matrix th.sm-drug-label,
.sm-matrix td.sm-drug-label {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--card-bg, #fff);
  padding: 0.4rem 0.6rem;
  text-align: left;
  min-width: 160px;
  max-width: 180px;
  border-right: 2px solid var(--border-color, #e5e7eb);
  font-weight: 600;
  color: var(--text-primary, #1f2937);
}
.sm-matrix th.sm-drug-label,
.sm-matrix td.sm-drug-label { font-weight: 600; }
.sm-matrix th.sm-corner { z-index: 4; top: 0; }

/* Frozen top-row — polymer column headers */
.sm-matrix th.sm-poly-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-bg, #fff);
  height: 130px;
  vertical-align: bottom;
  padding: 0 2px 6px;
  min-width: 36px;
  max-width: 36px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  font-size: 0.7rem;
  line-height: 1.1;
}
.sm-matrix th.sm-poly-head > div {
  transform: rotate(-55deg);
  transform-origin: left bottom;
  white-space: nowrap;
  position: relative;
  left: 22px;
  bottom: 0;
  text-align: left;
}
.sm-matrix th.sm-poly-head.sm-class-sep { border-left: 2px solid #7c3aed; }

/* Cells */
.sm-matrix td.sm-cell {
  width: 36px; height: 36px;
  min-width: 36px; max-width: 36px;
  cursor: pointer;
  position: relative;
  color: #fff;
  font-weight: 600;
  transition: transform 0.08s;
}
.sm-matrix td.sm-cell:hover {
  outline: 2px solid #0a0e27;
  outline-offset: -2px;
  z-index: 1;
}
.sm-matrix td.sm-cell.sm-class-sep { border-left: 2px solid #7c3aed; }
.sm-matrix td.sm-cell-empty { background: rgba(148,163,184,0.08); color: var(--text-muted,#9ca3af); cursor: default; }

/* Verdict colors */
.sm-cell-good     { background: #10b981; }        /* green 500 */
.sm-cell-marginal { background: #f59e0b; }        /* amber 500 */
.sm-cell-poor     { background: #dc2626; }        /* red 600 */
.sm-cell-pcsaft   {
  background: linear-gradient(135deg, #7c3aed, #00d4ff);
}

/* PC-SAFT crown marker — small triangle top-right */
.sm-cell-has-pcsaft::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 0; height: 0;
  border-top: 8px solid rgba(255,255,255,0.85);
  border-left: 8px solid transparent;
}
.sm-cell-synergy-exceptional::before {
  content: '\f005'; /* fa-star */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  top: 1px; left: 2px;
  font-size: 9px;
  color: rgba(255,255,255,0.95);
}

/* Tooltip */
.sm-tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(10, 14, 39, 0.97);
  color: #fff;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  z-index: 9999;
  max-width: 300px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.12s;
}
.sm-tooltip.sm-tooltip-visible { opacity: 1; }
.sm-tooltip b { color: #00d4ff; }

/* Drill-down panel */
.sm-drill {
  margin-top: 1rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-left: 4px solid #7c3aed;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.sm-drill-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.sm-drill-title { font-weight: 700; font-size: 1.05rem; color: var(--text-primary, #111827); }
.sm-drill-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted, #9ca3af);
  cursor: pointer;
  font-size: 1.1rem;
}
.sm-drill-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-primary, #1f2937);
  margin: 0.3rem 0 0.5rem;
}
.sm-drill-metrics strong { color: #7c3aed; }
.sm-drill-rationale {
  font-size: 0.85rem;
  color: var(--text-muted, #4b5563);
  padding-left: 1.1rem;
  margin: 0;
}
.sm-drill-rationale li { margin-bottom: 0.15rem; }
.sm-drill-pcsaft {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-color, #e5e7eb);
}
.sm-drill-pcsaft-head {
  display: flex; align-items: center; gap: 0.3rem;
  font-weight: 700; color: #7c3aed; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

/* --- Sadowski drug-solubility line block (Prudic 2014) --- */
.sm-drill-sadowski {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color, #e5e7eb);
}
.sm-drill-sadowski-head {
  display: flex; align-items: center; gap: 0.35rem;
  font-weight: 700;
  color: #6366f1;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}

/* Sadowski-mode cell tier accents */
.sm-cell-sadowski-lit {
  border-top: 2px solid rgba(16, 185, 129, 0.55);
}
.sm-cell-sadowski-walden {
  border-top: 2px dashed rgba(245, 158, 11, 0.6);
}
