* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #6b7280;
  --success-color: #10b981;
  --error-color: #ef4444;
  --background: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Upload Section */
.upload-section,
.login-section {
  max-width: 600px;
  margin: 0 auto;
}

.upload-box {
  background: var(--surface);
  border: 3px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.login-box {
  border-style: solid;
  border-color: var(--border);
  cursor: default;
}

.login-box:hover {
  background: var(--surface);
  border-color: var(--border);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.upload-box:hover {
  border-color: var(--primary-color);
  background: #f9fafb;
}

.upload-box svg {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.upload-box h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.upload-box p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.file-types {
  font-size: 0.875rem;
  margin-bottom: 1.5rem !important;
}

/* Upload Divider */
.upload-divider {
  text-align: center;
  margin: 2rem 0;
  position: relative;
}

.upload-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: var(--border);
}

.upload-divider span {
  display: inline-block;
  background: var(--background);
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  position: relative;
  z-index: 1;
}

/* Load Results Box */
.load-results-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s;
}

.load-results-box:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.load-results-box svg {
  color: var(--secondary-color);
  margin-bottom: 1rem;
}

.load-results-box h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.load-results-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.selected-file {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.file-info svg {
  color: var(--primary-color);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-icon {
  background: none;
  border: 2px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Loading Section */
.loading-section {
  text-align: center;
  padding: 4rem 2rem;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Results Section */
.results-section {
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.header-buttons {
  display: flex;
  gap: 1rem;
}

.results-content {
  display: block;
  margin-bottom: 2rem;
}

.preview-panel,
.content-panel {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 1.25rem;
  margin: 0;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.canvas-container {
  position: relative;
  padding: 1.5rem;
  min-height: 800px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #f9fafb;
  overflow: auto;
}

#pdfCanvas {
  max-width: 100%;
  border: 1px solid var(--border);
  background: white;
  box-shadow: var(--shadow-lg);
}

.bounding-box-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bounding-box {
  fill: rgba(79, 70, 229, 0.1);
  stroke: rgba(79, 70, 229, 0.8);
  stroke-width: 2;
  transition: all 0.2s;
}

.bounding-box:hover {
  fill: rgba(79, 70, 229, 0.2);
  stroke: rgba(79, 70, 229, 1);
  stroke-width: 3;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
}

.tab {
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab:hover {
  color: var(--primary-color);
}

.panel-content {
  padding: 1.5rem;
  max-height: 600px;
  overflow-y: auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Markdown Content */
.markdown-content {
  line-height: 1.8;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.markdown-content p {
  margin-bottom: 1rem;
}

.markdown-content ul,
.markdown-content ol {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.markdown-content code {
  background: var(--background);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: "Courier New", monospace;
}

/* Chunks Content */
.chunks-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chunk-item {
  padding: 1rem;
  background: var(--background);
  border-left: 4px solid var(--primary-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.chunk-item:hover {
  background: #f3f4f6;
  transform: translateX(4px);
}

.chunk-item.highlighted {
  background: rgba(79, 70, 229, 0.1);
  border-left-color: var(--primary-hover);
}

.chunk-type {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.chunk-content {
  color: var(--text-primary);
}

/* JSON Content */
.json-content {
  background: #1f2937;
  color: #e5e7eb;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Metadata Section */
.metadata-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.metadata-section h3 {
  margin-bottom: 1rem;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.metadata-item {
  padding: 1rem;
  background: var(--background);
  border-radius: 8px;
}

.metadata-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.metadata-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Figures Section */
.figures-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.figures-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.figures-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.figures-header h3 {
  margin: 0;
}

.filter-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--primary-color);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.figures-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.figures-controls label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.figures-controls label[for="elementTypeFilter"] {
  color: var(--primary-color);
  font-weight: 700;
}

.figure-sort-select {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.figure-sort-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Modern, beautiful styling for section category dropdown */
#elementTypeFilter {
  font-weight: 600;
  border: 2px solid var(--primary-color);
  color: var(--text-primary);
  background: linear-gradient(
    135deg,
    rgba(79, 70, 229, 0.08) 0%,
    rgba(79, 70, 229, 0.04) 100%
  );
  padding: 0.75rem 2.5rem 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
  appearance: none;
  background-image:
    linear-gradient(
      135deg,
      rgba(79, 70, 229, 0.08) 0%,
      rgba(79, 70, 229, 0.04) 100%
    ),
    url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat, no-repeat;
  background-position:
    center,
    right 0.75rem center;
  background-size: auto, 20px;
}

#elementTypeFilter:hover {
  background:
    linear-gradient(
      135deg,
      rgba(79, 70, 229, 0.12) 0%,
      rgba(79, 70, 229, 0.06) 100%
    ),
    url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat, no-repeat;
  background-position:
    center,
    right 0.75rem center;
  background-size: auto, 20px;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
  border-color: #4338ca;
}

#elementTypeFilter:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow:
    0 0 0 4px rgba(79, 70, 229, 0.1),
    0 4px 16px rgba(79, 70, 229, 0.25);
}

#elementTypeFilter:active {
  transform: translateY(0);
}

/* Style the dropdown options */
#elementTypeFilter option {
  padding: 0.75rem;
  background: white;
  color: var(--text-primary);
  font-weight: 500;
}

#elementTypeFilter option:hover {
  background: rgba(79, 70, 229, 0.1);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.figures-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.figures-placeholder {
  text-align: center;
  color: var(--text-secondary);
  padding: 3rem 2rem;
}

.figure-item {
  background: var(--background);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.figure-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.figure-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.figure-item-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.figure-item-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  align-items: center;
}

.figure-item-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.gemini-status {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gemini-positive {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.gemini-negative {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-secondary);
}

.gemini-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
}

.figure-item-actions {
  display: flex;
  gap: 0.5rem;
}

.figure-item-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.figure-item-actions button:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.figure-item-content {
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  border-radius: 8px;
  padding: 1rem;
  min-height: 200px;
}

.figure-item-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Figure-local tabs */
.figure-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.figure-tab {
  padding: 0.4rem 0.8rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
}

.figure-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.figure-tab.disabled {
  color: var(--border);
  cursor: not-allowed;
  opacity: 0.5;
}

.figure-tab.disabled:hover {
  color: var(--border);
}

.figure-panels {
  width: 100%;
}

.figure-tab-content {
  display: none;
}
.figure-tab-content.active {
  display: block;
}

.figure-diff-placeholder {
  color: var(--text-secondary);
}

.diff-controls-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(79, 70, 229, 0.05);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.diff-controls-help span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.diff-controls-help strong {
  color: var(--text-primary);
}

.btn-delete-selected {
  padding: 0.4rem 0.8rem;
  background: var(--error-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
}

.btn-delete-selected:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Diff overlay */
.diff-view {
  position: relative;
  display: inline-block;
}

.diff-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.diff-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: crosshair;
}

.diff-overlay:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.diff-box {
  fill: rgba(16, 185, 129, 0.12);
  stroke: rgba(16, 185, 129, 0.9);
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-box:hover {
  fill: rgba(16, 185, 129, 0.25);
  stroke-width: 3;
}

.diff-box.selected {
  fill: rgba(239, 68, 68, 0.2);
  stroke: rgba(239, 68, 68, 1);
  stroke-width: 3;
}

.diff-box.drawing {
  fill: rgba(79, 70, 229, 0.15);
  stroke: rgba(79, 70, 229, 0.8);
  stroke-width: 2;
}

.figure-diff-json-container {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--background);
  border-radius: 8px;
}

.diff-json-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.figure-diff-json {
  background: #1f2937;
  color: #e5e7eb;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  margin: 0;
}

.figure-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.figure-description {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-left: 4px solid var(--primary-color);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 150px;
  overflow-y: auto;
}

/* Preview Image Only */
.preview-image-only {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  min-height: 300px;
}

.preview-image-only img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.preview-image-only img:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-lg);
}

.preview-hint {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-style: italic;
}

/* Image Modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-modal.active {
  opacity: 1;
}

.image-modal.closing {
  opacity: 0;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  max-width: 95vw;
  max-height: 95vh;
  width: 1400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 2rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.modal-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  height: 100%;
  overflow: hidden;
}

.modal-image {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  overflow: auto;
}

.modal-image-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.modal-download-btn {
  padding: 0.5rem 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.modal-download-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.modal-download-btn:active {
  transform: translateY(0);
}

.modal-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  align-self: center;
}

.modal-text {
  display: flex;
  flex-direction: column;
  background: var(--background);
  border-radius: 8px;
  padding: 1.5rem;
  overflow: hidden;
}

.modal-text h3 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.75rem;
}

.modal-markdown {
  flex: 1;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  padding: 1rem;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Markdown content styling */
.modal-markdown h1,
.modal-markdown h2,
.modal-markdown h3 {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-markdown h1 {
  font-size: 1.5rem;
}
.modal-markdown h2 {
  font-size: 1.25rem;
}
.modal-markdown h3 {
  font-size: 1.1rem;
}

.modal-markdown strong {
  font-weight: 700;
  color: var(--text-primary);
}

.modal-markdown em {
  font-style: italic;
}

.modal-markdown ul,
.modal-markdown ol {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.modal-markdown p {
  margin-bottom: 0.5rem;
}

/* Table styling for HTML tables */
.modal-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.modal-markdown table td,
.modal-markdown table th {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}

.modal-markdown table th {
  background: var(--background);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-markdown table tr:nth-child(even) {
  background: #f9fafb;
}

.modal-markdown table tr:hover {
  background: #f3f4f6;
}

/* Responsive Modal */
@media (max-width: 1024px) {
  .modal-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal-image {
    max-height: 50vh;
  }
}

/* Error Section */
.error-section {
  text-align: center;
  padding: 4rem 2rem;
}

.error-box {
  max-width: 500px;
  margin: 0 auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.error-box svg {
  color: var(--error-color);
  margin-bottom: 1rem;
}

.error-box h3 {
  color: var(--error-color);
  margin-bottom: 1rem;
}

.error-box p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .header-buttons {
    flex-direction: column;
    width: 100%;
  }

  .header-buttons .btn {
    width: 100%;
  }

  .controls {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .figures-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .figures-header-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .figures-controls {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .figures-controls label {
    margin-top: 0.5rem;
  }

  .figure-sort-select,
  .figures-controls .btn,
  #elementTypeFilter,
  #clearFilterBtn {
    width: 100%;
  }

  .figure-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .figure-item-actions {
    width: 100%;
    flex-direction: column;
  }

  .figure-item-actions button {
    width: 100%;
  }
}

/* ========================================================================= */
/* INSPECTION ANALYSIS STYLES */
/* ========================================================================= */

.insight-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}

.insight-controls label {
  font-weight: 500;
  color: var(--text-primary);
}

.analysis-type-select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: white;
  font-size: 0.875rem;
  min-width: 200px;
}

.btn-inspect {
  padding: 0.5rem 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-inspect:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-inspect:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.insight-results {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  align-items: flex-start;
}

.insight-preview {
  flex: 1;
  position: relative;
  background: #f5f5f5;
  border-radius: 0.5rem;
  overflow: hidden;
}

.insight-image {
  width: 100%;
  height: auto;
  display: block;
}

.insight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.inspection-box {
  transition: all 0.2s;
}

.inspection-box.highlighted {
  stroke: #a855f7 !important; /* Light purple stroke */
  stroke-width: 4 !important;
  fill: rgba(
    168,
    85,
    247,
    0.3
  ) !important; /* Light purple fill with transparency */
  filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.5)); /* Glow effect */
}

.inspection-label {
  pointer-events: none;
  text-shadow:
    1px 1px 2px white,
    -1px -1px 2px white;
}

.insight-issues {
  flex: 0 0 350px;
  max-height: 600px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.insight-placeholder {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.insight-loading {
  padding: 2rem;
  text-align: center;
  color: var(--primary-color);
  font-weight: 500;
}

.insight-error {
  padding: 2rem;
  text-align: center;
  color: var(--error-color);
}

.insight-success {
  padding: 2rem;
  text-align: center;
  color: var(--success-color);
  font-weight: 500;
}

.issues-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 2px solid var(--border);
  background: var(--background);
}

.issues-header h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.issues-count {
  background: #22c55e;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.issues-list {
  padding: 0.5rem;
}

.issue-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
}

.issue-item:hover {
  background: rgba(168, 85, 247, 0.05); /* Light purple background */
  border-color: #a855f7; /* Purple border */
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2); /* Purple shadow */
}

.issue-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.875rem;
}

.issue-details {
  flex: 1;
}

.issue-description {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.issue-location {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Ferri Esplosi Styles */
.ferri-esplosi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 2px solid var(--border);
  background: var(--background);
}

.ferri-esplosi-header h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.bars-count {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.ferri-esplosi-list {
  padding: 0.5rem;
  max-height: calc(600px - 60px);
  overflow-y: auto;
}

.ferri-bar-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.2s;
}

.ferri-bar-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  transform: translateY(-2px);
}

.ferri-bar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--background);
}

.ferri-bar-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.ferri-bar-title {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ferri-bar-details {
  font-size: 0.95rem;
  line-height: 1.6;
}

.ferri-params {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ferri-param-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  padding: 0.5rem;
  background: var(--background);
  border-radius: 6px;
  align-items: start;
}

.ferri-param-key {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 0.9rem;
}

.ferri-param-value {
  color: var(--text-primary);
  font-size: 0.9rem;
  word-break: break-word;
}

.ferri-param-text {
  padding: 0.5rem;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.9rem;
}

/* Responsive adjustments for ferri-esplosi */
@media (max-width: 768px) {
  .ferri-param-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .ferri-bar-header {
    flex-direction: row;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .insight-results {
    flex-direction: column;
  }

  .insight-issues {
    flex: 1;
    max-height: 400px;
  }
}
