/* ==========================================================================
   VisionText AI - Core Design System & Styling
   Aesthetic: Deep Futuristic Glassmorphism, Neon Accents, Ultra-Clean Typography
   ========================================================================== */

:root {
  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark Theme Palette (Default) */
  --bg-app: #080b12;
  --bg-surface: #0f1523;
  --bg-surface-elevated: #161e31;
  --bg-glass: rgba(18, 25, 41, 0.72);
  --bg-glass-hover: rgba(28, 38, 62, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(6, 182, 212, 0.55);
  --border-glow: rgba(139, 92, 246, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-highlight: #38bdf8;

  /* Vibrant Accents */
  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;
  --violet-400: #a78bfa;
  --violet-500: #8b5cf6;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --amber-400: #fbbf24;
  --rose-400: #fb7185;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
  --grad-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
  --grad-glow: radial-gradient(circle at 50% 0%, rgba(6, 182, 212, 0.15) 0%, transparent 70%);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.25);
  --shadow-glow-violet: 0 0 25px rgba(139, 92, 246, 0.25);

  /* Bounding Box Colors */
  --box-border: #06b6d4;
  --box-bg: rgba(6, 182, 212, 0.15);
  --box-hover-border: #a78bfa;
  --box-hover-bg: rgba(167, 139, 250, 0.35);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Light Theme Variables */
body.light-theme {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-hover: rgba(241, 245, 249, 0.95);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(6, 182, 212, 0.7);
  --border-glow: rgba(139, 92, 246, 0.3);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-highlight: #0284c7;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);

  --box-border: #0284c7;
  --box-bg: rgba(2, 132, 199, 0.18);
  --box-hover-border: #7c3aed;
  --box-hover-bg: rgba(124, 58, 237, 0.25);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Background Atmosphere Glow */
body::before {
  content: "";
  position: fixed;
  top: -10vw;
  left: 20vw;
  width: 60vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, rgba(139, 92, 246, 0.04) 50%, transparent 80%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

/* App Shell */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Top Navigation Bar */
.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Brand Logo */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.brand-icon-glow {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.brand-icon {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-highlight {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: -3px;
}

/* Hardware Status Badge */
.hardware-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald-400);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--emerald-400);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--emerald-400);
  animation: pulse-ring 2s infinite ease-in-out;
}

/* Engine Selector Dropdown */
.engine-selector-wrap {
  display: flex;
  align-items: center;
}

.engine-select-dropdown {
  background: var(--bg-surface-elevated);
  color: var(--cyan-400);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.engine-select-dropdown:hover, .engine-select-dropdown:focus {
  border-color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.1);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
}

.engine-select-dropdown option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Sample Pills */
.sample-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pills-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pill-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.pill-btn:hover {
  color: var(--text-primary);
  border-color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.1);
  transform: translateY(-1px);
}

/* Icon Buttons */
.icon-action-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-action-btn:hover {
  color: var(--text-primary);
  border-color: var(--cyan-400);
  background: var(--bg-surface-elevated);
}

/* ==========================================================================
   Workspace Split Grid Layout
   ========================================================================== */

.workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Panels */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}

.panel-left {
  display: flex;
  flex-direction: column;
}

.panel-right {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Left Panel: Dropzone & Interactive Canvas Stage
   ========================================================================== */

/* Dropzone Area */
.dropzone-area {
  flex: 1;
  margin: 16px;
  border: 2px dashed rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  background: var(--grad-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.dropzone-area:hover, .dropzone-area.drag-over {
  border-color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: inset 0 0 40px rgba(6, 182, 212, 0.1);
}

.dropzone-content {
  text-align: center;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.dropzone-icon-box {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: var(--cyan-400);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  animation: float-icon 4s ease-in-out infinite;
}

@keyframes float-icon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.dropzone-heading {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
}

.dropzone-cta-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.keyboard-paste-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.keyboard-paste-badge strong {
  color: var(--cyan-400);
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Stage Container (Active Image & Canvas) */
.stage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #05080e;
}

.stage-toolbar {
  height: 44px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-name-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-dims-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: 4px;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stage-tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--cyan-400);
}

.stage-tool-btn.active {
  color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--cyan-400);
}

/* Canvas Viewport */
.canvas-viewport {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

.canvas-stage {
  position: relative;
  display: inline-block;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.source-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 300px);
  object-fit: contain;
  user-select: none;
}

/* Interactive Bounding Boxes Overlay */
.boxes-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.ocr-bbox {
  position: absolute;
  border: 1.5px solid var(--box-border);
  background-color: var(--box-bg);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.ocr-bbox:hover, .ocr-bbox.highlighted {
  border: 2px solid var(--box-hover-border);
  background-color: var(--box-hover-bg);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.7);
  z-index: 10;
}

.ocr-bbox-label {
  position: absolute;
  top: -18px;
  left: -1px;
  background: var(--violet-500);
  color: #fff;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ocr-bbox:hover .ocr-bbox-label, .ocr-bbox.highlighted .ocr-bbox-label {
  opacity: 1;
}

/* ==========================================================================
   Vision Preprocessing & Filter Toolbar (Bottom Left)
   ========================================================================== */

.controls-card {
  padding: 14px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

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

.header-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Custom Toggle Switch */
.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 28px;
  height: 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-control input:checked + .toggle-slider {
  background: var(--cyan-500);
  border-color: var(--cyan-400);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.toggle-control input:checked + .toggle-slider::after {
  transform: translateX(12px);
  background: #fff;
}

/* Slider Row */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.slider-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 130px;
}

.slider-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.slider-value {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--cyan-400);
}

.confidence-range {
  flex: 1;
  accent-color: var(--cyan-500);
  cursor: pointer;
  height: 4px;
}

/* ==========================================================================
   Right Panel: Intelligence HUD, Tabs, Views, Exports
   ========================================================================== */

/* Telemetry HUD Bar */
.telemetry-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.metric-icon {
  font-size: 1.1rem;
}

.metric-data {
  display: flex;
  flex-direction: column;
}

.metric-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.metric-sub {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Results Navigation & Search */
.results-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.tabs-list {
  display: flex;
  gap: 4px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab-item {
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.tab-item.active {
  color: #fff;
  background: var(--grad-primary);
  box-shadow: var(--shadow-sm);
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  color: var(--text-muted);
  transition: border-color 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--cyan-400);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-primary);
  width: 140px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-count {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--cyan-400);
}

/* ==========================================================================
   Output Views Container
   ========================================================================== */

.output-viewport {
  flex: 1;
  position: relative;
  overflow: auto;
  padding: 16px;
  background: var(--bg-surface);
}

/* Loading Overlay */
.loading-state {
  position: absolute;
  inset: 0;
  background: rgba(15, 21, 35, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 20;
}

.spinner-core {
  position: relative;
  width: 64px;
  height: 64px;
}

.spinner-ring {
  width: 100%;
  height: 100%;
  border: 3px solid rgba(6, 182, 212, 0.15);
  border-top-color: var(--cyan-400);
  border-right-color: var(--violet-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-glow {
  position: absolute;
  inset: 4px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.3) 0%, transparent 70%);
  filter: blur(8px);
}

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

.loading-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.loading-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Empty State */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

.empty-illustration {
  color: var(--cyan-500);
  opacity: 0.4;
  margin-bottom: 16px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 0.85rem;
  max-width: 340px;
  line-height: 1.5;
}

/* View Panels */
.view-panel {
  display: none;
  height: 100%;
}

.view-panel.active {
  display: block;
}

/* VIEW 1: Formatted Document Text */
.formatted-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  outline: none;
  background: var(--bg-surface-elevated);
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  min-height: 100%;
  font-family: var(--font-body);
}

.formatted-content:focus {
  border-color: var(--border-focus);
}

/* VIEW 2: Itemized Line Blocks */
.blocks-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.block-row:hover, .block-row.highlighted {
  border-color: var(--violet-400);
  background: rgba(139, 92, 246, 0.08);
  transform: translateX(3px);
}

.block-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
}

.block-index {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.block-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  word-break: break-word;
}

.confidence-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  flex-shrink: 0;
}

.conf-high {
  color: var(--emerald-400);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.conf-mid {
  color: var(--amber-400);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.conf-low {
  color: var(--rose-400);
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.25);
}

/* VIEW 3: Table / Key-Value Container */
.table-container {
  overflow-x: auto;
}

.ocr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ocr-table th, .ocr-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.ocr-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
}

.ocr-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* VIEW 4: JSON Code View */
.json-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: #38bdf8;
  background: #05080e;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: auto;
}

/* Search Highlights */
mark.search-highlight {
  background: rgba(251, 191, 36, 0.35);
  color: #fff;
  border-bottom: 2px solid var(--amber-400);
  padding: 0 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Footer Action Bar
   ========================================================================== */

.results-footer {
  height: 56px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.footer-exports {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.45);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  color: #fff;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.5);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--cyan-400);
  background: rgba(6, 182, 212, 0.1);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.72rem;
}

/* ==========================================================================
   Toast Notification Component
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-focus);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  animation: slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.toast-fade {
  animation: slide-out 0.25s forwards ease-in;
}

@keyframes slide-out {
  to { transform: translateX(50px); opacity: 0; }
}

/* Utilities */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-400);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }

  html, body {
    overflow: auto;
  }

  .panel {
    min-height: 500px;
  }
}

/* ==========================================================================
   AI Information Extraction & FreeLLMAPI View Styles
   ========================================================================== */

.tab-item-ai {
  background: rgba(139, 92, 246, 0.12) !important;
  color: var(--violet-400) !important;
  border: 1px solid rgba(139, 92, 246, 0.3) !important;
}

.tab-item-ai:hover {
  background: rgba(139, 92, 246, 0.25) !important;
  border-color: var(--violet-400) !important;
}

.tab-item-ai.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%) !important;
  color: #fff !important;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.4) !important;
}

.ai-extract-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

/* API Config Card */
.ai-config-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-config-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-primary);
}

.ai-sparkle-icon {
  font-size: 1.1rem;
}

.ai-status-pill {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--cyan-400);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.ai-inputs-grid {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.5fr;
  gap: 12px;
}

.ai-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-field label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.ai-field input, .ai-select-dropdown {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.ai-select-dropdown {
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
}

.ai-select-dropdown option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.ai-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.openrouter-link {
  font-size: 0.72rem;
  color: var(--cyan-400);
  text-decoration: none;
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(6, 182, 212, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  transition: all 0.15s ease;
}

.openrouter-link:hover {
  background: rgba(6, 182, 212, 0.2);
  color: #fff;
}
  outline: none;
  transition: border-color 0.2s ease;
}

.ai-field input:focus {
  border-color: var(--violet-400);
}

.ai-action-bar {
  display: flex;
  justify-content: flex-end;
}

/* Q&A Card */
.ai-qa-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qa-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qa-input-row input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
}

.qa-input-row input:focus {
  border-color: var(--cyan-400);
}

.qa-answer-box {
  background: rgba(6, 182, 212, 0.08);
  border-left: 3px solid var(--cyan-400);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.qa-answer-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cyan-400);
  margin-bottom: 4px;
}

/* Results Metadata Grid */
.ai-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.ai-meta-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-meta-card.highlight {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.06);
}

.ai-meta-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ai-meta-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-meta-card.highlight .ai-meta-val {
  color: var(--emerald-400);
}

/* Executive Summary Box */
.ai-summary-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-summary-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ai-summary-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Items Section & JSON */
.ai-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.ai-json-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

