/* ============================================================
   Readiness Matrix — Phase 5
   ============================================================ */

.matrix-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-secondary);
}

/* ---- toolbar ---- */
.matrix-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.matrix-toolbar__title {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 4px;
}

.matrix-toolbar__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 8px;
}

.matrix-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.matrix-filter__label {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.matrix-filter select,
.matrix-filter input {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  outline: none;
}

.matrix-filter select:focus,
.matrix-filter input:focus {
  border-color: var(--accent);
}

.matrix-filter input {
  width: 160px;
}

.matrix-filter select {
  cursor: pointer;
}

.matrix-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.matrix-legend__item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.matrix-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---- table wrapper ---- */
.matrix-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  padding-bottom: 90px;
}

.matrix-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

/* ---- sticky header ---- */
.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-strong);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}

.matrix-table thead th.col-asset {
  position: sticky;
  left: 0;
  z-index: 4;
  text-align: left;
  padding: 8px 12px;
  min-width: 200px;
}

.matrix-table thead th.col-gate {
  text-align: center;
  padding: 8px 10px;
  min-width: 72px;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.matrix-table thead th.col-gate:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.matrix-table thead th.col-gate.sort-asc::after  { content: " ▲"; font-size: 9px; }
.matrix-table thead th.col-gate.sort-desc::after { content: " ▼"; font-size: 9px; }

/* ---- sticky first column ---- */
.matrix-table tbody td.col-asset {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
}

.matrix-table tbody tr:hover td.col-asset {
  background: var(--bg-hover);
}

/* ---- rows ---- */
.matrix-table tbody tr {
  border-bottom: 1px solid var(--border-color);
}

.matrix-table tbody tr:hover {
  background: var(--bg-hover);
}

.matrix-cell--asset {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 12px;
}

.matrix-cell--asset-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.matrix-cell--asset-name {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ---- gate cells ---- */
.matrix-table tbody td.col-gate {
  text-align: center;
  padding: 4px 6px;
  vertical-align: middle;
}

.matrix-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.matrix-pip:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-hover);
  z-index: 1;
  position: relative;
}

.matrix-pip--signed        { background: rgba(22,163,74,0.15);  color: #16A34A; }
.matrix-pip--in_progress   { background: rgba(232,163,61,0.18); color: #C07A10; }
.matrix-pip--blocked       { background: rgba(220,38,38,0.13);  color: #DC2626; }
.matrix-pip--not_started   { background: var(--bg-tertiary);    color: var(--text-tertiary); }
.matrix-pip--waived_with_risk { background: rgba(99,102,241,0.13); color: #6366F1; }

/* ---- detail panel ---- */
.matrix-detail {
  display: none;
  position: fixed;
  top: 60px; /* updated by JS to follow the clicked pip */
  right: 14px;
  width: 320px;
  max-height: calc(100vh - 80px);
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  z-index: 100;
  flex-direction: column;
  overflow: hidden;
}

.matrix-detail.open {
  display: flex;
}

.matrix-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.matrix-detail__title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.matrix-detail__subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.matrix-detail__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.matrix-detail__close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.matrix-detail__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.matrix-detail__status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

.matrix-detail__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
}

.matrix-detail__row:last-child {
  border-bottom: none;
}

.matrix-detail__row-label {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.matrix-detail__row-value {
  color: var(--text-primary);
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
}

.matrix-detail__section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}

.matrix-detail__evidence-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
}

.matrix-detail__evidence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.matrix-detail__evidence-dot--ok      { background: var(--status-ok); }
.matrix-detail__evidence-dot--missing { background: var(--status-blocked); }

.matrix-detail__evidence-link {
  text-decoration: none;
  color: inherit;
  justify-content: space-between;
}

.matrix-detail__evidence-link:hover {
  background: var(--bg-hover);
  border-radius: 4px;
}

.matrix-detail__evidence-pdf {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.matrix-detail__photo {
  width: 100%;
  border-radius: 6px;
  margin-top: 4px;
  display: block;
  object-fit: cover;
  max-height: 200px;
}
