/* ==========================================================================
   KanoAI Gujarati Optical Character Recognition (OCR) Studio Stylesheet
   Supports Bhashini-IITJ IndicPhotoOCR, Gujarati TrOCR & GujaratiHCR
   ========================================================================== */

.ocr-workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease-out;
}

/* Header & Status Card */
.ocr-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  backdrop-filter: blur(12px);
}

.ocr-title-group h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.ocr-title-group p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.ocr-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.ocr-status-badge.connected {
  background: rgba(46, 160, 67, 0.15);
  border-color: rgba(46, 160, 67, 0.4);
  color: #3fb950;
}

.ocr-status-badge.fallback {
  background: rgba(255, 179, 0, 0.15);
  border-color: rgba(255, 179, 0, 0.4);
  color: #ffb300;
}

.ocr-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8b949e;
}

.ocr-status-badge.connected .ocr-status-dot {
  background: #3fb950;
  box-shadow: 0 0 8px #3fb950;
}

.ocr-status-badge.fallback .ocr-status-dot {
  background: #ffb300;
  box-shadow: 0 0 8px #ffb300;
}

/* Preset Showcase Cards */
.ocr-samples-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.ocr-samples-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ocr-samples-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.ocr-sample-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-fast);
  text-align: left;
}

.ocr-sample-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.ocr-sample-card.active {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.ocr-sample-thumb {
  width: 100%;
  height: 70px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #111;
  border: 1px solid var(--border-subtle);
}

.ocr-sample-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.ocr-sample-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
}

/* Two-Column Layout */
.ocr-main-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
}

/* Left Column: Image Canvas & Visualizer */
.ocr-stage-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.ocr-stage-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ocr-mode-pills {
  display: flex;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ocr-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ocr-pill-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

/* Dropzone & Preview Stage */
.ocr-dropzone-container {
  width: 100%;
  min-height: 380px;
  background: var(--stage-bg);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.ocr-dropzone-container.drag-over {
  border-color: var(--accent-primary);
  background: rgba(255, 107, 53, 0.05);
}

.ocr-dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  cursor: pointer;
  padding: 30px 20px;
}

.ocr-dropzone-icon {
  font-size: 42px;
}

.ocr-dropzone-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.ocr-dropzone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Image Visualizer with Overlays */
.ocr-canvas-wrapper {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: 520px;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-sm);
  margin: 0 auto;
  line-height: 0;
}

.ocr-display-img {
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  margin: 0 auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

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

.ocr-bbox-rect {
  position: absolute;
  border: 2px solid #00f2fe;
  background: rgba(0, 242, 254, 0.15);
  pointer-events: auto;
  cursor: pointer;
  border-radius: 3px;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.ocr-bbox-rect:hover {
  border-color: #ff6b35;
  background: rgba(255, 107, 53, 0.3);
  box-shadow: 0 0 10px rgba(255, 107, 53, 0.8);
  z-index: 10;
}

/* Drawing Whiteboard Canvas */
.ocr-draw-canvas-container {
  display: none;
  width: 100%;
  height: 340px;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  position: relative;
  touch-action: none;
}

.ocr-draw-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.ocr-draw-toolbar {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

/* Right Column: Settings Panel */
.ocr-settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.ocr-setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ocr-setting-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ocr-select, .ocr-input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

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

.ocr-info-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Action Button */
.btn-ocr-extract {
  width: 100%;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: all var(--transition-normal);
  margin-top: 10px;
}

.btn-ocr-extract:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-ocr-extract:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ocr-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

/* Results & Extracted Text Panel */
.ocr-results-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.ocr-results-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff6b35, #00f2fe);
}

.ocr-results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

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

.ocr-metrics-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ocr-metric-tag {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.ocr-metric-tag.highlight {
  border-color: var(--border-accent);
  color: var(--accent-primary);
}

/* Extracted Text Box */
.ocr-text-output-wrapper {
  position: relative;
  width: 100%;
}

.ocr-text-output {
  width: 100%;
  min-height: 180px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Noto Sans Gujarati', 'Outfit', sans-serif;
  font-size: 18px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.ocr-text-output:focus {
  border-color: var(--accent-primary);
}

/* Action Controls Bar */
.ocr-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.ocr-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-ocr-tool {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-ocr-tool:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-ocr-voice {
  background: rgba(255, 107, 53, 0.12);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 700;
}

.btn-ocr-voice:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* Toast Message */
.ocr-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  animation: slideUp 0.3s ease-out;
}

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

/* Responsive */
@media (max-width: 900px) {
  .ocr-samples-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ocr-main-layout {
    grid-template-columns: 1fr;
  }
}
