/* ===== Modal Backdrop ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Modal ===== */
.modal {
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-backdrop.active .modal {
  transform: scale(1);
}

/* ===== Modal Header ===== */
.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.type-badge.loophole { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }
.type-badge.exemption { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.type-badge.gray-area { background: rgba(139, 92, 246, 0.12); color: var(--accent-purple); }
.type-badge.contradiction { background: rgba(236, 72, 153, 0.12); color: var(--accent-pink); }
.type-badge.missing-definition { background: rgba(99, 102, 241, 0.12); color: var(--accent-indigo); }
.type-badge.weak-enforcement { background: rgba(249, 115, 22, 0.12); color: var(--accent-orange); }
.type-badge.scope-gap { background: rgba(20, 184, 166, 0.12); color: var(--accent-teal); }
.type-badge.sunset-clause { background: rgba(100, 116, 139, 0.12); color: var(--accent-slate); }

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 4px;
  padding-right: 32px;
}

.modal-section-ref {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ===== Modal Body ===== */
.modal-body {
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-section {
  padding-left: 16px;
  border-left: 3px solid var(--border-color);
}

.modal-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.modal-section-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* Section border colors */
.modal-section.issue { border-left-color: currentColor; }
.modal-section.exploit { border-left-color: var(--accent-red); }
.modal-section.parallel { border-left-color: var(--accent-amber); }
.modal-section.fix { border-left-color: var(--accent-green); }

.fix-block {
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.12);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ===== Connected Issues ===== */
.connected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.connected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.connected-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

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

/* ===== Deep Dive ===== */
.deep-dive-section {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.deep-dive-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.deep-dive-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Stakeholder table */
.stakeholder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stakeholder-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stakeholder-card.benefits {
  border-top: 2px solid var(--accent-green);
}

.stakeholder-card.harmed {
  border-top: 2px solid var(--accent-red);
}

.stakeholder-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stakeholder-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stakeholder-list li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding-left: 12px;
  position: relative;
}

.stakeholder-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* Closing strategies */
.strategy-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.strategy-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.strategy-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.strategy-meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.difficulty-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.difficulty-badge.easy { background: rgba(34, 197, 94, 0.12); color: var(--accent-green); }
.difficulty-badge.moderate { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.difficulty-badge.hard { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); }

.strategy-side-effects {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Exploit scenario */
.scenario-steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-steps li {
  counter-increment: step;
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.scenario-steps li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-red);
  font-family: var(--font-mono);
}

.exploit-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.82rem;
}

.exploit-difficulty.easy { background: rgba(34, 197, 94, 0.1); color: var(--accent-green); }
.exploit-difficulty.moderate { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.exploit-difficulty.hard { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* ===== Modal Footer ===== */
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== Responsive Modal ===== */
@media (max-width: 768px) {
  .modal {
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  .modal-title {
    font-size: 1.15rem;
  }

  .stakeholder-grid {
    grid-template-columns: 1fr;
  }
}
