/* OCR UI — RTL Persian, Vazir font.
   Layout carried over from the Summarizer project (summarize.css), recolored
   from blue/teal to a violet/plum family:
   body #7b52ab · grid #b3b3b3 + border #b794d6 · panel #b794d6 ·
   output #e9ecef · primary button #6a3fa0/#b794d6 ·
   cancel button #eec17a/#e6af08/#79522c · accent #4a2580 */

@font-face {
  font-family: 'vazir';
  src: url('/static/fonts/Vazir.woff2') format('woff2'),
       url('/static/fonts/Vazir.woff') format('woff'),
       url('/static/fonts/Vazir.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

:root {
  --body-bg: #7b52ab;        /* violet page background (was blue #3e8bca) */
  --grid-bg: #b3b3b3;
  --grid-border: #b794d6;    /* soft lavender (was #6dbdff) */
  --panel: #b794d6;
  --surface: #ffffff;
  --output-bg: #e9ecef;
  --border: #c3ccd4;
  --text: #000000;
  --muted: #6c757d;
  --accent: #4a2580;         /* deep violet (was teal #27a09e) */
  --accent-bright: #c9a4e8;  /* light lavender (was #02b1e8) */
  --accent-dark: #3c1f68;    /* deep plum hover (was #0269e8) */
  --primary: #6a3fa0;        /* violet action button (was #3e8bca) */
  --primary-border: #b794d6;
  --secondary: #eec17a;
  --secondary-border: #e6af08;
  --secondary-text: #79522c;
  --fieldset-bg: #6a3fa0;    /* violet labels + copy button (was #3e8bca) */
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--body-bg);
  color: var(--text);
  font-family: 'vazir', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.8;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* ---------- header ---------- */

.app-header { text-align: center; margin: 8px 0 24px; }
.app-title { margin: 0; font-size: 1.6rem; color: #ffffff; }
.app-subtitle { margin: 6px 0 0; font-size: 0.95rem; color: #e8d8f7; }

/* ---------- cards (legacy layered look: gray grid → white card) ---------- */

.card {
  background: var(--grid-bg);
  border: 3px solid var(--grid-border);
  border-radius: 15px;
  padding: 4px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-inner {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---------- dropzone ---------- */

.dropzone {
  border: 2px dashed var(--grid-border);
  border-radius: var(--radius);
  background: #faf7fd;
  text-align: center;
  padding: 28px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent-dark);
  background: #f2ecfa;
  outline: none;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #ece3f7;
}

.drop-icon { font-size: 2rem; line-height: 1; }
.drop-text { margin: 10px 0 2px; font-weight: 600; color: var(--text); }
.drop-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

.drop-preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

.preview-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- actions ---------- */

.actions { display: flex; gap: 12px; margin-top: 14px; }

.btn {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

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

.btn-primary {
  background: var(--primary);
  border: 2px solid var(--primary-border);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-secondary {
  background: var(--secondary);
  border: 2px solid var(--secondary-border);
  color: var(--secondary-text);
}
.btn-secondary:hover:not(:disabled) { background: #e6b25f; }

.btn-copy {
  background: var(--fieldset-bg);
  border: 1px solid var(--grid-border);
  color: #fff;
  font-size: 0.8rem;
  padding: 4px 16px;
  border-radius: 6px;
}
.btn-copy:hover:not(:disabled) { background: var(--accent-dark); }

.btn-translate {
  background: #fff;
  border: 1px solid var(--grid-border);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 6px;
}
.btn-translate:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-translate:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-mini {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--danger);
  font-size: 0.78rem;
  padding: 3px 12px;
  border-radius: 6px;
}
.btn-mini:hover:not(:disabled) { border-color: var(--danger); }

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  padding: 3px 10px 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.btn-share:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-share:hover:not(:disabled) { border-color: var(--accent-dark); }
.btn-share .share-icon { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; }

/* ---------- status / error ---------- */

.status { min-height: 1.5em; color: var(--muted); font-size: 0.9rem; margin: 12px 0 0; }
.error { color: var(--danger); font-size: 0.9rem; margin: 12px 0 0; }

/* ---------- output ---------- */

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

.output-header h2 { margin: 0; font-size: 1.05rem; }

.output-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.log-file {
  display: block;
  margin: 10px 2px 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  direction: ltr;
  unicode-bidi: isolate;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.output {
  background: var(--output-bg);
  border-radius: 10px;
  min-height: 120px;
  padding: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.0em;
  line-height: 1.6rem;
}

/* blinking caret while the stream is active */
.output.is-streaming::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-inline-start: 4px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink { to { visibility: hidden; } }

/* ---------- responsive ---------- */

@media (max-width: 600px) {
  .container { padding: 12px 8px 40px; }
  .app-title { font-size: 1.25rem; }
  .output-actions { flex-wrap: wrap; }
}
