/* OCR Text Extractor — same Input → Processing → Result shape as the rest
   of the rebuilt tools, plus a segmented Upload/Camera/URL mode switch. */
.ocr-fit.ocr-scope {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 1600px; margin: 0 auto;
  padding: 90px 4vw 60px;
}

.ocr-hero { text-align: center; flex-shrink: 0; }
.ocr-hero h1 {
  font-size: 1.5rem !important; font-weight: 800 !important;
  color: var(--brand, #f59e0b) !important;
  margin: 0 0 4px !important;
}
#ocrScope .ocr-hero p {
  font-size: .85rem !important; color: var(--txt-2, #64748b) !important;
  margin: 0 auto !important; max-width: 640px;
}

#ocrScope .ocr-card {
  max-width: 100% !important; width: 100%;
  padding: 24px 32px !important;
  background: var(--page-bg, #f8fafc) !important;
  border: 1px solid var(--border, #e2e8f0) !important;
  box-shadow: none !important;
  margin: 0 auto !important;
}
.ocr-input-view { display: flex; flex-direction: column; }

.ocr-engine-status {
  text-align: center; font-size: .78rem; color: var(--txt-2, #64748b);
  margin: 0 0 12px; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ocr-engine-status.ocr-engine-ready { color: #16a34a; }
.ocr-engine-status.ocr-engine-error { color: var(--red, #ef4444); }

/* ── Upload / Camera / URL segmented control ── */
.ocr-mode-toggle {
  display: flex; gap: 4px; background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0); border-radius: 14px; padding: 5px;
  margin: 0 auto 18px; max-width: 420px; box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.ocr-mode-btn {
  flex: 1; border: none; background: transparent; padding: 11px 0; border-radius: 10px;
  font-size: .84rem; font-weight: 700; color: var(--txt-2, #64748b); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.ocr-mode-btn:hover:not(.ocr-mode-active) { background: var(--page-bg, #f8fafc); color: var(--txt, #0f172a); }
.ocr-mode-btn.ocr-mode-active {
  background: linear-gradient(135deg, var(--brand, #f59e0b), var(--brand-dark, #b45309));
  color: #fff; box-shadow: 0 6px 16px rgba(245,158,11,.35);
}

/* ── Dropzone ── */
.ocr-scope .ocr-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 220px; padding: 26px 20px; border: 2px dashed var(--brand, #f59e0b); border-radius: 14px;
  cursor: pointer; text-align: center; color: var(--txt, #0f172a);
  background: transparent; transition: border-color .2s ease, background .2s ease;
}
.ocr-scope .ocr-dropzone:hover, .ocr-scope .ocr-dropzone.ocr-dragover {
  border-color: var(--brand-dark, #b45309); background: rgba(245,158,11,.06);
}
.ocr-scope .ocr-dropzone i {
  color: var(--brand, #f59e0b); font-size: 2.2rem;
  animation: ocrIconFloat 2.4s ease-in-out infinite;
}
@keyframes ocrIconFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .ocr-scope .ocr-dropzone i { animation: none; } }
.ocr-drop-title { font-weight: 700; margin-top: 10px; font-size: .95rem; color: var(--txt, #0f172a); }
.ocr-drop-sub { font-size: .8rem; opacity: .65; margin-top: 4px; color: var(--txt-2, #64748b); }

/* ── Camera ── */
.ocr-camera-wrap {
  position: relative; min-height: 220px; border-radius: 14px; overflow: hidden;
  background: #0f172a; display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.ocr-camera-video, .ocr-camera-wrap canvas { width: 100%; max-height: 360px; object-fit: contain; }
.ocr-camera-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #64748b; font-size: .85rem; }
.ocr-camera-placeholder i { font-size: 2rem; }

/* ── Preview row (shown once an image is loaded, any tab) ── */
#ocrPreviewRow {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0);
}
.ocr-chip-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--page-bg, #f1f5f9); }

.ocr-resize-row { display: flex; align-items: center; gap: 8px; }
.ocr-resize-row input[type="url"] {
  height: 42px; padding: 0 14px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  background: var(--surface, #fff); color: var(--txt, #0f172a); font-size: .85rem;
}

.ocr-enhance-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ocr-select {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  background: var(--surface, #fff); color: var(--txt, #0f172a); font-size: .82rem;
}

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 20px; }
#ocrScope #ocrProcessBtn, #ocrScope #ocrCopyBtn, #ocrScope #ocrStartCameraBtn, #ocrScope #ocrCaptureBtn, #ocrScope #ocrLoadUrlBtn {
  background: linear-gradient(135deg, var(--brand, #f59e0b), var(--brand-dark, #b45309));
  border: none; padding: 13px 26px; font-weight: 700; font-size: .95rem; border-radius: 12px;
  box-shadow: 0 10px 24px rgba(245,158,11,.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
#ocrScope #ocrProcessBtn:hover, #ocrScope #ocrCopyBtn:hover, #ocrScope #ocrStartCameraBtn:hover, #ocrScope #ocrCaptureBtn:hover, #ocrScope #ocrLoadUrlBtn:hover {
  transform: translateY(-2px); box-shadow: 0 14px 30px rgba(245,158,11,.45);
}
#ocrScope .btn-warning, #ocrScope .btn-info { padding: 13px 26px; font-weight: 700; font-size: .95rem; border-radius: 12px; }

.ocr-shake { animation: ocrShake .4s ease; }
@keyframes ocrShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce) { .ocr-shake { animation: none; } }

/* ── Processing ── */
.ocr-processing { padding: 10px 0 4px; }
.ocr-ring-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto 18px; }
.ocr-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ocr-ring-track { fill: none; stroke: var(--border, #e2e8f0); stroke-width: 8; }
.ocr-ring-fill {
  fill: none; stroke: var(--brand, #f59e0b); stroke-width: 8;
  stroke-linecap: round; transition: stroke-dashoffset .2s ease;
  filter: drop-shadow(0 0 6px rgba(245,158,11,.45));
}
.ocr-ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--txt, #0f172a); }
.ocr-ring-count { font-size: 2.1rem; line-height: 1; }
.ocr-ring-percent { font-size: 1.1rem; opacity: .7; margin-left: 2px; }

.ocr-process-steps { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 22px; }
.ocr-process-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; color: var(--txt-2, #64748b);
  opacity: .55; transition: opacity .2s ease;
}
.ocr-process-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface, #fff); border: 2px solid var(--border, #e2e8f0);
  color: var(--txt-2, #64748b); font-size: .9rem;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.ocr-process-line { width: 30px; height: 2px; background: var(--border, #e2e8f0); }
.ocr-process-step.ocr-step-active { opacity: 1; }
.ocr-process-step.ocr-step-active .ocr-process-icon {
  border-color: var(--brand, #f59e0b); color: var(--brand, #f59e0b);
  box-shadow: 0 0 0 4px rgba(245,158,11,.12);
  animation: ocrPulseStep 1.3s ease-in-out infinite;
}
.ocr-process-step.ocr-step-done { opacity: 1; }
.ocr-process-step.ocr-step-done .ocr-process-icon { border-color: #16a34a; color: #fff; background: #16a34a; }
@keyframes ocrPulseStep {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245,158,11,.12); }
  50%      { box-shadow: 0 0 0 8px rgba(245,158,11,.04); }
}
@media (prefers-reduced-motion: reduce) { .ocr-process-step.ocr-step-active .ocr-process-icon { animation: none; } }
.ocr-progress-text { font-size: .85rem; margin-top: 10px; color: var(--txt, #0f172a); font-weight: 600; text-align: center; }

/* ── Result ── */
.ocr-result-head { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.ocr-result-icon { font-size: 1.4rem; color: #16a34a; }
.ocr-result-head h3 { font-size: 1rem !important; font-weight: 800 !important; color: var(--txt, #0f172a) !important; margin: 0 !important; }

.ocr-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.ocr-stat-card { text-align: center; padding: 12px 8px; border-radius: 10px; background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); }
.ocr-stat-value { font-size: 1.2rem; font-weight: 800; color: var(--brand, #f59e0b); }
.ocr-stat-label { font-size: .7rem; color: var(--txt-2, #64748b); margin-top: 2px; }

.ocr-result-textarea {
  width: 100%; min-height: 260px; resize: vertical;
  border: 1px solid var(--border, #e2e8f0); border-radius: 12px;
  background: var(--surface, #fff); color: var(--txt, #0f172a);
  padding: 14px 16px; font-size: .85rem; line-height: 1.6;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.ocr-result-textarea:focus { border-color: var(--brand, #f59e0b); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }

.hidden { display: none !important; }

/* ── Options accordion (same pattern as Image Resizer & Converter) ── */
.ict-accordion { display: flex; flex-direction: column; gap: 8px; }
.ict-acc-section {
  border: 1px solid var(--border, #e2e8f0); border-radius: 12px;
  background: var(--page-bg, #f8fafc); overflow: hidden;
}
.ict-acc-header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border: none; background: transparent; cursor: pointer;
  font-size: .86rem; font-weight: 700; color: var(--txt, #0f172a); text-align: left;
}
.ict-acc-header-left { display: flex; align-items: center; gap: 9px; }
.ict-acc-header-left i.fa-solid:first-child { color: var(--brand, #f59e0b); width: 16px; text-align: center; }
.ict-acc-chevron { color: var(--txt-2, #64748b); font-size: .78rem; transition: transform .2s ease; flex-shrink: 0; }
.ict-acc-section.ict-acc-open .ict-acc-chevron { transform: rotate(180deg); }
.ict-acc-content { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.ict-acc-section.ict-acc-open .ict-acc-content { max-height: 900px; }
.ict-acc-content > .ict-opt-group { padding: 0 16px 16px; margin-bottom: 0; }

.ict-opt-group { margin-bottom: 14px; }
.ict-opt-label { display: block; font-size: .82rem; font-weight: 700; color: var(--txt, #0f172a); margin-bottom: 8px; }
.ict-opt-label-sub { margin-top: 12px; }
.ict-opt-hint { font-weight: 500; color: var(--txt-2, #64748b); font-size: .74rem; }
.ict-checkbox { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--txt-2, #64748b); cursor: pointer; }
.ict-checkbox input { accent-color: var(--brand, #f59e0b); }
.ict-autosave { margin-top: 10px; text-align: center; font-size: .82rem; color: var(--txt-2, #64748b); }
.ict-chip-name { font-weight: 600; font-size: .85rem; color: var(--txt, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ict-chip-remove {
  width: 26px; height: 26px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; color: #fff; font-size: .78rem; cursor: pointer;
  background: var(--red, #ef4444); transition: background .15s ease, transform .15s ease;
}
.ict-chip-remove:hover { background: #dc2626; transform: scale(1.08); }
.ict-chip-view {
  width: 26px; height: 26px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; color: #fff; font-size: .78rem; cursor: pointer;
  background: var(--brand, #f59e0b); transition: background .15s ease, transform .15s ease;
}
.ict-chip-view:hover { background: var(--brand-dark, #b45309); transform: scale(1.08); }

/* ── Options modal — same shape as Image Resizer & Converter's popup ── */
.ocr-modal {
  position: fixed; inset: 0; z-index: 100060;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.ocr-modal.ocr-modal-open { display: flex; }
.ocr-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.6); animation: ocrFadeIn .15s ease; }
.ocr-modal-box {
  position: relative; z-index: 1; width: 100%; max-width: 520px; max-height: 90vh;
  background: var(--surface, #fff); border-radius: 18px; padding: 26px;
  box-shadow: 0 30px 60px rgba(0,0,0,.35); animation: ocrPopIn .18s ease;
  display: flex; flex-direction: column;
}
.ocr-modal-title { margin: 0 0 2px; font-size: 1.1rem; font-weight: 800; color: var(--txt, #0f172a); display: flex; align-items: center; gap: 8px; }
.ocr-modal-title i { color: var(--brand, #f59e0b); }
.ocr-modal-sub { margin: 0 0 16px; font-size: .8rem; color: var(--txt-2, #64748b); }
.ocr-modal-close {
  position: absolute; top: -12px; right: -12px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand, #f59e0b); color: #fff; border: none; cursor: pointer; font-size: 1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.ocr-modal-body { overflow-y: auto; flex: 1; padding-right: 4px; }
.ocr-modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-shrink: 0; }
@keyframes ocrFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ocrPopIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.ocr-modal-box .ict-acc-content > .ict-opt-group { padding: 0 16px 16px; margin-bottom: 0; }

html[data-theme="dark"] #ocrScope .ocr-card { background: var(--surface, #11111a) !important; }
html[data-theme="dark"] .ocr-modal-box { background: var(--surface, #11111a); }

/* ── Full-image preview popup — same large overlay shape as a crop editor,
   just showing the image with no crop box. ── */
.ocr-crop-modal {
  position: fixed; inset: 0; z-index: 100070;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.ocr-crop-modal.ocr-modal-open { display: flex; }
.ocr-crop-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.75); animation: ocrFadeIn .15s ease; }
.ocr-crop-modal-box {
  position: relative; z-index: 1; width: 100%; max-width: 860px;
  background: var(--surface, #fff); border-radius: 18px; padding: 22px 26px;
  box-shadow: 0 30px 60px rgba(0,0,0,.4); animation: ocrPopIn .18s ease;
  max-height: 92vh; overflow-y: auto;
}
.ocr-crop-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ocr-crop-modal-head .ocr-modal-close { position: static; top: auto; right: auto; flex-shrink: 0; }
.ocr-crop-modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--txt, #0f172a); display: flex; align-items: center; gap: 8px; }
.ocr-crop-modal-head h3 i { color: var(--brand, #f59e0b); }
.ocr-crop-wrap {
  width: 100%; max-height: 70vh; border-radius: 10px; overflow: hidden;
  background: #0f172a; display: flex; align-items: center; justify-content: center;
}
.ocr-crop-wrap img { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; }
html[data-theme="dark"] .ocr-crop-modal-box { background: var(--surface, #11111a); }

@media (max-width: 600px) {
  .ocr-enhance-grid { grid-template-columns: 1fr; }
  .ocr-stats { grid-template-columns: repeat(2, 1fr); }
}
