/*
 * Briefer auth-overlay styles — externalized so the CSP can keep
 * `style-src 'self'` without `'unsafe-inline'`. This used to be a
 * runtime `<style>` injection by `briefer-api.js#injectStyles()`,
 * which the post-v1.0.1 CSP-tightening pass moved here.
 *
 * Two responsibilities:
 *   1. FOUC guard — hide the intake form before its first paint when
 *      the user has no session token. `briefer-api.js` toggles
 *      `html.briefer-locked` synchronously before the parser yields.
 *   2. Auth chrome — login modal, top bar, brief picker, modals list.
 *      Mounted by `briefer-api.js` at runtime; this stylesheet renders
 *      it whether or not the JS has finished setting up.
 */

/* ---------- FOUC guard ----------
   `briefer-api.js` adds `html.briefer-locked` synchronously at the top
   of its IIFE when no session token is present, and removes the class
   in `mountAuthenticatedShell()` once auth is resolved. Keeps every
   body child invisible during the brief window between HTML parsing
   and JS executing — except the login overlay itself. */
html.briefer-locked body > *:not(#briefer-login):not(.briefer-overlay) {
  visibility: hidden !important;
}

/* ---------- Overlay scrim + modals ---------- */
.briefer-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15,23,42,0.55); display: flex;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  font-family: var(--font-body, ui-sans-serif, system-ui);
}
.briefer-modal {
  background: #fff;
  /* The page sets `color: var(--lop-text-primary, #fff)` on body for the
     dark intake form. Without an explicit override here, every text
     element inside the modal — picker rows, history rows, the login
     subtitle — would inherit white-on-white and be invisible until
     hover (when `:hover` repaints the background). Lock to slate-900. */
  color: #0f172a;
  border-radius: 14px;
  padding: 28px 32px; width: min(420px, 92vw);
  box-shadow: 0 30px 80px rgba(0,0,0,0.25);
}
/* Wide-modal variant — used by the brief picker and revision history. */
.briefer-modal--wide { width: min(560px, 92vw); }

/* Logomark inside a modal — sits above the title in the login form. */
.briefer-modal-brand {
  display: flex; justify-content: center;
  margin-bottom: 14px;
}
.briefer-modal-brand img {
  height: 64px; width: auto;
  display: block;
}
.briefer-modal h2 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.briefer-modal p.sub { text-align: center; }
.briefer-modal p.sub { color: #475569; margin: 0 0 18px; font-size: 14px; }
.briefer-modal label { display: block; font-size: 13px; color: #334155; margin-top: 14px; }
.briefer-modal input[type="email"],
.briefer-modal input[type="password"],
.briefer-modal input[type="text"],
.briefer-modal input[type="search"] {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; margin-top: 4px;
}
.briefer-modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.briefer-btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; font-size: 14px; font-weight: 500;
}
.briefer-btn.primary { background: #1d4ed8; color: #fff; }
.briefer-btn.primary:hover { background: #1e40af; }
.briefer-btn.ghost { background: #fff; color: #334155; border-color: #cbd5e1; }
.briefer-btn.ghost:hover { background: #f1f5f9; }
.briefer-error {
  background: #fee2e2; color: #991b1b;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; margin-top: 10px;
}

/* ---------- Top bar (mounted post-auth) ---------- */
.briefer-topbar {
  position: sticky; top: 0; z-index: 500;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px;
  background: #0f172a; color: #f1f5f9;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  border-bottom: 1px solid #1e293b;
}
.briefer-topbar .brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: inherit;
  font-weight: 600; letter-spacing: 0.02em;
}
.briefer-topbar .brand img {
  height: 22px; width: auto;
  display: block;
}
.briefer-topbar .brand:hover { color: #fff; }

/* Three-button language picker (ES / EN / PT) in the topbar. The active
   language gets the teal highlight; the inactive ones are subdued. */
.briefer-lang-picker {
  display: inline-flex;
  margin-right: 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
}
.briefer-lang-picker button {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 4px 8px !important;
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: transparent !important;
  color: #94a3b8 !important;
  border: 0 !important;
  border-radius: 0 !important;
  cursor: pointer;
}
.briefer-lang-picker button + button { border-left: 1px solid #334155 !important; }
.briefer-lang-picker button:hover { background: #1e293b !important; color: #f1f5f9 !important; }
.briefer-lang-picker button.active {
  background: #00d4b8 !important; color: #0a1628 !important;
}
.briefer-lang-picker .lang-flag {
  /* SVG flags hosted in `/static/flags/` (es.svg / us.svg / br.svg).
     Switched from emoji because Windows often renders flag emoji as
     regional-indicator letters. SVGs are 100% reliable across browsers
     + OSes. Sized to match the lang-code ascender height. */
  width: 18px; height: 12px;
  display: inline-block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
  vertical-align: -2px;
}
.briefer-lang-picker .lang-code {
  letter-spacing: 0.04em;
  line-height: 1;
}
.briefer-lang-picker button.active .lang-flag {
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
.briefer-topbar .ctx { color: #94a3b8; }
.briefer-topbar .ctx strong { color: #e2e8f0; font-weight: 600; }
.briefer-topbar .spacer { flex: 1; }
.briefer-topbar button {
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
  background: #1e293b; color: #e2e8f0; border: 1px solid #334155; cursor: pointer;
}
.briefer-topbar button:hover { background: #334155; }
.briefer-topbar button.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.briefer-topbar button.primary:hover { background: #1e40af; }
.briefer-topbar button.danger { background: transparent; color: #fca5a5; border-color: transparent; }

/* ---------- Brief picker / history modal lists ---------- */
.briefer-list { max-height: 420px; overflow: auto; margin-top: 10px; }
.briefer-list .row { padding: 10px; border-bottom: 1px solid #e2e8f0; cursor: pointer; }
.briefer-list .row:hover { background: #f1f5f9; }
.briefer-list .row .meta { color: #64748b; font-size: 12px; }

/* Result counter — sits between the search input and the list. */
.briefer-list-meta {
  margin-top: 12px;
  font-size: 11px;
  color: #64748b;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.briefer-list-empty {
  padding: 20px 10px;
  color: #64748b;
  font-style: italic;
  text-align: center;
}

/* ---------- JS-injected widget styling ---------- */
/* These four classes back inline style="…" attributes that used to live
   inside briefer-api.js innerHTML strings. Externalized so the CSP can
   keep `style-src 'self'` without `'unsafe-inline'`. */
.briefer-brief-meta { color: #64748b; }
.briefer-readiness-pill { color: #1d4ed8; }
.briefer-btn-restore { margin-top: 6px; }

/* ---------- PPTX templates picker ---------- */
.briefer-tpl-list .briefer-tpl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head actions" "body actions";
  column-gap: 14px;
  align-items: center;
  cursor: default;
}
.briefer-tpl-row .briefer-tpl-head { grid-area: head; }
.briefer-tpl-row .briefer-tpl-body { grid-area: body; }
.briefer-tpl-row .briefer-tpl-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
  align-items: center;
}
.briefer-tpl-row strong { font-size: 14px; }
.briefer-tpl-row .meta { color: #64748b; font-size: 12px; margin-left: 8px; }
.briefer-tpl-row .briefer-tpl-link {
  color: #1d4ed8;
  text-decoration: underline;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  word-break: break-all;
}
.briefer-tpl-row .briefer-tpl-meta {
  color: #64748b;
  font-size: 11px;
  margin-left: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.briefer-tpl-row .briefer-tpl-empty {
  color: #94a3b8;
  font-size: 12px;
  font-style: italic;
}
.briefer-tpl-row .briefer-btn.danger { color: #b91c1c; border-color: #fecaca; }
.briefer-tpl-row .briefer-btn.danger:hover { background: #fee2e2; }
/* Hidden file picker — clicked programmatically when the user hits "Open…" */
.briefer-tpl-file-input { display: none !important; }

/* ---------- Combined PPTX picker (Generate section, card 4) ---------- */
.briefer-pptx-list .briefer-pptx-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "head" "tpl" "actions";
  row-gap: 8px;
  cursor: default;
  padding: 14px 10px;
}
.briefer-pptx-row + .briefer-pptx-row {
  border-top: 1px solid #e2e8f0;
}
.briefer-pptx-row .briefer-pptx-head {
  grid-area: head;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.briefer-pptx-row .briefer-pptx-template { grid-area: tpl; }
.briefer-pptx-row .briefer-pptx-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.briefer-pptx-row strong { font-size: 14px; }
.briefer-pptx-row .meta { color: #64748b; font-size: 12px; }
.briefer-pptx-row .briefer-pptx-download {
  background: #0b1120;
  color: #fff;
  border-color: #0b1120;
}
.briefer-pptx-row .briefer-pptx-download:hover { background: #1e293b; }
.briefer-pptx-row .briefer-pptx-download:disabled { opacity: 0.7; cursor: progress; }
.briefer-pptx-row .briefer-btn.danger { color: #b91c1c; border-color: #fecaca; }
.briefer-pptx-row .briefer-btn.danger:hover { background: #fee2e2; }
.briefer-pptx-readonly { color: var(--coral, #FF6B61); }
/* No-brief banner — rendered when the picker opens without a saved brief.
   Higher contrast than .sub so the user reads it before scanning rows. */
.briefer-pptx-blocked {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0 6px;
  font-size: 13px;
  text-align: left;
}

/* ---------- Deliverables picker ---------- */
.briefer-dlv-list .briefer-dlv-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head actions" "body actions";
  column-gap: 14px;
  align-items: center;
  cursor: default;
}
.briefer-dlv-row .briefer-dlv-head { grid-area: head; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.briefer-dlv-row .briefer-dlv-body { grid-area: body; }
.briefer-dlv-row .briefer-dlv-actions { grid-area: actions; display: flex; align-items: center; }
.briefer-dlv-row strong { font-size: 14px; }
.briefer-dlv-row .meta { color: #64748b; font-size: 12px; }
.briefer-dlv-row .briefer-dlv-fmt {
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.briefer-dlv-row .briefer-dlv-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
}
.briefer-dlv-row .briefer-dlv-badge--templated {
  background: #ecfdf5;
  color: #059669;
}

/* Contextus widget styles moved to the standalone package — see
   `Contextus/static/contextus.css` (mounted at /static/contextus/
   in app/main.py). The migration to the standalone is the canonical
   source of truth so future fixes only ship to one place. */

/* ---------- Section §13 inline-style replacements ---------- */
/* These four classes replace inline `style="..."` attributes in
   briefer.html — necessary because dropping `'unsafe-inline'` from
   the CSP `style-src` directive forbids inline styles. */
.readiness-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
  margin-top: 8px;
}
.recompute-btn { margin-top: 16px; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-hidden { display: none; margin-top: 16px; }
