/* ===== Document View Layout ===== */
.document-view {
  flex-direction: row;
  min-height: 100vh;
}

.main-panel {
  flex: 1;
  padding: 2rem 2.5rem;
  margin-left: var(--sidebar-width);
  overflow-y: auto;
  max-height: 100vh;
}

/* ===== Summary Banner ===== */
.summary-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-indigo);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.summary-banner::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 120px;
  background: linear-gradient(90deg, var(--accent-indigo-dim), transparent);
  pointer-events: none;
}

.summary-banner h2 {
  font-size: 1.15rem;
  color: var(--accent-indigo);
  margin-bottom: 0.75rem;
  position: relative;
}

.summary-banner p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  position: relative;
}

/* ===== Section Cards ===== */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px);
  animation: cardEnter var(--transition-slow) forwards;
}

.section-card.highlight {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 2px var(--accent-indigo-dim);
}

@keyframes cardEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.section-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: fit-content;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-primary);
  flex: 1;
}

/* ===== Type Badges ===== */
.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-definition    { background: var(--accent-blue-dim);    color: var(--accent-blue); }
.badge-substantive   { background: var(--accent-indigo-dim);  color: var(--accent-indigo); }
.badge-penalty       { background: var(--accent-red-dim);     color: var(--accent-red); }
.badge-procedural    { background: var(--accent-amber-dim);   color: var(--accent-amber); }
.badge-severability  { background: var(--accent-gray-dim);    color: var(--accent-gray); }
.badge-effective-date{ background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-enacting      { background: var(--accent-purple-dim);  color: var(--accent-purple); }
.badge-other         { background: var(--accent-gray-dim);    color: var(--accent-gray); }

/* ===== Penalty Badge ===== */
.penalty-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  background: var(--accent-red-dim);
  color: var(--accent-red);
  font-size: 0.7rem;
  cursor: help;
  position: relative;
}

.penalty-indicator .penalty-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 30;
  box-shadow: var(--shadow-md);
}

.penalty-indicator:hover .penalty-tooltip {
  display: block;
  animation: tooltipIn var(--transition-fast) forwards;
}

/* ===== Section Body ===== */
.section-body {
  padding: 1.25rem;
}

.legislation-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--text-secondary);
  padding: 1rem 1.25rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-light);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===== Plain English Toggle ===== */
.plain-english-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: var(--accent-indigo-dim);
  color: var(--accent-indigo);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.plain-english-toggle:hover {
  background: var(--accent-indigo-mid);
}

.plain-english-toggle.expanded {
  border-color: var(--accent-indigo);
}

.plain-english-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow) ease, opacity var(--transition-med);
  opacity: 0;
}

.plain-english-content.expanded {
  max-height: 600px;
  opacity: 1;
}

.plain-english-inner {
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--accent-indigo-dim);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-indigo);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-primary);
}

/* ===== Defined Terms ===== */
.defined-term {
  color: var(--accent-emerald);
  border-bottom: 1px dotted var(--accent-emerald);
  cursor: help;
  position: relative;
  transition: color var(--transition-fast);
}

.defined-term:hover {
  color: #6ee7b7;
}

/* ===== Cross References ===== */
.cross-ref {
  color: var(--accent-indigo);
  border-bottom: 1px dotted var(--accent-indigo);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.cross-ref:hover {
  color: #a5b4fc;
}

/* ===== Tooltip ===== */
.tooltip {
  position: fixed;
  z-index: 80;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-primary);
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.95);
  animation: tooltipIn var(--transition-fast) forwards;
}

.tooltip-label {
  font-weight: 600;
  color: var(--accent-emerald);
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@keyframes tooltipIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Suggestions Panel ===== */
.suggestions-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-med);
  box-shadow: var(--shadow-lg);
}

.suggestions-panel.open {
  transform: translateX(0);
}

.suggestions-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.suggestions-panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent-indigo);
}

.suggestions-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.suggestions-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.suggestions-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Loading state inside panel */
.suggestions-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  flex: 1;
}

.suggestions-loading .spinner {
  width: 36px;
  height: 36px;
}

.suggestions-loading-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Overall assessment card */
.assessment-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--accent-indigo);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.assessment-card h4 {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.assessment-card p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Suggestion cards (compact, clickable) */
.suggestion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.suggestion-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.suggestion-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  min-width: 0;
}

.suggestion-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.stype-loophole      { background: var(--accent-red-dim);     color: var(--accent-red); }
.stype-clarity        { background: var(--accent-amber-dim);   color: var(--accent-amber); }
.stype-enforcement    { background: var(--accent-indigo-dim);  color: var(--accent-indigo); }
.stype-scope          { background: var(--accent-blue-dim);    color: var(--accent-blue); }
.stype-consistency    { background: var(--accent-purple-dim);  color: var(--accent-purple); }
.stype-redundancy     { background: var(--accent-gray-dim);    color: var(--accent-gray); }
.stype-modernization  { background: var(--accent-emerald-dim); color: var(--accent-emerald); }

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

.severity-critical  { background: var(--accent-red); }
.severity-important { background: var(--accent-amber); }
.severity-minor     { background: var(--accent-gray); }

.suggestion-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-section-ref {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.suggestion-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: color var(--transition-fast);
  margin-left: 0.15rem;
}

.suggestion-card:hover .suggestion-chevron {
  color: var(--text-secondary);
}

/* ===== Suggestion Detail Modal ===== */
.suggestion-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 250ms ease-out;
  pointer-events: none;
}

.suggestion-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.suggestion-modal {
  background: #111827;
  border: 1px solid rgba(129, 140, 248, 0.15);
  border-radius: 16px;
  max-width: 700px;
  width: calc(100% - 3rem);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(129, 140, 248, 0.08);
  transform: scale(0.95);
  transition: transform 250ms ease-out;
}

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

/* Modal header */
.suggestion-modal-header {
  padding: 1.5rem 1.75rem 1.25rem;
  position: relative;
}

.suggestion-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: all var(--transition-fast);
}

.suggestion-modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.suggestion-modal-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.severity-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.severity-pill-critical  { background: var(--accent-red-dim);   color: var(--accent-red); }
.severity-pill-important { background: var(--accent-amber-dim); color: var(--accent-amber); }
.severity-pill-minor     { background: var(--accent-gray-dim);  color: var(--accent-gray); }

.suggestion-modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
  line-height: 1.35;
  padding-right: 2.5rem;
}

.suggestion-modal-section {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Modal body */
.suggestion-modal-body {
  padding: 0 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-section {
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
}

.modal-section-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.modal-section-content {
  padding-left: 1rem;
  border-left: 3px solid var(--border-light);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.modal-section-problem .modal-section-content {
  border-left-color: var(--accent-red);
}

.modal-section-problem.severity-ctx-important .modal-section-content {
  border-left-color: var(--accent-amber);
}

.modal-section-problem.severity-ctx-minor .modal-section-content {
  border-left-color: var(--accent-gray);
}

.modal-section-recommendation .modal-section-content {
  border-left-color: var(--accent-emerald);
}

.modal-section-rationale .modal-section-content {
  border-left-color: var(--accent-indigo);
  color: var(--text-muted);
}

.recommendation-code {
  background: #1a2332;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--accent-emerald);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Modal footer */
.suggestion-modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Suggestions overlay for mobile */
.suggestions-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 65;
}

.suggestions-overlay.active {
  display: block;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-panel {
    margin-left: 0;
    padding: 1.25rem;
    padding-top: 3.5rem;
  }

  .section-header {
    padding: 0.75rem 1rem;
  }

  .section-body {
    padding: 1rem;
  }

  .legislation-text {
    font-size: 0.78rem;
    padding: 0.75rem 1rem;
  }

  .suggestions-panel {
    width: 100%;
  }

  .suggestion-modal {
    max-width: none;
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }

  .suggestion-modal-header {
    padding: 1.25rem 1rem 1rem;
  }

  .suggestion-modal-title {
    font-size: 1.25rem;
  }

  .suggestion-modal-body {
    padding: 0 1rem;
  }

  .suggestion-modal-footer {
    padding: 1rem;
  }
}