/**
 * Sophistication Panel Styles — Reference-Graph Diff View
 * Glassmorphism-styled floating panel for AI layer enrichment
 */

/* ─── Panel Container ─── */
.sophistication-panel {
  position: absolute;
  right: 16px;
  top: 60px;
  width: 360px;
  max-height: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.15);
  z-index: 500;
  overflow: hidden;
  color: #e2e8f0;
  font-size: 12px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sophistication-panel[style*="display: none"] {
  opacity: 0;
  transform: translateX(20px);
}

/* ─── Header ─── */
.soph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.08);
}

.soph-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.soph-icon {
  font-size: 18px;
}

.soph-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #c4b5fd;
}

.soph-header-right {
  display: flex;
  gap: 4px;
}

.soph-btn-icon {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.soph-btn-icon:hover {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
}

.soph-btn-icon .material-icons {
  font-size: 16px;
}

/* ─── Target Info ─── */
.soph-target-info {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.soph-target-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
}

.soph-target-name {
  font-size: 14px;
  font-weight: 600;
  color: #e0d4ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soph-target-hint {
  font-size: 10px;
  color: #475569;
  font-style: italic;
}

/* ─── Action Button ─── */
.soph-actions {
  padding: 12px 16px;
}

.soph-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.soph-btn .material-icons {
  font-size: 16px;
}

.soph-btn.primary {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: white;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.soph-btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.soph-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.soph-btn.small {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
}

.soph-btn.tiny {
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 5px;
}

.soph-btn.tiny .material-icons {
  font-size: 13px;
}

.soph-btn.success {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.soph-btn.success:hover {
  background: rgba(34, 197, 94, 0.25);
}

.soph-btn.muted {
  background: rgba(255, 255, 255, 0.06);
  color: #64748b;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.soph-btn.muted:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

/* ─── Loading (Brain Spinner Container) ─── */
.soph-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  padding-top: 46px;
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border-radius: 12px;
}

.soph-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top: 3px solid #8b5cf6;
  border-radius: 50%;
  animation: soph-spin 1s linear infinite;
}

@keyframes soph-spin {
  to { transform: rotate(360deg); }
}

/* ─── Status Bar ─── */
.soph-status {
  padding: 6px 16px;
  font-size: 10px;
  color: #64748b;
  min-height: 20px;
}

.soph-status-success { color: #4ade80; }
.soph-status-error { color: #f87171; }
.soph-status-warning { color: #fbbf24; }
.soph-status-info { color: #60a5fa; }

/* ═══════════════ DIFF VIEW ═══════════════ */

/* ─── Diff Results Container ─── */
.soph-diff-results {
  padding: 0 12px 12px;
  overflow-y: auto;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.soph-diff-results::-webkit-scrollbar {
  width: 4px;
}

.soph-diff-results::-webkit-scrollbar-track {
  background: transparent;
}

.soph-diff-results::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 4px;
}

.soph-diff-results::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* ─── Score Section ─── */
.soph-score-section {
  padding: 12px;
  background: rgba(139, 92, 246, 0.06);
  border-radius: 10px;
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.soph-score-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.soph-score-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a78bfa;
  min-width: 80px;
}

.soph-progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.soph-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease;
}

.soph-progress-fill.soph-success {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.soph-progress-fill.soph-warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.soph-progress-fill.soph-danger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.soph-score-value {
  font-size: 16px;
  font-weight: 700;
  color: #e0d4ff;
  min-width: 42px;
  text-align: right;
}

.soph-score-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.soph-stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #4ade80;
}

.soph-stat .material-icons {
  font-size: 13px;
}

.soph-stat-missing {
  color: #fbbf24;
}

.soph-stat-extra {
  color: #60a5fa;
}

/* ─── Section (Missing / Matching / Extra) ─── */
.soph-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  overflow: hidden;
}

.soph-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}

.soph-section-header.soph-clickable {
  cursor: pointer;
}

.soph-section-header.soph-clickable:hover {
  background: rgba(139, 92, 246, 0.12);
}

.soph-section-header .material-icons {
  font-size: 16px;
  color: #a78bfa;
}

.soph-section-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.soph-section-body {
  padding: 8px 10px;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.soph-section-body.collapsed {
  max-height: 0;
  padding: 0 10px;
  overflow: hidden;
}

/* Diff section color accents */
.soph-diff-missing .soph-section-header .material-icons {
  color: #fbbf24;
}

.soph-diff-missing .soph-section-header {
  background: rgba(251, 191, 36, 0.06);
}

.soph-diff-matching .soph-section-header .material-icons {
  color: #4ade80;
}

.soph-diff-matching .soph-section-header {
  background: rgba(34, 197, 94, 0.06);
}

.soph-diff-extra .soph-section-header .material-icons {
  color: #60a5fa;
}

.soph-diff-extra .soph-section-header {
  background: rgba(96, 165, 250, 0.06);
}

/* ─── Diff Item ─── */
.soph-diff-item {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.3s;
}

.soph-diff-item:last-child {
  border-bottom: none;
}

/* Missing Item */
.soph-diff-item-missing {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.soph-diff-item-missing:hover {
  background: rgba(251, 191, 36, 0.06);
}

.soph-diff-item-main {
  flex: 1;
  min-width: 0;
}

.soph-diff-item-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.soph-diff-item-name {
  font-weight: 600;
  font-size: 12px;
  color: #e0d4ff;
}

.soph-child-count {
  font-size: 10px;
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
}

.soph-diff-item-desc {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.4;
  margin-top: 2px;
}

/* Relation Chips */
.soph-relations-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.soph-relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.10);
  border: 1px solid rgba(139, 92, 246, 0.20);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soph-relation-chip .material-icons {
  font-size: 11px;
  opacity: 0.7;
}

.soph-relation-chip strong {
  font-weight: 600;
  color: #e0d4ff;
}

.soph-diff-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Match Item */
.soph-diff-item-match {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.soph-diff-item-match .soph-diff-item-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.soph-match-icon {
  font-size: 14px;
  color: #4ade80;
}

/* Extra Item */
.soph-diff-item-extra {
  display: flex;
  align-items: center;
  gap: 6px;
}

.soph-extra-icon {
  font-size: 14px;
  color: #60a5fa;
}

.soph-diff-item-extra .soph-diff-item-name {
  color: #94a3b8;
}

/* ─── Sub-Diff (nested child comparison) ─── */
.soph-sub-diff {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 26px;
  font-size: 10px;
}

.soph-sub-stat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 3px;
}

.soph-sub-stat.missing {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
}

.soph-sub-stat.matching {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.1);
}

.soph-sub-stat.extra {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}

.soph-sub-score {
  font-weight: 700;
  color: #a78bfa;
  margin-left: auto;
}

/* ─── Item State (accepted/dismissed) ─── */
.soph-diff-item.soph-accepted {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.06);
  opacity: 0.7;
}

.soph-diff-item.soph-dismissed {
  border-color: rgba(100, 116, 139, 0.2);
  background: rgba(100, 116, 139, 0.04);
  opacity: 0.5;
}

.soph-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
}

.soph-status-badge.soph-accepted {
  color: #4ade80;
  background: rgba(34, 197, 94, 0.15);
}

.soph-status-badge.soph-dismissed {
  color: #94a3b8;
  background: rgba(100, 116, 139, 0.1);
}

.soph-status-badge .material-icons {
  font-size: 13px;
}

/* ─── Info Badge (all-accepted feedback) ─── */
.soph-info-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.soph-info-badge .material-icons {
  font-size: 16px;
}

.soph-info-badge.success {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.2);
}
