/**
 * Listening-IELTS Authentic Matching Matrix Stylesheet
 * English Mastery Hub Design System Harmonization
 * Replicates Computer-Delivered IELTS matrix grid with dark mode support
 * Features high-density compact layout (.matrix-dense) for >= 6 options
 */

.listening-matrix-container {
  margin: 1.25rem 0 1.5rem 0;
  width: 100%;
  max-width: calc(100% - 2.5rem);
}

.listening-matrix-table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.05);
  transition: all 0.2s ease;
}

.listening-matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
}

/* Table Header */
.listening-matrix-table thead tr {
  background: #f8fafc;
  border-bottom: 1.5px solid #e2e8f0;
}

.listening-matrix-table th {
  padding: 0.75rem 0.5rem;
  font-weight: 700;
  color: #475569;
  user-select: none;
}

.listening-matrix-table th.col-question {
  text-align: left;
  padding-left: 0.875rem;
  width: auto;
  min-width: 120px;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.listening-matrix-table th.col-option {
  width: 2.75rem;
  min-width: 2.4rem;
}

.col-letter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Table Body */
.listening-matrix-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.listening-matrix-table tbody tr:last-child {
  border-bottom: none;
}

.listening-matrix-table tbody tr:hover {
  background: #f8fafc;
}

/* Question Statement Cell */
.listening-matrix-table td.cell-statement {
  text-align: left;
  padding: 0.65rem 0.875rem;
  vertical-align: middle;
}

.stmt-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stmt-qnum-pill {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #fce7f3;
  color: #be185d;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #fbcfe8;
}

.stmt-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.35;
}

/* Radio Button Cell */
.listening-matrix-table td.cell-radio {
  padding: 0.5rem 0.2rem;
  vertical-align: middle;
  border-left: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.listening-matrix-table td.cell-radio.is-active-cell {
  background: #fdf2f8;
}

.matrix-radio-label {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0.35rem 0;
}

.matrix-radio-input {
  display: none;
}

.matrix-radio-circle {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
  position: relative;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.matrix-radio-label:hover .matrix-radio-circle {
  border-color: #ec4899;
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

.matrix-radio-input:checked + .matrix-radio-circle {
  border-color: #db2777;
  background: #db2777;
}

.matrix-radio-input:checked + .matrix-radio-circle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 9999px;
  background: #ffffff;
}

/* ==========================================================================
   Compact Density Mode (.matrix-dense) for >= 6 Options (Zero Overflow)
   ========================================================================== */
.listening-matrix-table.matrix-dense th.col-question {
  min-width: 110px;
  padding-left: 0.65rem;
  font-size: 0.725rem;
}

.listening-matrix-table.matrix-dense th.col-option {
  width: 2.15rem;
  min-width: 1.85rem;
  padding: 0.45rem 0.15rem;
}

.listening-matrix-table.matrix-dense .col-letter-pill {
  width: 1.4rem;
  height: 1.4rem;
  font-size: 0.75rem;
}

.listening-matrix-table.matrix-dense td.cell-statement {
  padding: 0.45rem 0.6rem;
}

.listening-matrix-table.matrix-dense .stmt-content {
  gap: 0.35rem;
}

.listening-matrix-table.matrix-dense .stmt-qnum-pill {
  width: 1.3rem;
  height: 1.3rem;
  font-size: 0.7rem;
}

.listening-matrix-table.matrix-dense .stmt-text {
  font-size: 0.8rem;
  line-height: 1.25;
}

.listening-matrix-table.matrix-dense td.cell-radio {
  padding: 0.35rem 0.1rem;
}

.listening-matrix-table.matrix-dense .matrix-radio-circle {
  width: 1.05rem;
  height: 1.05rem;
}

.listening-matrix-table.matrix-dense .matrix-radio-input:checked + .matrix-radio-circle::after {
  width: 0.35rem;
  height: 0.35rem;
}

/* Review Mode Highlights */
.listening-matrix-table td.cell-radio.is-correct-choice {
  background: #ecfdf5 !important;
}

.listening-matrix-table td.cell-radio.is-correct-choice .matrix-radio-circle {
  border-color: #10b981 !important;
  background: #10b981 !important;
}

.listening-matrix-table td.cell-radio.is-correct-choice .matrix-radio-circle::after {
  background: #ffffff !important;
}

.listening-matrix-table td.cell-radio.is-wrong-choice {
  background: #fef2f2 !important;
}

.listening-matrix-table td.cell-radio.is-wrong-choice .matrix-radio-circle {
  border-color: #ef4444 !important;
  background: #ef4444 !important;
}

/* Hidden Native Question Containers */
.listening-native-input-hidden {
  display: none !important;
}

/* Dark Mode Support */
[data-theme='dark'] .listening-matrix-table-wrapper,
.dark .listening-matrix-table-wrapper {
  background: #0f172a;
  border-color: #334155;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme='dark'] .listening-matrix-table thead tr,
.dark .listening-matrix-table thead tr {
  background: #1e293b;
  border-bottom-color: #334155;
}

[data-theme='dark'] .listening-matrix-table th,
.dark .listening-matrix-table th {
  color: #94a3b8;
}

[data-theme='dark'] .col-letter-pill,
.dark .col-letter-pill {
  background: #0f172a;
  border-color: #475569;
  color: #f1f5f9;
}

[data-theme='dark'] .listening-matrix-table tbody tr,
.dark .listening-matrix-table tbody tr {
  border-bottom-color: #1e293b;
}

[data-theme='dark'] .listening-matrix-table tbody tr:hover,
.dark .listening-matrix-table tbody tr:hover {
  background: #1e293b/50;
}

[data-theme='dark'] .stmt-qnum-pill,
.dark .stmt-qnum-pill {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.4);
}

[data-theme='dark'] .stmt-text,
.dark .stmt-text {
  color: #e2e8f0;
}

[data-theme='dark'] .listening-matrix-table td.cell-radio,
.dark .listening-matrix-table td.cell-radio {
  border-left-color: #1e293b;
}

[data-theme='dark'] .listening-matrix-table td.cell-radio.is-active-cell,
.dark .listening-matrix-table td.cell-radio.is-active-cell {
  background: rgba(236, 72, 153, 0.15);
}

[data-theme='dark'] .matrix-radio-circle,
.dark .matrix-radio-circle {
  border-color: #475569;
  background: #1e293b;
}
