/*
 * freque-support.css -- look for the Frequezoid support form and the help chat.
 * Also loaded by the admin page.
 *
 * Tokens are the Pro theme values from Frequezoid's utilities/freque-utilities.css, so the
 * form matches the rest of frequezoid.com. Everything is scoped under .fqs-root so nothing
 * leaks into the surrounding Craft page. Raw hex lives only in the token block.
 */

/* ===================================================================== tokens (Pro theme) */
.fqs-root {
    --fqs-bg: #111827;
    --fqs-surface: #1f2937;
    --fqs-text: #f9fafb;
    --fqs-text-muted: #d1d5db;
    --fqs-accent: #6b7280;
    --fqs-highlight: #9ca3af;
    --fqs-hover: #374151;
    --fqs-border: #4b5563;
    --fqs-error: #ef4444;
    --fqs-success: #10b981;
    --fqs-warning: #f59e0b;
    --fqs-info: #3b82f6;
    --fqs-link: #93c5fd;
    --fqs-link-hover: #bfdbfe;
    --fqs-shadow: rgba(0, 0, 0, 0.5);

    --fqs-radius-sm: 4px;
    --fqs-radius-md: 6px;
    --fqs-radius-lg: 8px;

    --fqs-fs-xs: 11px;
    --fqs-fs-sm: 12px;
    --fqs-fs-md: 13px;
    --fqs-fs-lg: 16px;
    --fqs-fs-xl: 22px;

    --fqs-font: 'Freque Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
}

/* ===================================================================== base */
.fqs-root {
    font-family: var(--fqs-font);
    font-size: var(--fqs-fs-md);
    line-height: 1.4;
    color: var(--fqs-text);
    text-align: left;
}
.fqs-root *, .fqs-root *::before, .fqs-root *::after { box-sizing: border-box; }
.fqs-root a { color: var(--fqs-link); }
.fqs-root a:hover { color: var(--fqs-link-hover); }
.fqs-root button, .fqs-root input, .fqs-root select, .fqs-root textarea { font: inherit; color: var(--fqs-text); }
/* The Craft site theme sets its own heading font and inherited color. */
.fqs-root :is(h1, h2, h3, h4) { font-family: inherit; color: var(--fqs-text); }
.fqs-root :focus-visible { outline: 2px solid var(--fqs-info); outline-offset: 2px; }
.fqs-root [hidden] { display: none; }

/* ===================================================================== card + headings */
.fqs-root .fqs-card {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 22px;
    color: var(--fqs-text);
    background: var(--fqs-surface);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-lg);
}
.fqs-root .fqs-title { margin: 0 0 4px; font-size: var(--fqs-fs-xl); font-weight: 600; }
.fqs-root .fqs-subtitle { margin: 0 0 16px; font-size: var(--fqs-fs-sm); color: var(--fqs-text-muted); }

/* ===================================================================== fields */
.fqs-root .fqs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fqs-root .fqs-field { margin-bottom: 12px; min-width: 0; }
.fqs-root .fqs-label { display: block; margin-bottom: 4px; font-size: var(--fqs-fs-sm); color: var(--fqs-text-muted); }
.fqs-root .fqs-optional { color: var(--fqs-highlight); }
.fqs-root .fqs-input {
    display: block;
    width: 100%;
    min-height: 34px;
    padding: 6px 10px;
    color: var(--fqs-text);
    background: var(--fqs-bg);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-md);
}
.fqs-root textarea.fqs-input { min-height: 150px; resize: vertical; line-height: 1.45; }
.fqs-root .fqs-input:focus { outline: none; border-color: var(--fqs-info); }
.fqs-root .fqs-input[aria-invalid="true"] { border-color: var(--fqs-error); }
.fqs-root .fqs-input:disabled { opacity: 0.6; }

/* Trap field for simple spam bots: off screen, not reachable by keyboard. */
.fqs-root .fqs-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ===================================================================== buttons */
.fqs-root .fqs-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 80px; min-height: 32px; padding: 6px 16px;
    color: var(--fqs-bg);
    background: var(--fqs-highlight);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-md);
    font-size: var(--fqs-fs-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
}
.fqs-root .fqs-btn:hover:not(:disabled) { color: var(--fqs-text); background: var(--fqs-hover); }
.fqs-root .fqs-btn:disabled { opacity: 0.45; cursor: default; }
.fqs-root .fqs-btn--quiet { color: var(--fqs-text); background: transparent; }
.fqs-root .fqs-btn--small { min-width: 0; min-height: 26px; padding: 3px 10px; font-size: var(--fqs-fs-xs); }
.fqs-root .fqs-link-btn { padding: 0; color: var(--fqs-link); background: none; border: none; text-decoration: underline; cursor: pointer; }
.fqs-root .fqs-link-btn:hover { color: var(--fqs-link-hover); }
/* A hidden button stays hidden: the display values above would otherwise beat [hidden]. */
.fqs-root .fqs-btn[hidden], .fqs-root .fqs-link-btn[hidden] { display: none; }

/* ===================================================================== status + notices */
.fqs-root .fqs-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.fqs-root .fqs-status { min-height: 1.4em; margin: 0; font-size: var(--fqs-fs-sm); color: var(--fqs-text-muted); }
.fqs-root .fqs-status[data-kind="bad"] { color: var(--fqs-warning); }
.fqs-root .fqs-status[data-kind="ok"] { color: var(--fqs-success); }
.fqs-root .fqs-notice {
    padding: 12px 14px;
    color: var(--fqs-text);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-md);
}
.fqs-root .fqs-notice--ok { background: color-mix(in srgb, var(--fqs-success) 16%, transparent); border-color: color-mix(in srgb, var(--fqs-success) 50%, transparent); }
.fqs-root .fqs-notice--bad { background: color-mix(in srgb, var(--fqs-error) 16%, transparent); border-color: color-mix(in srgb, var(--fqs-error) 50%, transparent); }
.fqs-root .fqs-notice p { margin: 0 0 8px; }
.fqs-root .fqs-notice p:last-child { margin-bottom: 0; }
.fqs-root .fqs-legal { margin: 12px 0 0; font-size: var(--fqs-fs-xs); color: var(--fqs-text-muted); }

/* ===================================================================== help chat
   The mount <div> takes no room in the page: the launcher and the panel are fixed to the
   bottom right corner of the window. */
.fqs-root.fqs-chat { position: static; margin: 0; padding: 0; }
.fqs-root .fqs-chat-launcher {
    position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
    min-width: 72px; min-height: 40px; padding: 8px 18px;
    color: var(--fqs-bg);
    background: var(--fqs-highlight);
    border: 1px solid var(--fqs-border);
    border-radius: 20px;
    box-shadow: 0 4px 16px var(--fqs-shadow);
    font-size: var(--fqs-fs-md); font-weight: 600; cursor: pointer;
}
.fqs-root .fqs-chat-launcher:hover { color: var(--fqs-text); background: var(--fqs-hover); }
.fqs-root .fqs-chat-panel {
    position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
    display: flex; flex-direction: column;
    width: 380px; max-width: calc(100vw - 24px);
    height: 560px; max-height: calc(100vh - 40px);
    color: var(--fqs-text);
    background: var(--fqs-surface);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-lg);
    box-shadow: 0 8px 32px var(--fqs-shadow);
    overflow: hidden;
}
.fqs-root .fqs-chat-panel[hidden] { display: none; }
.fqs-root .fqs-chat-header {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid var(--fqs-border);
}
.fqs-root .fqs-chat-title { flex: 1; margin: 0; font-size: var(--fqs-fs-lg); font-weight: 600; }
.fqs-root .fqs-chat-log {
    flex: 1; min-height: 0; overflow-y: auto;
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px;
    background: var(--fqs-bg);
}
.fqs-root .fqs-chat-msg {
    max-width: 88%;
    padding: 8px 10px;
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-lg);
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.fqs-root .fqs-chat-msg--assistant { align-self: flex-start; background: var(--fqs-surface); }
.fqs-root .fqs-chat-msg--user { align-self: flex-end; background: var(--fqs-hover); white-space: pre-wrap; }
.fqs-root .fqs-chat-msg--waiting { color: var(--fqs-text-muted); font-style: italic; }
.fqs-root .fqs-chat-para { margin: 0 0 8px; }
.fqs-root .fqs-chat-list { margin: 0 0 8px; padding-left: 20px; }
.fqs-root .fqs-chat-list li { margin-bottom: 4px; }
.fqs-root .fqs-chat-msg > :last-child { margin-bottom: 0; }
.fqs-root .fqs-chat-note {
    align-self: center;
    padding: 4px 10px;
    font-size: var(--fqs-fs-sm);
    color: var(--fqs-text-muted);
    border: 1px solid var(--fqs-border);
    border-radius: var(--fqs-radius-md);
}
.fqs-root .fqs-chat-note[data-kind="ok"] { color: var(--fqs-text); border-color: color-mix(in srgb, var(--fqs-success) 50%, transparent); background: color-mix(in srgb, var(--fqs-success) 16%, transparent); }
.fqs-root .fqs-chat-note[data-kind="bad"] { color: var(--fqs-warning); }
.fqs-root .fqs-chat-form {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px 6px;
    border-top: 1px solid var(--fqs-border);
}
.fqs-root textarea.fqs-chat-input { flex: 1; min-height: 44px; max-height: 120px; resize: none; }
.fqs-root .fqs-chat-foot { margin: 0; padding: 0 12px 10px; font-size: var(--fqs-fs-xs); color: var(--fqs-text-muted); }

/* Inline chat (data-mode="inline"): part of the page, always open. */
.fqs-root.fqs-chat--inline .fqs-chat-panel {
    position: static;
    width: 100%; max-width: none;
    height: 540px; max-height: 80vh;
    box-shadow: none;
}

/* ===================================================================== site theme
   data-theme="site": the frequezoid.com look instead of the app look. The site's custom CSS
   (Frequezoid utilities/Landing/freque-site.css, embedded in the site) sets --fz-* tokens on
   body; the chat and form take their colors, type sizes, radii and font from those tokens,
   and their control shapes copy that file's form rules (46px controls, 12px 14px padding, a
   flame button). The literals are the same values, used only where the tokens are missing.
   Raw colors stay in this token block. */
.fqs-root.fqs-site {
    --fqs-bg: var(--fz-bg, #111827);
    --fqs-surface: var(--fz-surface, #1f2937);
    --fqs-border: var(--fz-line, #374151);
    --fqs-hover: var(--fz-line, #374151);
    --fqs-text: var(--fz-text, #f9fafb);
    --fqs-text-muted: var(--fz-muted, #9ca3af);
    --fqs-highlight: var(--fz-muted, #9ca3af);
    --fqs-info: var(--fz-teal, #2fbf9b);
    --fqs-link: var(--fz-teal, #2fbf9b);
    --fqs-link-hover: var(--fz-text, #f9fafb);
    --fqs-success: var(--fz-teal, #2fbf9b);
    --fqs-warning: var(--fz-amber, #f5a51f);
    --fqs-error: var(--fz-flame, #e9471d);
    --fqs-primary: var(--fz-flame, #e9471d);
    --fqs-on-primary: var(--fz-white, #ffffff);

    --fqs-radius-md: var(--fz-radius-sm, 8px);
    --fqs-radius-lg: var(--fz-radius, 12px);

    --fqs-fs-xs: 0.8rem;
    --fqs-fs-sm: var(--fz-fs-hint, 0.85rem);
    --fqs-fs-md: var(--fz-fs-body, 1rem);
    --fqs-fs-lg: var(--fz-fs-h4, 1.15rem);
    --fqs-fs-xl: var(--fz-fs-h3, 1.6rem);

    --fqs-font: var(--fz-font, 'Freque Inter', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif);
    line-height: 1.5;
}
.fqs-root.fqs-site .fqs-card { max-width: none; padding: 0; background: transparent; border: 0; }
.fqs-root.fqs-site .fqs-title { font-weight: 300; letter-spacing: -0.02em; }
.fqs-root.fqs-site .fqs-input { min-height: 46px; padding: 12px 14px; background: var(--fqs-surface); }
.fqs-root.fqs-site .fqs-btn {
    min-height: 46px; padding: 12px 28px;
    color: var(--fqs-on-primary);
    background: var(--fqs-primary);
    border: 0;
    font-size: var(--fqs-fs-md); font-weight: 600;
}
.fqs-root.fqs-site .fqs-btn:hover:not(:disabled) { color: var(--fqs-on-primary); background: var(--fqs-primary); filter: brightness(1.08); }
.fqs-root.fqs-site .fqs-btn--quiet { color: var(--fqs-text); background: transparent; border: 1px solid var(--fqs-border); }
.fqs-root.fqs-site .fqs-btn--quiet:hover:not(:disabled) { color: var(--fqs-text); background: var(--fqs-hover); filter: none; }
.fqs-root.fqs-site .fqs-btn--small { min-height: 32px; padding: 4px 14px; font-size: var(--fqs-fs-sm); font-weight: 500; }
.fqs-root.fqs-site .fqs-chat-launcher { color: var(--fqs-on-primary); background: var(--fqs-primary); border: 0; }
.fqs-root.fqs-site .fqs-chat-launcher:hover { color: var(--fqs-on-primary); background: var(--fqs-primary); filter: brightness(1.08); }
.fqs-root.fqs-site .fqs-chat-list li::marker { color: var(--fqs-info); }

/* ===================================================================== light theme
   Class fqs-light on a .fqs-root: light surfaces, dark text, the same accent colors darkened
   enough to read on white. Works with or without the site theme (it comes after it, so its
   colors win). The admin page has a button that switches it on. Raw colors stay in this block. */
.fqs-root.fqs-light {
    --fqs-bg: #f3f4f6;
    --fqs-surface: #ffffff;
    --fqs-text: #111827;
    --fqs-text-muted: #4b5563;
    --fqs-accent: #9ca3af;
    --fqs-highlight: #6b7280;
    --fqs-hover: #e5e7eb;
    --fqs-border: #d1d5db;
    --fqs-error: #c2410c;
    --fqs-success: #0f766e;
    --fqs-warning: #b45309;
    --fqs-info: #0f766e;
    --fqs-link: #0f766e;
    --fqs-link-hover: #111827;
    --fqs-primary: #d9431b;
    --fqs-on-primary: #ffffff;
    --fqs-shadow: rgba(17, 24, 39, 0.18);
}
/* The app look's primary button is light grey with dark text; on a light page it flips. */
.fqs-root.fqs-light:not(.fqs-site) .fqs-btn:not(.fqs-btn--quiet) { color: var(--fqs-surface); background: var(--fqs-text-muted); }

/* The support block (site/support-block.html), pasted into a frequezoid.com page: one readable
   column, centered. Its heading and intro text use the site's own .text-widget-content rules. */
.fqs-block { max-width: 860px; margin: 0 auto; padding: clamp(28px, 4vw, 56px) 16px clamp(40px, 5vw, 72px); }
.fqs-block__gap { height: 36px; }

@media (max-width: 520px) {
    .fqs-root .fqs-row { grid-template-columns: 1fr; gap: 0; }
    .fqs-root .fqs-card { padding: 16px; }
    .fqs-root .fqs-chat-panel { right: 12px; bottom: 12px; height: calc(100vh - 24px); max-height: calc(100vh - 24px); }
    .fqs-root .fqs-chat-launcher { right: 12px; bottom: 12px; }
}
