/* Design tokens — app palette and typography. */
:root {
  --app-bg: #f0f2f5;
  --app-surface: #ffffff;
  --app-border: #d8dee6;
  --app-text: #1a2332;
  --app-muted: #5c6b7a;
  --app-primary: #1e5a8a;
  --app-primary-light: #e8f1f8;
  --app-primary-hover: #174a70;
  --app-primary-active: #133d5c;
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: 30, 90, 138;
  --bs-link-color: var(--app-primary);
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-focus-ring-color: rgba(var(--bs-primary-rgb), 0.25);
  --status-equal: #1a7f4b;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "Liberation Mono", monospace;
}

/* Bootstrap primary override — matches --app-primary instead of default blue. */
.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-hover);
  --bs-btn-hover-border-color: var(--app-primary-hover);
  --bs-btn-active-bg: var(--app-primary-active);
  --bs-btn-active-border-color: var(--app-primary-active);
}

.form-control:focus-visible {
  border-color: rgba(var(--bs-primary-rgb), 0.55);
  box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.form-control:focus:not(:focus-visible) {
  box-shadow: none;
}

/* Base layout */
* {
  box-sizing: border-box;
}

body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

/* Page header */
.app-header {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 1.5rem;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-brand-icon {
  flex-shrink: 0;
  display: block;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.app-subtitle {
  color: var(--app-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
}

.upload-section.card {
  border-radius: 0.5rem;
  overflow: hidden;
}

.upload-section .card-body {
  background: var(--app-surface);
}

/* Upload drop zone */
.drop-zone {
  border: 2px dashed var(--app-border);
  border-radius: 0.75rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fafbfc;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--app-primary);
  background: var(--app-primary-light);
  outline: none;
}

.drop-zone-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Loaded file list before analysis */
.files-list {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.files-list .file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  font-size: 0.875rem;
}

.files-list .file-item:last-child {
  border-bottom: none;
}

.files-list .file-path {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
}

.files-list .file-path .file-dir {
  color: var(--app-muted);
}

.files-list .file-meta {
  flex-shrink: 0;
  color: var(--app-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.files-list .file-remove-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--app-muted);
  padding: 0.2rem 0.35rem;
  border-radius: 0.25rem;
  line-height: 1;
}

.files-list .file-remove-btn:hover {
  color: #b42318;
  background: #fef3f2;
}

.files-list .file-folder-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--app-primary);
  padding: 0.35rem 0.75rem;
  background: var(--app-primary-light);
  border-bottom: 1px solid var(--app-border);
}


/* Result panel — table, search, export */
.compare-results-panel {
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  background: var(--app-surface);
}

.result-tabs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--app-border);
}

.result-tabs-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
  flex-shrink: 0;
}

.result-tabs-actions-divider {
  width: 1px;
  align-self: stretch;
  min-height: 1.75rem;
  background: var(--app-border);
}

.search-group {
  width: 220px;
}

.compare-table {
  font-size: 0.875rem;
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

.results-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.compare-table thead th,
.compare-table tbody tr.result-row td {
  white-space: nowrap;
}

.compare-table thead th:nth-child(2),
.compare-table thead th:nth-child(3),
.compare-table td.col-datenbank,
.compare-table td.col-schema {
  width: 1%;
}

.compare-table thead th {
  background: #f8f9fb;
  border-bottom-width: 1px;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--app-border);
}

.compare-table td.col-tabelle,
.compare-table td.col-schema {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.compare-table td.attr-star {
  color: var(--app-muted);
  font-style: italic;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--app-border);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--app-muted);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--status-equal);
  display: block;
  margin-bottom: 0.75rem;
}

/* Footer */
.app-footer {
  background: var(--app-surface);
  margin-top: 2rem;
}

/* Analysis hints — compact expandable cards with source snippets */
.hints-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hint-card {
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  background: var(--app-surface);
  overflow: hidden;
}

.hint-card-header {
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
  background: #f8f9fb;
  border-bottom: 1px solid var(--app-border);
}

.hint-location {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--app-border);
}

.hint-location:last-child {
  border-bottom: none;
}

.hint-location-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--app-primary);
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.hint-snippet {
  margin: 0;
  padding: 0.55rem 0.65rem;
  background: #1a2332;
  color: #abb2bf;
  border-radius: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre;
}

.hint-snippet .hljs {
  background: transparent;
  padding: 0;
}

.hint-snippet-line {
  white-space: pre;
}

.hint-snippet-code {
  white-space: pre;
}

.hint-snippet-code .hljs {
  display: inline;
  padding: 0;
  background: transparent;
}

.hint-compact-list {
  display: flex;
  flex-direction: column;
}

.hint-expand-item {
  border-bottom: 1px solid var(--app-border);
}

.hint-expand-item:last-child {
  border-bottom: none;
}

.hint-expand-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.9rem;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.875rem;
  color: var(--app-text);
  cursor: pointer;
}

.hint-expand-toggle:hover {
  background: #f8f9fb;
}

.hint-expand-toggle.is-open {
  background: #f8f9fb;
}

.hint-macro-name,
.hint-item-name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--app-primary);
}

.hint-item-name.hint-mono {
  font-weight: 600;
}

.hint-expand-meta {
  color: var(--app-muted);
  font-size: 0.8rem;
}

.hint-expand-icon {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--app-muted);
  transition: transform 0.15s ease;
}

.hint-expand-toggle.is-open .hint-expand-icon {
  transform: rotate(180deg);
}

.hint-expand-details {
  border-top: 1px solid var(--app-border);
  background: #fafbfc;
}

.hint-expand-details .hint-location {
  padding-left: 1.25rem;
}

.hint-ignore-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--app-muted);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  line-height: 1;
  cursor: pointer;
}

.hint-ignore-btn:hover {
  color: var(--app-primary);
  background: var(--app-primary-light);
}

.sort-mode-select {
  width: auto;
  min-width: 8.5rem;
}

.result-col-expand {
  width: 2.25rem;
  padding-left: 0.5rem;
  padding-right: 0.25rem;
}

.result-expand-btn {
  border: none;
  background: transparent;
  color: var(--app-muted);
  padding: 0.1rem 0.25rem;
  line-height: 1;
  border-radius: 0.25rem;
  cursor: pointer;
}

.result-expand-btn:hover {
  color: var(--app-primary);
  background: var(--app-primary-light);
}

.result-expand-btn.is-open {
  color: var(--app-primary);
}

.result-expand-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.result-expand-btn.is-open i {
  transform: rotate(180deg);
}

.result-expand-btn i {
  transition: transform 0.15s ease;
}

.result-detail-row td.result-detail-cell {
  padding: 0;
  background: #fafbfc;
  border-top: none;
  overflow: hidden;
  white-space: normal;
}

.result-detail-inner {
  padding: 0.5rem 0.75rem 0.65rem 2.5rem;
  min-width: 0;
  overflow: hidden;
  contain: inline-size;
  width: 100%;
  box-sizing: border-box;
}

.compare-table tbody tr.result-row.is-open td {
  border-bottom-color: transparent;
}

.source-file-view {
  max-height: min(28rem, 55vh);
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--app-border);
  border-radius: 0.35rem;
  background: #1a2332;
}

.source-file-lines {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: #abb2bf;
  width: max-content;
  min-width: 100%;
}

.source-line-text .hljs {
  display: inline;
  padding: 0;
  background: transparent;
}

.source-line {
  display: flex;
  min-height: 1.45em;
  max-width: none;
}

.source-line-no {
  flex-shrink: 0;
  padding: 0 0.65rem 0 0.55rem;
  color: #7d8b99;
  user-select: none;
  border-right: 1px solid #2d3a47;
  margin-right: 0.55rem;
}

.source-line-text {
  flex: 1;
  min-width: 0;
  padding-right: 0.55rem;
  white-space: pre;
}

.source-line-highlight {
  background: rgba(30, 90, 138, 0.45);
  box-shadow: inset 3px 0 0 #5ba3d9;
}

.source-line-highlight .source-line-no {
  color: #b8d4eb;
  font-weight: 600;
}

.result-source-location {
  margin-bottom: 0.65rem;
}

.result-source-location:last-child {
  margin-bottom: 0;
}
