/* Chat with document - fileformat.ai. Scoped to .ffc so it can't affect the rest of the page. */

.ffc {
    --ffc-accent: var(--primarytheme, #5d21d1);
    --ffc-accent-soft: #efe9fb;
    --ffc-ink: #1d1b2c;
    --ffc-muted: #6b6880;
    --ffc-line: #e4e1ee;
    --ffc-surface: #ffffff;
    --ffc-canvas: #f6f5fa;
    --ffc-ok: #12805c;
    --ffc-ok-soft: #e3f5ee;
    --ffc-bad: #b42318;
    --ffc-bad-soft: #fdecea;
    --ffc-bad-line: #f3c3bd;
    --ffc-line-strong: #cfcadf;
    --ffc-hover: #e9e6f2;
    --ffc-code: #ebe8f3;
    --ffc-warn-bg: #fff7e0;
    --ffc-warn-line: #f2e2ad;
    --ffc-warn-ink: #6d5208;
    --ffc-stop: #1d1b2c;
    --ffc-page-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 4px 14px rgba(0, 0, 0, .06);
    --ffc-radius: 14px;

    background: var(--ffc-surface);
    border-radius: var(--ffc-radius);
    box-shadow: 0 18px 50px rgba(4, 2, 34, .28);
    color: var(--ffc-ink);
    margin: 0 auto;
    max-width: 1280px;
    overflow: hidden;
    text-align: left;
    width: 100%;
}

.ffc *, .ffc *::before, .ffc *::after { box-sizing: border-box; }

/* Dark theme: only the chat workspace (viewer + conversation); the rest of the site is unchanged.
   Document pages stay white so they look like the original. Toggled by chat.js (data-theme). */
.ffc[data-theme="dark"] {
    --ffc-accent: #9b7bff;
    --ffc-accent-soft: #2e2550;
    --ffc-ink: #e9e7f2;
    --ffc-muted: #a19db6;
    --ffc-line: #34314a;
    --ffc-line-strong: #4a4664;
    --ffc-surface: #1b1a26;
    --ffc-canvas: #13121b;
    --ffc-hover: #2a2839;
    --ffc-code: #2a2839;
    --ffc-ok: #4cc79a;
    --ffc-ok-soft: #173329;
    --ffc-bad: #ff8f84;
    --ffc-bad-soft: #3a1c1c;
    --ffc-bad-line: #5a2a2a;
    --ffc-warn-bg: #33290f;
    --ffc-warn-line: #4d3e15;
    --ffc-warn-ink: #f2d27a;
    --ffc-stop: #4a4664;
    --ffc-page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 14px rgba(0, 0, 0, .4);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
    color-scheme: dark; /* dark scrollbars and form controls */
}

/* The user's own messages and the send button keep the brand purple, readable on dark. */
.ffc[data-theme="dark"] .ffc-msg-user .ffc-bubble,
.ffc[data-theme="dark"] .ffc-send:not(.ffc-stop) { background: #6d4be0; }
.ffc[data-theme="dark"] .ffc-cite:hover { color: #13121b; }

.ffc-theme-toggle .ffc-icon-dark { display: none; }
.ffc[data-theme="dark"] .ffc-theme-toggle .ffc-icon-light { display: none; }
.ffc[data-theme="dark"] .ffc-theme-toggle .ffc-icon-dark { display: inline; }

/* The site styles p, h3 and buttons globally; reset what matters inside the workspace. */
.ffc p { line-height: 1.45; }
.ffc button { font-family: inherit; line-height: 1.3; }

.ffc.d-none { display: none !important; }

/* Toolbar ---------------------------------------------------------------------------------------- */
.ffc-toolbar {
    align-items: center;
    border-bottom: 1px solid var(--ffc-line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: space-between;
    padding: 12px 16px;
}

.ffc-doc {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.ffc-doc-icon { color: var(--ffc-accent); font-size: 20px; }

.ffc-doc-name {
    font-weight: 600;
    max-width: 42ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ffc-badge {
    align-items: center;
    border-radius: 100px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 500;
    gap: 6px;
    padding: 3px 10px;
    white-space: nowrap;
}

.ffc-badge-processing { background: var(--ffc-accent-soft); color: var(--ffc-accent); }
.ffc-badge-ready { background: var(--ffc-ok-soft); color: var(--ffc-ok); }
.ffc-badge-failed { background: var(--ffc-bad-soft); color: var(--ffc-bad); }

.ffc-toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.ffc-btn {
    align-items: center;
    background: none;
    border: 1px solid var(--ffc-line);
    border-radius: 8px;
    color: var(--ffc-ink);
    cursor: pointer;
    display: inline-flex;
    font-size: 14px;
    gap: 6px;
    padding: 6px 12px;
    transition: background .15s, border-color .15s;
}

.ffc-btn:hover:not(:disabled) { background: var(--ffc-canvas); border-color: var(--ffc-line-strong); }
.ffc-btn:disabled { cursor: default; opacity: .45; }
.ffc-btn-danger:hover:not(:disabled) { background: var(--ffc-bad-soft); border-color: var(--ffc-bad-line); color: var(--ffc-bad); }

.ffc-notice {
    align-items: flex-start;
    background: var(--ffc-warn-bg);
    border-bottom: 1px solid var(--ffc-warn-line);
    color: var(--ffc-warn-ink);
    display: flex;
    font-size: 14px;
    gap: 8px;
    line-height: 1.45;
    padding: 9px 16px;
}

.ffc-notice.d-none { display: none; }
.ffc-notice-error { background: var(--ffc-bad-soft); border-color: var(--ffc-bad-line); color: var(--ffc-bad); }

/* Panes ------------------------------------------------------------------------------------------ */
.ffc-panes {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    height: min(78vh, 820px);
    min-height: 520px;
}

.ffc-viewer {
    background: var(--ffc-canvas);
    border-right: 1px solid var(--ffc-line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ffc-viewer-bar {
    align-items: center;
    border-bottom: 1px solid var(--ffc-line);
    display: flex;
    gap: 4px;
    padding: 6px 10px;
}

.ffc-icon-btn {
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--ffc-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 6px 8px;
}

.ffc-icon-btn:hover { background: var(--ffc-hover); color: var(--ffc-ink); }

.ffc-zoom { color: var(--ffc-muted); font-size: 13px; min-width: 44px; text-align: center; }
.ffc-page { color: var(--ffc-muted); font-size: 13px; margin-left: auto; }

.ffc-viewer-body {
    align-items: center;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow: auto;
    padding: 16px;
    position: relative;
}

.ffc-page-wrap {
    background: #fff; /* pages stay white in both themes, like the original document */
    border-radius: 4px;
    box-shadow: var(--ffc-page-shadow);
    flex: none;
    max-width: none;
}

.ffc-page-wrap canvas { display: block; }

.ffc-flash { animation: ffc-flash 1.6s ease-out; }

@keyframes ffc-flash {
    0%, 30% { box-shadow: 0 0 0 4px var(--ffc-accent), 0 4px 14px rgba(0, 0, 0, .06); }
    100% { box-shadow: var(--ffc-page-shadow); }
}

.ffc-placeholder {
    align-items: center;
    color: var(--ffc-muted);
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    margin: auto;
    max-width: 36ch;
    text-align: center;
}

.ffc-placeholder p { margin: 0; }
.ffc-placeholder-icon { color: var(--ffc-bad); font-size: 28px; }

/* Chat ------------------------------------------------------------------------------------------- */
.ffc-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ffc-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 18px;
}

.ffc-empty {
    color: var(--ffc-muted);
    margin: auto;
    max-width: 40ch;
    text-align: center;
}

.ffc-empty.d-none { display: none; }
.ffc-empty-icon { color: var(--ffc-accent); font-size: 34px; }
.ffc-empty h3 { color: var(--ffc-ink); font-size: 19px; font-weight: 600; margin: 10px 0 6px; }
.ffc-empty p { font-size: 15px; margin: 0 0 16px; }

.ffc-starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.ffc-starter {
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 100px;
    color: var(--ffc-ink);
    cursor: pointer;
    font-size: 14px;
    padding: 6px 14px;
    transition: border-color .15s, color .15s;
}

.ffc-starter:hover:not(:disabled) { border-color: var(--ffc-accent); color: var(--ffc-accent); }
.ffc-starter:disabled { cursor: default; opacity: .5; }

.ffc-msg { display: flex; flex-direction: column; max-width: 100%; }
.ffc-msg-user { align-items: flex-end; }
.ffc-msg-assistant { align-items: flex-start; }

.ffc-bubble {
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.55;
    max-width: 92%;
    overflow-wrap: anywhere;
    padding: 10px 14px;
}

.ffc-msg-user .ffc-bubble {
    background: var(--ffc-accent);
    border-bottom-right-radius: 4px;
    color: #fff;
    white-space: pre-wrap;
}

.ffc-msg-assistant .ffc-bubble {
    background: var(--ffc-canvas);
    border: 1px solid var(--ffc-line);
    border-bottom-left-radius: 4px;
}

.ffc-md > :first-child { margin-top: 0; }
.ffc-md > :last-child { margin-bottom: 0; }
.ffc-md p, .ffc-md ul, .ffc-md ol { margin: 0 0 .6em; }
.ffc-md ul, .ffc-md ol { padding-left: 1.3em; }
.ffc-md h1, .ffc-md h2, .ffc-md h3, .ffc-md h4 { font-size: 1em; font-weight: 700; margin: .8em 0 .4em; }
.ffc-md code { background: var(--ffc-code); border-radius: 4px; font-size: .9em; padding: 1px 4px; }
.ffc-md pre { background: var(--ffc-code); border-radius: 8px; overflow-x: auto; padding: 10px; }
.ffc-md table { border-collapse: collapse; display: block; font-size: 14px; margin: 0 0 .6em; overflow-x: auto; }
.ffc-md th, .ffc-md td { border: 1px solid var(--ffc-line); padding: 4px 8px; }
.ffc-md a { color: var(--ffc-accent); }

.ffc-cite {
    background: var(--ffc-accent-soft);
    border: 0;
    border-radius: 6px;
    color: var(--ffc-accent);
    cursor: pointer;
    display: inline-block;
    font-size: 12.5px;
    font-style: normal;
    font-weight: 600;
    line-height: 1.5;
    padding: 0 6px;
    white-space: nowrap;
}

.ffc-cite:hover { background: var(--ffc-accent); color: #fff; }

.ffc-sources {
    align-items: center;
    color: var(--ffc-muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    gap: 6px;
    margin-top: 6px;
}

.ffc-error { color: var(--ffc-bad); margin-top: 6px; }

.ffc-thinking { align-items: center; color: var(--ffc-muted); display: inline-flex; font-size: 14px; gap: 3px; }

.ffc-thinking i {
    animation: ffc-dot 1.2s infinite ease-in-out;
    background: var(--ffc-accent);
    border-radius: 50%;
    display: inline-block;
    height: 6px;
    width: 6px;
}

.ffc-thinking i:nth-child(2) { animation-delay: .15s; }
.ffc-thinking i:nth-child(3) { animation-delay: .3s; }

@keyframes ffc-dot {
    0%, 80%, 100% { opacity: .25; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Input ------------------------------------------------------------------------------------------ */
.ffc-input {
    align-items: flex-end;
    border-top: 1px solid var(--ffc-line);
    display: flex;
    gap: 8px;
    padding: 12px 14px 6px;
}

.ffc-input textarea {
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 12px;
    color: var(--ffc-ink);
    flex: 1;
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
    max-height: 160px;
    outline: none;
    padding: 10px 12px;
    resize: none;
}

.ffc-input textarea:focus { border-color: var(--ffc-accent); box-shadow: 0 0 0 3px var(--ffc-accent-soft); }
.ffc-input textarea:disabled { background: var(--ffc-canvas); }

.ffc-send {
    align-items: center;
    background: var(--ffc-accent);
    border: 0;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    flex: none;
    font-size: 18px;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.ffc-send:disabled { cursor: default; opacity: .4; }
.ffc-send.d-none { display: none; }
.ffc-stop { background: var(--ffc-stop); }

.ffc-disclaimer { color: var(--ffc-muted); font-size: 12px; line-height: 1.45 !important; margin: 0; padding: 4px 16px 12px; }

/* Spinner ---------------------------------------------------------------------------------------- */
.ffc-spinner {
    animation: ffc-spin .8s linear infinite;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    display: inline-block;
    height: 12px;
    width: 12px;
}

.ffc-spinner-lg { color: var(--ffc-accent); height: 28px; width: 28px; border-width: 3px; }

@keyframes ffc-spin { to { transform: rotate(360deg); } }

/* Small screens: stack the viewer above the chat ------------------------------------------------- */
/* Screen-reader-only text (does not rely on the site's Bootstrap CSS) */
.ffc-sr-only {
    border: 0 !important;
    clip: rect(0, 0, 0, 0) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    white-space: nowrap !important;
    width: 1px !important;
}

/* Download menu in the toolbar */
.ffc-menu-wrap { position: relative; }
.ffc-menu.d-none { display: none; } /* also without the site's Bootstrap CSS */

.ffc-menu {
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(20, 20, 40, .14);
    display: flex;
    flex-direction: column;
    min-width: 170px;
    padding: 4px;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
}

.ffc-menu [role="menuitem"] {
    align-items: center;
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--ffc-ink);
    cursor: pointer;
    display: flex;
    font-size: 13.5px;
    gap: 8px;
    padding: 7px 10px;
    text-align: left;
    white-space: nowrap;
}

.ffc-menu [role="menuitem"]:hover, .ffc-menu [role="menuitem"]:focus-visible { background: var(--ffc-hover); outline: none; }
.ffc-btn.ffc-busy { cursor: progress; }

/* Copy button under each answer */
.ffc-actions { display: flex; gap: 4px; margin-top: 4px; }

.ffc-action {
    align-items: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ffc-muted);
    cursor: pointer;
    display: inline-flex;
    font-size: 12.5px;
    gap: 5px;
    padding: 2px 8px;
    transition: background .15s, color .15s, border-color .15s;
}

/* Regenerate only on the latest answer */
/* (an answer followed by a later answer; a quiz card in between doesn't count) */
.ffc-msg-assistant:has(~ .ffc-msg-assistant) .ffc-regen { display: none; }

.ffc-action:hover, .ffc-action:focus-visible { background: var(--ffc-hover); color: var(--ffc-ink); }
.ffc-action.ffc-copied, .ffc-btn.ffc-copied { color: var(--ffc-ok); }
.ffc-action.ffc-copy-failed, .ffc-btn.ffc-copy-failed { color: var(--ffc-bad); }

@media (max-width: 991px) {
    .ffc-panes { display: flex; flex-direction: column; height: auto; }
    .ffc-viewer { border-bottom: 1px solid var(--ffc-line); border-right: 0; height: 52vh; }
    .ffc-chat { height: 72vh; min-height: 420px; }
    .ffc-btn span { display: none; }
    .ffc-doc-name { max-width: 22ch; }
}

@media (prefers-reduced-motion: reduce) {
    .ffc-flash, .ffc-thinking i, .ffc-spinner { animation: none; }
}

/* Quiz me ------------------------------------------------------------------------------------------ */
.ffc-quiz-btn {
    align-items: center;
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 12px;
    color: var(--ffc-accent);
    cursor: pointer;
    display: inline-flex;
    flex: none;
    font-size: 19px;
    height: 44px;
    justify-content: center;
    transition: border-color .15s, background .15s;
    width: 44px;
}

.ffc-quiz-btn:hover:not(:disabled) { background: var(--ffc-accent-soft); border-color: var(--ffc-accent); }
.ffc-quiz-btn:disabled { cursor: default; opacity: .45; }
.ffc-starter-quiz { border-color: var(--ffc-accent); color: var(--ffc-accent); }
.ffc-starter-quiz i { margin-right: 2px; }

.ffc-msg-quiz { align-items: stretch; }

.ffc-quiz {
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 14px;
    max-width: 560px;
    padding: 12px 16px 14px;
    width: 100%;
}

.ffc-quiz-head {
    align-items: center;
    color: var(--ffc-muted);
    display: flex;
    font-size: 13px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ffc-quiz-title { color: var(--ffc-accent); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.ffc-quiz-wait { align-items: center; color: var(--ffc-muted); display: flex; font-size: 14px; gap: 8px; margin: 6px 0 2px; }

.ffc-quiz-dots { display: flex; gap: 5px; margin-bottom: 10px; }
.ffc-quiz-dots i { background: var(--ffc-line); border-radius: 3px; flex: 1; height: 5px; max-width: 48px; }
.ffc-quiz-dots i.current { background: var(--ffc-accent); }
.ffc-quiz-dots i.right { background: var(--ffc-ok); }
.ffc-quiz-dots i.wrong { background: var(--ffc-bad); }

.ffc-quiz-q { color: var(--ffc-ink); font-size: 16px; font-weight: 600; line-height: 1.45; margin: 0 0 10px; }
.ffc-quiz-options { display: flex; flex-direction: column; gap: 7px; }

.ffc-quiz-option {
    align-items: center;
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 10px;
    color: var(--ffc-ink);
    cursor: pointer;
    display: flex;
    font-size: 14.5px;
    gap: 10px;
    line-height: 1.4;
    padding: 9px 12px;
    text-align: left;
    transition: border-color .15s, background .15s;
}

.ffc-quiz-option:hover:not(:disabled) { background: var(--ffc-accent-soft); border-color: var(--ffc-accent); }
.ffc-quiz-option:focus-visible { outline: 2px solid var(--ffc-accent); outline-offset: 2px; }
.ffc-quiz-option:disabled { cursor: default; }
.ffc-quiz-option:disabled:not(.right):not(.wrong) { opacity: .6; }

.ffc-quiz-letter {
    align-items: center;
    border: 1px solid var(--ffc-line);
    border-radius: 50%;
    color: var(--ffc-muted);
    display: inline-flex;
    flex: none;
    font-size: 12px;
    font-weight: 700;
    height: 24px;
    justify-content: center;
    width: 24px;
}

.ffc-quiz-text { flex: 1; overflow-wrap: anywhere; }
.ffc-quiz-mark { flex: none; font-size: 17px; }
.ffc-quiz-option.right { background: var(--ffc-ok-soft); border-color: var(--ffc-ok); }
.ffc-quiz-option.right .ffc-quiz-letter, .ffc-quiz-option.right .ffc-quiz-mark { border-color: var(--ffc-ok); color: var(--ffc-ok); }
.ffc-quiz-option.wrong { background: var(--ffc-bad-soft); border-color: var(--ffc-bad); }
.ffc-quiz-option.wrong .ffc-quiz-letter, .ffc-quiz-option.wrong .ffc-quiz-mark { border-color: var(--ffc-bad); color: var(--ffc-bad); }

.ffc-quiz-feedback { font-size: 14px; line-height: 1.5; margin-top: 10px; }
.ffc-quiz-feedback:empty { display: none; }
.ffc-quiz-feedback p { color: var(--ffc-muted); margin: 3px 0 0; }
.ffc-quiz-right { color: var(--ffc-ok); }
.ffc-quiz-wrong { color: var(--ffc-bad); }

.ffc-quiz-score { color: var(--ffc-ink); font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.ffc-quiz-note { color: var(--ffc-muted); font-size: 14px; margin: 0; }
.ffc-quiz-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.ffc-btn-primary { background: var(--ffc-accent); border-color: var(--ffc-accent); color: #fff; }
.ffc-btn-primary:hover:not(:disabled) { background: var(--ffc-accent); border-color: var(--ffc-accent); filter: brightness(1.08); }
.ffc-quiz-actions .ffc-btn span { display: inline; } /* keep labels on small screens */

/* Suggested follow-up questions under the latest answer */
.ffc-followups { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }

.ffc-followup {
    align-items: flex-start;
    background: var(--ffc-surface);
    border: 1px solid var(--ffc-line);
    border-radius: 999px;
    color: var(--ffc-ink);
    cursor: pointer;
    display: inline-flex;
    font-size: 13.5px;
    gap: 7px;
    line-height: 1.35;
    max-width: 100%;
    padding: 6px 13px;
    text-align: left;
    transition: border-color .15s, background .15s;
}

.ffc-followup i { color: var(--ffc-accent); flex: none; margin-top: 1px; }
.ffc-followup span { overflow-wrap: anywhere; }
.ffc-followup:hover { background: var(--ffc-accent-soft); border-color: var(--ffc-accent); }
.ffc-followup:focus-visible { outline: 2px solid var(--ffc-accent); outline-offset: 2px; }

/* Suggested-questions toggle (toolbar): lightbulb when on, crossed-out when off */
.ffc-suggest-toggle .ffc-icon-suggest-off { display: none; }
.ffc[data-suggest="off"] .ffc-suggest-toggle .ffc-icon-suggest-on { display: none; }
.ffc[data-suggest="off"] .ffc-suggest-toggle .ffc-icon-suggest-off { display: inline; }
.ffc[data-suggest="off"] .ffc-followups { display: none; }
