/* Patent NOA Paralegal - Styles */

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 1rem;
}

.sidebar-brand h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.new-app-link {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.9rem;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.new-app-link:hover {
  color: var(--accent-hover);
}

.input-section {
  margin-bottom: 2rem;
}

.input-section.centered-fetch {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-section.centered-fetch .fetch-form {
  width: min(680px, 100%);
}

.fetch-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.fetch-form input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.fetch-form input::placeholder {
  color: var(--text-muted);
}

.fetch-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.fetch-form button {
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.fetch-form button:hover {
  background: var(--accent-hover);
}

.fetch-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fetch-form.is-fetching input {
  opacity: 0.85;
}

.fetch-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.fetch-spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: fetch-spin 0.65s linear infinite;
}

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

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.hidden {
  display: none !important;
}

.header-display {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.header-display h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.summary-dl {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.5rem 1.5rem;
  margin: 0;
}

.summary-dl dt {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.summary-dl dd {
  margin: 0;
  font-size: 0.9375rem;
}

.sections-area {
  margin-top: 1rem;
}

.active-section-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem 1.25rem;
}

.section-detail-card h3 {
  margin: 0 0 0.5rem;
}

.section-nav-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
  cursor: pointer;
}

.section-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.section-header-text {
  flex: 1;
  min-width: 0;
}

.section-nav-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.section-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.section-desc-truncated {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.reviewed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.section-nav-card.section-not-run {
  border-color: var(--border);
}

.section-nav-card.section-run-unreviewed {
  border-color: var(--warning);
}

.section-nav-card.section-run-reviewed {
  border-color: var(--success);
}

.section-nav-card.section-selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.45);
}

.section-nav-card.section-running {
  animation: sectionPulse 1.2s ease-in-out infinite;
}

@keyframes sectionPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.35);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(88, 166, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(88, 166, 255, 0);
  }
}

.ocr-provider-options {
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.ocr-label {
  margin-right: 0.75rem;
  color: var(--text-muted);
}

.radio-label {
  margin-right: 1rem;
  cursor: pointer;
  color: var(--text);
}

.radio-label input {
  margin-right: 0.35rem;
}

.doc-links {
  margin-bottom: 1rem;
}

.doc-link-wrap {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: 0.5rem;
}

.doc-links a {
  display: inline;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}

.doc-links a:hover {
  text-decoration: underline;
}

.doc-text-link {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.doc-text-link:hover {
  color: var(--accent);
}

.output-area {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.output-area.priority-output-layout {
  background: transparent;
  border: none;
  padding: 0;
  max-height: none;
  overflow: visible;
  white-space: normal;
}

.priority-tables-frame {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  white-space: normal;
}

.priority-fp-summary-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
}

.priority-fp-summary-label {
  color: var(--text-muted);
  font-weight: 500;
}

.priority-fp-summary-value {
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.priority-fp-summary-value--yes {
  color: var(--success);
  background: rgba(63, 185, 80, 0.12);
}

.priority-fp-summary-value--no {
  color: var(--text-muted);
  background: rgba(139, 148, 158, 0.12);
}

.priority-fp-review-pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--warning);
}

.priority-section-divider {
  margin: 1.1rem 0 0.9rem;
  border-top: 1px solid var(--border);
  opacity: 0.9;
}

.priority-docs-heading {
  margin: 0 0 0.75rem;
}

.priority-docs-group > h4 {
  margin-top: 1rem;
}

.priority-docs-group {
  background: rgba(88, 166, 255, 0.06);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: 8px;
  padding: 0.8rem 0.9rem 0.6rem;
}

.priority-ai-comparison-block {
  margin-bottom: 0.75rem;
  padding: 0 0.125rem;
  font-size: 0.875rem;
}

.progress-log {
  font-size: 0.875rem;
}

.progress-line {
  padding: 0.25rem 0;
  color: var(--text-muted);
}

.progress-line:last-child {
  color: var(--text);
}

.output-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.output-table th,
.output-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.output-table th {
  color: var(--text-muted);
  font-weight: 500;
}

.field-missing {
  color: var(--text-muted);
  font-style: italic;
}

.signature-ok {
  color: var(--success);
}

.signature-missing {
  color: var(--error);
}

.in-assignments-no {
  color: var(--error);
  font-weight: 600;
}

/* Priority: rows appended from USPTO when extract is truncated but ref set matches */
.priority-row-uspto-fill {
  border-left: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
}

.signature-doc-label {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.notes-list {
  margin-top: 0.75rem;
  color: var(--error);
  font-size: 0.8125rem;
}

.run-section-btn {
  margin-top: 0;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
}

.run-section-btn:hover {
  background: var(--border);
}

.run-section-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.run-sequential-btn {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
}

.run-sequential-btn:hover {
  background: var(--border);
}

.run-sequential-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 900px;
  height: 80vh;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  border: none;
  background: var(--surface-hover);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  z-index: 1;
}

.modal-close:hover {
  background: var(--border);
}

#doc-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.ids-compare-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  padding: 0.2rem;
}

.ids-compare-btn:hover {
  background: var(--border);
}

.ids-compare-btn svg {
  width: 1.2rem;
  height: 1.2rem;
}

.compare-modal-content {
  width: 96%;
  max-width: 1400px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.compare-modal-close {
  top: 0.65rem;
}

.compare-modal-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 3rem 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

.compare-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-sync-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.compare-frames {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.6rem;
}

.compare-frame-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  min-height: 0;
}

#compare-left-iframe,
#compare-right-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.confidence-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.2rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.confidence-high {
  color: #0f5c2e;
  background: #dff7e7;
  border-color: #7bcf98;
}

.confidence-medium {
  color: #7b4a02;
  background: #fff1d9;
  border-color: #f0c374;
}

.confidence-low {
  color: #7b1d21;
  background: #fde6e7;
  border-color: #f2a2a7;
}

.confidence-unknown {
  color: var(--text-muted);
  background: var(--surface-hover);
  border-color: var(--border);
}

.ids-unmatched-row td {
  background: rgba(255, 243, 224, 0.35);
}

.ids-unmatched-legend {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  background: rgba(255, 243, 224, 0.55);
  border: 1px solid rgba(240, 195, 116, 0.45);
}

.ids-lined-details td {
  padding-top: 0.15rem;
  padding-bottom: 0.6rem;
}

.ids-lined-details-box {
  margin-top: 0.1rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

.ids-lined-details-box summary {
  cursor: pointer;
  user-select: none;
}

.ids-lined-item {
  margin-top: 0.25rem;
  padding-left: 0.25rem;
}

/* Priority section: document source + match columns in one header row */
.priority-source-header {
  width: 100%;
  margin-bottom: 0.5rem;
  table-layout: fixed;
}

.priority-source-header th {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  vertical-align: bottom;
}

.priority-source-header td {
  vertical-align: middle;
  padding-top: 0.35rem;
}

.priority-source-header th:nth-child(1),
.priority-source-header td:nth-child(1) {
  width: 34%;
}

.priority-source-header th:nth-child(2),
.priority-source-header td:nth-child(2),
.priority-source-header th:nth-child(3),
.priority-source-header td:nth-child(3) {
  width: 33%;
}

.priority-note-section {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9375rem;
}

ul.priority-analysis-notes {
  margin: 0.25rem 0 0.75rem 1.25rem;
  padding: 0;
  list-style: disc;
}

ul.priority-analysis-notes li {
  margin-bottom: 0.35rem;
  color: var(--text);
  font-size: 0.9rem;
}

/* Access gate (shown before main app) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.main-app.hidden {
  display: none;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.access-gate.hidden {
  display: none;
}

.access-gate-card {
  width: min(400px, 100%);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.access-gate-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.access-gate-hint {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.access-gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.access-gate-form input {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.access-gate-form button {
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.access-gate-form button:hover {
  background: var(--accent-hover);
}

.access-gate .error {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

/* Restriction Requirement — claim copy blocks */
.restriction-alignment-block {
  margin: 1rem 0 1.25rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
}

.restriction-alignment-block h5 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.restriction-claim-group {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.restriction-claim-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

button.copy-claim-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
}

button.copy-claim-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.restriction-claim-pre {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24rem;
  overflow: auto;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.restriction-parent-pipeline {
  margin: 1rem 0;
}

a.restriction-table-doc-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

a.restriction-table-doc-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.terminal-disclaimer-current-box {
  margin: 0 0 1rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid rgba(88, 166, 255, 0.45);
  border-radius: 8px;
  background: rgba(88, 166, 255, 0.08);
}
