/* RAG UI — RTL Persian, Vazir font.
   Look carried over from the summarizer project (summarize.css), recolored
   to a GREEN family (this project's theme):
   body #2e7d32 · grid #b3b3b3 + border #a5d6a7 · panel #a5d6a7 ·
   output #e9ecef · primary button #2e7d32/#81c784 ·
   cancel button #eec17a/#e6af08/#79522c (amber, as summarizer) · accent #1b5e20 */

@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: #2e7d32;      /* deep green page background */
  --grid-bg: #b3b3b3;      /* legacy gray grid layer */
  --grid-border: #a5d6a7;  /* light green card border */
  --panel: #a5d6a7;
  --surface: #ffffff;
  --output-bg: #e9ecef;
  --border: #c3ccd4;
  --text: #000000;
  --muted: #6c757d;
  --accent: #1b5e20;       /* deep green */
  --accent-bright: #66bb6a;
  --accent-dark: #14521a;  /* darker green hover */
  --primary: #2e7d32;      /* green action button */
  --primary-border: #81c784;
  --secondary: #eec17a;    /* amber cancel (as summarizer) */
  --secondary-border: #e6af08;
  --secondary-text: #79522c;
  --fieldset-bg: #2e7d32;  /* green labels + copy button */
  --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-logo { height: 84px; width: auto; max-width: 100%; }
.app-header h1 { margin: 10px 0 0; font-size: 1.5rem; color: #ffffff; }

/* ---------- 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;
}

/* ---------- input ---------- */

.field-label {
  display: block;
  margin: 4px 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fieldset-bg);
}

select.collection-select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  cursor: pointer;
}

select.collection-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

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

textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

textarea {
  width: 100%;
  min-height: 84px;
  resize: none;
  overflow: hidden;          /* never show a scrollbar — the box grows to fit */
  overflow-wrap: anywhere;   /* long unbroken strings wrap instead of scrolling */
}

/* ---------- 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-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; }

/* ---------- view toggle (plain vs markdown) ---------- */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 3px 12px;
  border: none;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-btn + .view-btn { border-inline-start: 1px solid var(--border); }

.view-btn.is-active {
  background: var(--fieldset-bg);
  color: #fff;
}

.view-btn:hover:not(.is-active) { color: var(--accent-dark); }

/* ---------- status / error / pipeline progress ---------- */

.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; }

.pipeline-progress { margin-top: 14px; }
.progress-track {
  height: 8px;
  border-radius: 4px;
  background: var(--output-bg);
  overflow: hidden;
}
/* width% in an RTL block grows from the right edge — the natural direction */
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent-dark));
  transition: width 0.3s ease;
}

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

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

.output-header-spaced { margin-top: 24px; }

.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; } }

/* ---------- sources ---------- */

.sources-section { margin-top: 4px; }

.sources-count { font-size: 0.8rem; color: var(--muted); }

.sources-list {
  margin: 0;
  padding-inline-start: 22px;
  background: var(--output-bg);
  border-radius: 10px;
  padding: 14px 22px;
  display: grid;
  gap: 8px;
}

.sources-list li { font-size: 0.9rem; line-height: 1.6; }

.sources-list .source-title { font-weight: 600; }

.sources-list .source-url {
  display: block;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--accent);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.sources-list .source-meta { font-size: 0.78rem; color: var(--muted); }

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

@media (max-width: 600px) {
  .container { padding: 12px 8px 40px; }
  .app-logo { height: auto; }          /* scale the wide banner to the viewport */
  .output-actions { flex-wrap: wrap; }
}
