/* ==========================================================================
   IndicOCR v2 Design System & Archival Studio Styles
   Tailored for Devanagari and Latin multi-script typography
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-indic: 'Noto Sans Devanagari', -apple-system, sans-serif;

  /* Color Palette - Premium Slate & Saffron Accent */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-hover: #475569;

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

  --accent-primary: #f59e0b; /* Indic saffron */
  --accent-hover: #d97706;
  --accent-subtle: rgba(245, 158, 11, 0.15);

  --border-subtle: #334155;
  --border-strong: #475569;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.15);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-hover: #e2e8f0;

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

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Indic script font class */
.indic-text {
  font-family: var(--font-indic), var(--font-sans);
  line-height: 1.8;
  letter-spacing: 0.01em;
}

/* App Header / Navigation */
.app-header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-subtle);
  color: var(--accent-primary);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

/* Privacy Guarantee Banner Pill */
.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: help;
  transition: all 0.2s ease;
}

.privacy-badge:hover {
  background: rgba(16, 185, 129, 0.25);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Primary and Secondary Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

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

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-outline.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

/* Language selector */
.select-input {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--accent-primary);
}

/* Main App Container */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Upload View */
.upload-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
}

.dropzone-card {
  max-width: 680px;
  width: 100%;
  background: var(--bg-secondary);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 48px 36px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-lg);
}

.dropzone-card.drag-active {
  border-color: var(--accent-primary);
  background-color: rgba(245, 158, 11, 0.05);
  transform: scale(1.01);
}

.dropzone-icon {
  font-size: 54px;
  margin-bottom: 16px;
  color: var(--accent-primary);
}

.dropzone-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.dropzone-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.dropzone-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 32px;
  text-align: left;
}

.feature-item {
  background: var(--bg-tertiary);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.feature-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.feature-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Pre-Flight Modal & Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.preflight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Floating Bottom-Right Progress Widget */
.progress-screen {
  position: fixed;
  bottom: 112px;
  right: 24px;
  z-index: 1000;
  width: 420px;
  max-width: calc(100vw - 48px);
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  animation: slideUpFloat 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .progress-screen {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

@keyframes slideUpFloat {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.progress-screen.minimized {
  width: auto;
  padding: 8px 16px;
  cursor: pointer;
}

.progress-screen.minimized .progress-body {
  display: none;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-bar-container {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Split-Screen Review Studio */
.studio-layout {
  flex: 1;
  display: flex;
  height: 100%;
  overflow: hidden;
}

.studio-left, .studio-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.studio-left {
  border-right: 1px solid var(--border-subtle);
  background: #000000;
}

.pane-toolbar {
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Original Scan Viewer Container */
.scan-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #18181b;
  padding: 24px;
  user-select: none;
  -webkit-user-select: none;
}

.scan-viewport.hand-mode {
  cursor: grab;
}

.scan-viewport.hand-mode * {
  cursor: grab;
}

.scan-viewport.is-dragging,
.scan-viewport.is-dragging * {
  cursor: grabbing !important;
}

.scan-viewport.hand-mode .bbox-highlight,
.scan-viewport.is-dragging .bbox-highlight {
  pointer-events: none !important;
}

.scan-canvas-wrapper {
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  border-radius: 4px;
  overflow: visible;
  will-change: transform;
  transform-origin: center center;
}

.scan-image {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}

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

.bbox-highlight {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.bbox-high {
  border: 1.5px solid rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
}

.bbox-med {
  border: 1.5px solid rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.15);
}

.bbox-low {
  border: 2px solid rgba(239, 68, 68, 0.9);
  background: rgba(239, 68, 68, 0.25);
  animation: pulseLow 2s infinite ease-in-out;
}

@keyframes pulseLow {
  0%, 100% { border-color: rgba(239, 68, 68, 0.9); }
  50% { border-color: rgba(239, 68, 68, 0.4); }
}

.bbox-highlight:hover, .bbox-highlight.active {
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.35) !important;
  z-index: 20;
}

/* Structured Text Editor Container */
.editor-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  background: var(--bg-primary);
}

.editor-card {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 36px;
  box-shadow: var(--shadow-sm);
  min-height: 100%;
}

.block-item {
  margin-bottom: 24px;
  position: relative;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.block-item:hover, .block-item.focused {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.block-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.block-paragraph {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
}

.block-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  user-select: none;
}

/* Flagged Word in Text */
.flagged-word {
  background: var(--warning-bg);
  border-bottom: 2px solid var(--warning);
  padding: 0 3px;
  border-radius: 2px;
  cursor: pointer;
}

.flagged-word.critical {
  background: var(--danger-bg);
  border-bottom-color: var(--danger);
}

/* Filmstrip Bottom Bar */
.filmstrip-container {
  height: 96px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  overflow-x: auto;
  user-select: none;
}

.filmstrip-thumb {
  width: 60px;
  height: 76px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s ease;
}

.filmstrip-thumb:hover {
  transform: translateY(-2px);
  border-color: var(--text-secondary);
}

.filmstrip-thumb.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
}

/* Diff Inspector Box */
.diff-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 8px;
}

.diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.diff-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.diff-before {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-decoration: line-through;
  color: var(--danger);
}

.diff-after {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
}

.diff-reason {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 10px;
}

.diff-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Gemini AI Assistant Styles
   ========================================================================== */
.gemini-sub-toolbar {
  transition: all 0.2s ease;
}

.gemini-sub-toolbar button:hover {
  background: rgba(167, 139, 250, 0.2) !important;
  border-color: rgba(167, 139, 250, 0.6) !important;
  color: #ffffff !important;
}

.gemini-modal-content {
  border-color: rgba(138, 92, 246, 0.3) !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 0 20px rgba(138, 92, 246, 0.15) !important;
}

#btn-gemini-ai:hover {
  background: rgba(167, 139, 250, 0.18) !important;
  border-color: rgba(167, 139, 250, 0.7) !important;
}

/* User Guide Modal Styles */
.guide-modal-content {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.guide-step-card {
  transition: border-color 0.15s ease;
}

.guide-step-card:hover {
  border-color: var(--accent-primary) !important;
}

.guide-tab-bar button {
  transition: all 0.15s ease;
}


