/* ───────────── COMPARE PAGE STYLES ───────────── */

/* Back Link */
.back-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s ease;
  margin-right: 16px;
  white-space: nowrap;
}
.back-link:hover {
  color: var(--accent);
}

/* Profile Selector */
.profile-selector {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.select-group {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
}

.select-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.profile-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: 'Inter', 'Noto Sans Khmer', sans-serif;
  font-size: 0.9rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.profile-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

.profile-select option {
  background: #1a1a2e;
  color: var(--text-primary);
  padding: 8px;
}

.vs-badge {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  padding-bottom: 10px;
  text-shadow: 0 0 20px var(--accent-glow);
}

/* ── Insight Cards ── */
.insight-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  box-sizing: border-box;
}

.insight-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px !important;
  position: relative;
  overflow: hidden;
}

.insight-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
}

.insight-card.improvement::before {
  background: linear-gradient(90deg, #57F287, #48c78e);
}

.insight-card.attention::before {
  background: linear-gradient(90deg, #ED4245, #f47b67);
}

.insight-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.insight-content {
  flex: 1;
  min-width: 0;
}

.insight-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.insight-subject {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

.insight-value.positive {
  color: #57F287;
}

.insight-value.negative {
  color: #ED4245;
}

/* ── Charts Grid ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  box-sizing: border-box;
}

.charts-grid .card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-container {
  position: relative;
  width: 100%;
  padding: 8px 0;
}

.radar-container {
  max-width: 380px;
  margin: 0 auto;
}

/* ── Compare Table ── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.compare-table {
  min-width: 420px;
}

.compare-table td.diff-positive {
  color: #57F287 !important;
  font-weight: 600;
}

.compare-table td.diff-negative {
  color: #ED4245 !important;
  font-weight: 600;
}

.compare-table td.diff-neutral {
  color: var(--text-tertiary) !important;
}

.compare-table .total-row td {
  border-top: 2px solid var(--border);
  font-weight: 700 !important;
}

/* ── Empty State ── */
.empty-compare-state {
  max-width: 500px;
  margin: 0 auto;
}

/* ── Fade In Animation ── */
@keyframes compareFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.compare-fade-in {
  animation: compareFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ── Section Spacing ── */
#overview-section,
#selector-section,
#table-section {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

#overview-section h3,
#selector-section h3,
#table-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Compare Button in Modal ── */
.compare-link-btn {
  font-family: 'Inter', 'Noto Sans Khmer', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(88, 101, 242, 0.2);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.compare-link-btn:hover {
  background: rgba(88, 101, 242, 0.15);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .profile-selector {
    flex-direction: column;
    align-items: stretch;
  }
  .select-group {
    max-width: 100%;
  }
  .vs-badge {
    text-align: center;
    padding-bottom: 0;
  }
  .charts-grid {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .charts-grid .card {
    padding: 20px;
  }
  .insight-cards {
    grid-template-columns: 1fr;
  }
  .compare-table {
    min-width: 100%;
  }
  .compare-table th, .compare-table td {
    padding: 6px 4px;
    font-size: clamp(0.6rem, 2.5vw, 0.75rem);
  }
  .chart-container {
    min-height: 280px;
  }
}


/* Grade Badge */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 8px;
  min-width: 20px;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

