/**
 * 2012 - 2025 HiPresta
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0).
 * It is also available through the world-wide-web at this URL: https://opensource.org/licenses/AFL-3.0
 *
 * @author    HiPresta <support@hipresta.com>
 * @copyright HiPresta 2025
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
 *
 * @website   https://hipresta.com
 */

/* ==========================================================================
   FAQ Help Widget — floating launcher + panel
   ========================================================================== */

:root {
    --hifaq-widget-color: var(--hifaq-primary, #64748b);
    --hifaq-widget-header-bg: var(--hifaq-hero-bg, linear-gradient(160deg, #334155 0%, #475569 100%));
    --hifaq-widget-header-text: var(--hifaq-hero-text, #ffffff);
    --hifaq-widget-bg: var(--hifaq-bg, #ffffff);
    --hifaq-widget-text: var(--hifaq-text, #1e293b);
    --hifaq-widget-text-muted: color-mix(in srgb, var(--hifaq-widget-text), var(--hifaq-widget-bg) 50%);
    --hifaq-widget-border: var(--hifaq-border, #e2e8f0);
    --hifaq-widget-radius: 16px;
    --hifaq-widget-shadow:
        0 8px 16px rgb(0 0 0 / 0.08),
        0 24px 60px rgb(0 0 0 / 0.18);
    --hifaq-widget-offset-x: 20px;
    --hifaq-widget-offset-y: 20px;
    --hifaq-widget-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --hifaq-widget-z: 999999;
}

.hi-faq-widget,
.hi-faq-widget * {
    box-sizing: border-box;
}

.hi-faq-widget {
    /* Derive hover from the (possibly JS-overridden) local color, not :root. */
    --hifaq-widget-color-hover: color-mix(in srgb, var(--hifaq-widget-color), #000 15%);
    position: fixed;
    bottom: var(--hifaq-widget-offset-y);
    z-index: var(--hifaq-widget-z);
    font-family: inherit;
    line-height: 1.45;
    /* Neutralize theme grid/row rules in case the mount inherits them */
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.hi-faq-widget--right {
    left: auto !important;
}

.hi-faq-widget--left {
    right: auto !important;
}

.hi-faq-widget--right {
    right: var(--hifaq-widget-offset-x);
}

.hi-faq-widget--left {
    left: var(--hifaq-widget-offset-x);
}

/* --------------------------------------------------------------------------
   Launcher bubble
   -------------------------------------------------------------------------- */

.hi-faq-widget__launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--hifaq-widget-color);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.18), 0 8px 24px rgb(0 0 0 / 0.14);
    transition: transform 0.2s var(--hifaq-widget-spring), background 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.hi-faq-widget__launcher:hover {
    background: var(--hifaq-widget-color-hover);
    transform: scale(1.08);
}

.hi-faq-widget__launcher:active {
    transform: scale(0.96);
}

.hi-faq-widget__launcher:focus-visible {
    outline: 2px solid var(--hifaq-widget-color);
    outline-offset: 3px;
}

.hi-faq-widget__launcher-icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s var(--hifaq-widget-spring), opacity 0.2s ease;
}

.hi-faq-widget__launcher-icon svg {
    display: block;
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.hi-faq-widget__launcher-icon--close svg {
    width: 22px;
    height: 22px;
}

.hi-faq-widget__launcher-icon--close {
    opacity: 0;
    transform: rotate(-60deg) scale(0.4);
}

.hi-faq-widget--open .hi-faq-widget__launcher-icon--help {
    opacity: 0;
    transform: rotate(60deg) scale(0.4);
}

.hi-faq-widget--open .hi-faq-widget__launcher-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */

.hi-faq-widget__panel {
    position: absolute;
    bottom: 72px;
    display: flex;
    flex-direction: column;
    width: 384px;
    max-width: calc(100vw - 2 * var(--hifaq-widget-offset-x));
    height: min(704px, calc(100vh - var(--hifaq-widget-offset-y) - 110px));
    height: min(704px, calc(100dvh - var(--hifaq-widget-offset-y) - 110px));
    overflow: hidden;
    border-radius: var(--hifaq-widget-radius);
    background: var(--hifaq-widget-bg);
    color: var(--hifaq-widget-text);
    box-shadow: var(--hifaq-widget-shadow);
    opacity: 0;
    transform: translateY(16px) scale(0.92);
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.28s var(--hifaq-widget-spring),
        width 0.28s var(--hifaq-widget-spring);
}

.hi-faq-widget--right .hi-faq-widget__panel {
    right: 0;
    transform-origin: bottom right;
}

.hi-faq-widget--left .hi-faq-widget__panel {
    left: 0;
    transform-origin: bottom left;
}

.hi-faq-widget--open .hi-faq-widget__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Article view widens the panel for comfortable reading */
.hi-faq-widget__panel--wide {
    width: min(640px, calc(100vw - 2 * var(--hifaq-widget-offset-x)));
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.hi-faq-widget__header {
    position: relative;
    flex-shrink: 0;
    padding: 22px 20px 18px;
    background: var(--hifaq-widget-header-bg);
    color: var(--hifaq-widget-header-text);
    transition: padding 0.25s ease;
}

.hi-faq-widget__panel--sub .hi-faq-widget__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

.hi-faq-widget__greeting {
    margin: 0 28px 0 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
}

.hi-faq-widget__subtitle {
    margin: 6px 28px 0 0;
    font-size: 0.875rem;
    opacity: 0.82;
}

.hi-faq-widget__panel--sub .hi-faq-widget__greeting,
.hi-faq-widget__panel--sub .hi-faq-widget__subtitle {
    display: none;
}


.hi-faq-widget__header-title {
    display: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hi-faq-widget__panel--sub .hi-faq-widget__header-title {
    display: block;
}

.hi-faq-widget__icon-btn {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.85;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.hi-faq-widget__icon-btn:hover {
    background: rgb(255 255 255 / 0.15);
    opacity: 1;
}

.hi-faq-widget__icon-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.hi-faq-widget__icon-btn svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.hi-faq-widget__back {
    display: none;
}

.hi-faq-widget__panel--sub .hi-faq-widget__back {
    display: flex;
}

.hi-faq-widget__close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.hi-faq-widget__panel--sub .hi-faq-widget__close {
    position: static;
}

/* --------------------------------------------------------------------------
   Views container
   -------------------------------------------------------------------------- */

.hi-faq-widget__views {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.hi-faq-widget__view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--hifaq-widget-bg);
}

.hi-faq-widget__view--enter-forward {
    animation: hiFaqWidgetInRight 0.26s var(--hifaq-widget-spring) both;
}

.hi-faq-widget__view--enter-back {
    animation: hiFaqWidgetInLeft 0.26s var(--hifaq-widget-spring) both;
}

.hi-faq-widget__view--exit-forward {
    animation: hiFaqWidgetOutLeft 0.22s ease both;
}

.hi-faq-widget__view--exit-back {
    animation: hiFaqWidgetOutRight 0.22s ease both;
}

@keyframes hiFaqWidgetInRight {
    from { transform: translateX(60px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes hiFaqWidgetInLeft {
    from { transform: translateX(-60px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes hiFaqWidgetOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-60px); opacity: 0; }
}

@keyframes hiFaqWidgetOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(60px); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */

.hi-faq-widget__search {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-shrink: 0;
    padding: 14px 16px 10px;
    background: var(--hifaq-widget-bg);
}

.hi-faq-widget__search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.hi-faq-widget__search-box > svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    fill: var(--hifaq-widget-text-muted);
    pointer-events: none;
}

.hi-faq-widget__search-input {
    width: 100%;
    height: 42px;
    padding: 0 38px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 999px;
    background: var(--hifaq-widget-bg);
    color: var(--hifaq-widget-text);
    font-size: 0.9375rem;
    outline: none;
    box-shadow: var(--hifaq-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hi-faq-widget__search-input:focus {
    border-color: var(--hifaq-widget-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hifaq-widget-color), transparent 82%);
}

.hi-faq-widget__search-clear {
    position: absolute;
    right: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--hifaq-widget-text-muted);
    cursor: pointer;
}

.hi-faq-widget__search-clear:hover {
    color: var(--hifaq-widget-text);
}

.hi-faq-widget__search-clear svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.hi-faq-widget--searching .hi-faq-widget__search-clear {
    display: flex;
}

/* --------------------------------------------------------------------------
   Sections & list items
   -------------------------------------------------------------------------- */

.hi-faq-widget__body {
    flex: 1;
    padding: 4px 8px 12px;
}

.hi-faq-widget__section {
    margin-top: 8px;
}

.hi-faq-widget__section-label {
    margin: 0;
    padding: 8px 12px 6px;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hi-faq-widget--searching .hi-faq-widget__section--home {
    display: none;
}

.hi-faq-widget__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--hifaq-widget-text);
    cursor: pointer;
    font-size: 0.9063rem;
    text-align: left;
    transition: background 0.13s ease;
}

.hi-faq-widget__item:hover {
    background: var(--hifaq-bg-secondary, #f5f6f7);
}

.hi-faq-widget__item:focus-visible {
    outline: 2px solid var(--hifaq-widget-color);
    outline-offset: -2px;
}

.hi-faq-widget__item-text {
    flex: 1;
    min-width: 0;
}

.hi-faq-widget__item-count {
    flex-shrink: 0;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.8125rem;
}

.hi-faq-widget__item-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    fill: var(--hifaq-widget-text-muted);
    transition: transform 0.15s ease;
}

.hi-faq-widget__item:hover .hi-faq-widget__item-chevron {
    transform: translateX(2px);
    fill: var(--hifaq-widget-color);
}

.hi-faq-widget__empty {
    padding: 28px 16px;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.hi-faq-widget__load-more {
    display: block;
    width: calc(100% - 24px);
    margin: 8px 12px;
    padding: 10px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 10px;
    background: transparent;
    color: var(--hifaq-widget-color);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.13s ease, border-color 0.13s ease;
}

.hi-faq-widget__load-more:hover {
    background: var(--hifaq-bg-secondary, #f5f6f7);
    border-color: var(--hifaq-widget-color);
}

/* --------------------------------------------------------------------------
   Article view
   -------------------------------------------------------------------------- */

.hi-faq-widget__article {
    padding: 20px 20px 24px;
}

.hi-faq-widget__article-title {
    margin: 0 0 14px;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--hifaq-widget-text);
}

.hi-faq-widget__article-answer {
    font-size: 0.9375rem;
    color: var(--hifaq-widget-text);
    word-wrap: break-word;
}

.hi-faq-widget__article-answer img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.hi-faq-widget__article-answer a {
    color: var(--hifaq-widget-color);
}

/* Rich content typography for the article answer: mirrors the FAQ page prose
   styles (basic tags), scoped to the widget and using its color variables. */
.hi-faq-widget__article-answer p {
    margin: 0 0 0.85em;
}
.hi-faq-widget__article-answer p:last-child {
    margin-bottom: 0;
}

.hi-faq-widget__article-answer strong,
.hi-faq-widget__article-answer b {
    font-weight: 600;
}

.hi-faq-widget__article-answer a {
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--hifaq-widget-color), transparent 60%);
    text-underline-offset: 2px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.hi-faq-widget__article-answer a:hover {
    color: var(--hifaq-widget-color-hover);
    text-decoration-color: var(--hifaq-widget-color-hover);
}

.hi-faq-widget__article-answer h2,
.hi-faq-widget__article-answer h3,
.hi-faq-widget__article-answer h4 {
    color: var(--hifaq-widget-text);
    font-weight: 600;
    line-height: 1.35;
    margin: 1.1em 0 0.4em;
}
.hi-faq-widget__article-answer h2:first-child,
.hi-faq-widget__article-answer h3:first-child,
.hi-faq-widget__article-answer h4:first-child {
    margin-top: 0;
}
.hi-faq-widget__article-answer h2 {
    font-size: 1.2em;
}
.hi-faq-widget__article-answer h3 {
    font-size: 1.05em;
}
.hi-faq-widget__article-answer h4 {
    font-size: 1em;
}

.hi-faq-widget__article-answer ul,
.hi-faq-widget__article-answer ol {
    margin: 0 0 0.85em;
    padding-left: 1.4em;
}
.hi-faq-widget__article-answer ul {
    list-style: disc;
}
.hi-faq-widget__article-answer ol {
    list-style: decimal;
}
.hi-faq-widget__article-answer li {
    margin-bottom: 0.35em;
    padding-left: 0.15em;
}
.hi-faq-widget__article-answer li:last-child {
    margin-bottom: 0;
}
.hi-faq-widget__article-answer li > ul,
.hi-faq-widget__article-answer li > ol {
    margin-top: 0.35em;
    margin-bottom: 0;
}

.hi-faq-widget__article-answer blockquote {
    margin: 1em 0;
    padding: 0.6em 1em;
    border-left: 3px solid var(--hifaq-widget-color);
    background: var(--hifaq-bg-secondary, #f5f6f7);
    border-radius: 0 8px 8px 0;
    color: var(--hifaq-widget-text-muted);
    font-style: italic;
}
.hi-faq-widget__article-answer blockquote p:last-child {
    margin-bottom: 0;
}

.hi-faq-widget__article-answer hr {
    border: none;
    border-top: 1px solid var(--hifaq-widget-border);
    margin: 1.1em 0;
}

.hi-faq-widget__article-answer code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.875em;
    background: var(--hifaq-bg-secondary, #f5f6f7);
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 3px;
    padding: 0.15em 0.4em;
}
.hi-faq-widget__article-answer pre {
    margin: 1em 0;
    padding: 0.85em 1em;
    background: var(--hifaq-bg-secondary, #f5f6f7);
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.875em;
    line-height: 1.6;
}
.hi-faq-widget__article-answer pre code {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: inherit;
}

.hi-faq-widget__article-answer table {
    border-spacing: 0;
    width: 100%;
    margin: 1em 0;
    font-size: 0.9375em;
}
.hi-faq-widget__article-answer th,
.hi-faq-widget__article-answer td {
    border: 1px solid var(--hifaq-widget-border);
    padding: 0.5em 0.7em;
    text-align: left;
}
.hi-faq-widget__article-answer th {
    background: var(--hifaq-bg-secondary, #f5f6f7);
    color: var(--hifaq-widget-text);
    font-weight: 600;
}

.hi-faq-widget__article-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
    color: var(--hifaq-widget-color);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.hi-faq-widget__article-link:hover {
    color: var(--hifaq-widget-color-hover);
    text-decoration: underline;
}

.hi-faq-widget__article-link svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

/* Feedback */

.hi-faq-widget__feedback {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 12px;
    text-align: center;
}

.hi-faq-widget__feedback-label {
    margin: 0 0 12px;
    color: var(--hifaq-widget-text);
    font-size: 0.875rem;
    font-weight: 600;
}

.hi-faq-widget__feedback-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.hi-faq-widget__feedback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 50%;
    background: var(--hifaq-widget-bg);
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.15s var(--hifaq-widget-spring), border-color 0.15s ease, background 0.15s ease;
}

.hi-faq-widget__feedback-btn:hover {
    transform: scale(1.12);
    border-color: var(--hifaq-widget-color);
    background: var(--hifaq-bg-secondary, #f5f6f7);
}

.hi-faq-widget__feedback-btn:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.hi-faq-widget__feedback--form {
    text-align: left;
}

.hi-faq-widget__feedback-hint {
    margin: -4px 0 12px;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.8125rem;
}

.hi-faq-widget__feedback-comment {
    display: block;
    width: 100%;
    min-height: 84px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 10px;
    background: var(--hifaq-widget-bg);
    color: var(--hifaq-widget-text);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.45;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hi-faq-widget__feedback-comment:focus {
    border-color: var(--hifaq-widget-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hifaq-widget-color), transparent 82%);
}

.hi-faq-widget__feedback-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: var(--hifaq-widget-color);
    color: #fff;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.hi-faq-widget__feedback-submit:hover {
    background: var(--hifaq-widget-color-hover);
}

.hi-faq-widget__feedback-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.hi-faq-widget__feedback-thanks {
    margin: 0;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.hi-faq-widget__footer {
    flex-shrink: 0;
    padding: 10px 16px;
    border-top: 1px solid var(--hifaq-widget-border);
    background: var(--hifaq-widget-bg);
    text-align: center;
}

/* Experiment: when the context toggle is present it shares the footer row with
   the "Browse all FAQs" link (link left, toggle right). */
.hi-faq-widget--has-toggle .hi-faq-widget__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
}

.hi-faq-widget__footer a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
}

.hi-faq-widget__footer a:hover {
    color: var(--hifaq-widget-color);
}

.hi-faq-widget__footer svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* --------------------------------------------------------------------------
   Context toggle (AI <-> FAQ) - shares the footer row with "Browse all FAQs"
   -------------------------------------------------------------------------- */

.hi-faq-widget__mode-toggle {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 12px;
    border: 1px solid color-mix(in srgb, currentColor, transparent 68%);
    border-radius: 999px;
    background: color-mix(in srgb, currentColor, transparent 88%);
    color: inherit;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.hi-faq-widget__mode-toggle[hidden] {
    display: none;
}

.hi-faq-widget__mode-toggle:hover {
    background: color-mix(in srgb, currentColor, transparent 80%);
    transform: translateY(-1px);
}

.hi-faq-widget__mode-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.hi-faq-widget__mode-toggle svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.hi-faq-widget__mode-toggle-label {
    letter-spacing: 0.01em;
}

/* Accent variant: the "Ask AI" state stands out to pull visitors in. */
.hi-faq-widget__mode-toggle--accent {
    border-color: transparent;
    background: var(--hifaq-widget-color);
    color: #fff;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--hifaq-widget-color), transparent 55%);
}

.hi-faq-widget__mode-toggle--accent:hover {
    background: var(--hifaq-widget-color-hover);
}

.hi-faq-widget__panel--no-back .hi-faq-widget__back {
    display: none;
}

/* --------------------------------------------------------------------------
   AI chat view
   -------------------------------------------------------------------------- */

.hi-faq-widget__chat {
    overflow: hidden;
}

.hi-faq-widget__chat-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    padding: 16px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.hi-faq-widget__msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
}

.hi-faq-widget__msg--ai {
    align-self: flex-start;
    align-items: flex-start;
}

.hi-faq-widget__msg--user {
    align-self: flex-end;
    align-items: flex-end;
}

.hi-faq-widget__msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9063rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.hi-faq-widget__msg--ai .hi-faq-widget__msg-bubble {
    border-bottom-left-radius: 4px;
    background: var(--hifaq-bg-secondary, #f5f6f7);
    color: var(--hifaq-widget-text);
}

.hi-faq-widget__msg--user .hi-faq-widget__msg-bubble {
    border-bottom-right-radius: 4px;
    background: var(--hifaq-widget-color);
    color: #fff;
}

.hi-faq-widget__msg--error .hi-faq-widget__msg-bubble {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    color: var(--hifaq-widget-text-muted);
}

/* Pending bubble: typing dots + status label */

.hi-faq-widget__msg--pending .hi-faq-widget__msg-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hi-faq-widget__msg-status {
    color: var(--hifaq-widget-text-muted);
    font-size: 0.8125rem;
}

.hi-faq-widget__typing {
    display: inline-flex;
    gap: 3px;
}

.hi-faq-widget__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--hifaq-widget-text-muted);
    animation: hiFaqWidgetTyping 1.2s ease-in-out infinite;
}

.hi-faq-widget__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.hi-faq-widget__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes hiFaqWidgetTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Related article chips */

.hi-faq-widget__chat-related {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    margin-top: 8px;
}

.hi-faq-widget__chat-related-label {
    color: var(--hifaq-widget-text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hi-faq-widget__chat-chip {
    padding: 7px 12px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 12px;
    background: var(--hifaq-widget-bg);
    color: var(--hifaq-widget-text);
    cursor: pointer;
    font-size: 0.8125rem;
    text-align: left;
    transition: border-color 0.13s ease, background 0.13s ease;
}

.hi-faq-widget__chat-chip:hover {
    border-color: var(--hifaq-widget-color);
    background: var(--hifaq-bg-secondary, #f5f6f7);
}

/* Composer: one bordered container with the send button inside, Intercom-style */

.hi-faq-widget__chat-composer {
    position: relative;
    flex-shrink: 0;
    padding: 6px 12px 8px;
    background: var(--hifaq-widget-bg);
}

.hi-faq-widget__chat-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 8px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 20px;
    background: var(--hifaq-widget-bg);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hi-faq-widget__chat-box:focus-within {
    border-color: var(--hifaq-widget-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hifaq-widget-color), transparent 82%);
}

/* Bottom toolbar inside the composer: tools on the left, send on the right */

.hi-faq-widget__chat-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.hi-faq-widget__chat-tools {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.hi-faq-widget__chat-voice-hint {
    overflow: hidden;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Shared subtle icon buttons in the toolbar (Start over, microphone) */

.hi-faq-widget__chat-tool {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--hifaq-widget-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s var(--hifaq-widget-spring);
}

.hi-faq-widget__chat-tool svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.hi-faq-widget__chat-tool:hover {
    background: var(--hifaq-bg-secondary, #f5f6f7);
    color: var(--hifaq-widget-text);
}

.hi-faq-widget__chat-tool:disabled {
    opacity: 0.55;
    cursor: default;
}

.hi-faq-widget__chat-restart svg {
    width: 17px;
    height: 17px;
}

.hi-faq-widget__chat-mic--recording {
    background: color-mix(in srgb, #e5484d, transparent 88%);
    color: #e5484d;
    animation: hi-faq-widget-mic-pulse 1.4s ease-in-out infinite;
}

.hi-faq-widget__chat-mic--recording:hover {
    background: color-mix(in srgb, #e5484d, transparent 82%);
    color: #e5484d;
}

.hi-faq-widget__chat-mic--processing {
    position: relative;
    color: transparent;
}

.hi-faq-widget__chat-mic--processing::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid color-mix(in srgb, var(--hifaq-widget-color), transparent 65%);
    border-top-color: var(--hifaq-widget-color);
    border-radius: 50%;
    animation: hiFaqWidgetSpin 0.7s linear infinite;
}

@keyframes hi-faq-widget-mic-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, #e5484d, transparent 70%);
    }
    50% {
        box-shadow: 0 0 0 6px color-mix(in srgb, #e5484d, transparent 100%);
    }
}

.hi-faq-widget__chat-input {
    flex: 1;
    min-height: 24px;
    max-height: 120px;
    padding: 6px 0;
    border: none;
    background: transparent;
    color: var(--hifaq-widget-text);
    font: inherit;
    font-size: 0.9063rem;
    line-height: 1.4;
    resize: none;
    outline: none;
}

.hi-faq-widget__chat-input:disabled {
    opacity: 0.6;
}

.hi-faq-widget__chat-send {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--hifaq-widget-color);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s var(--hifaq-widget-spring), opacity 0.15s ease;
}

.hi-faq-widget__chat-send svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.hi-faq-widget__chat-send:hover {
    background: var(--hifaq-widget-color-hover);
    transform: scale(1.05);
}

.hi-faq-widget__chat-send:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.hi-faq-widget__chat-retry {
    padding: 6px 12px;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 10px;
    background: var(--hifaq-widget-bg);
    color: var(--hifaq-widget-color);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
}

.hi-faq-widget__chat-retry:hover {
    border-color: var(--hifaq-widget-color);
}

/* Attribution caption under AI messages ("AI Agent • Just now") */

.hi-faq-widget__msg-caption {
    margin: 4px 4px 0;
    color: var(--hifaq-widget-text-muted);
    font-size: 0.6875rem;
}

/* Floating "scroll to latest" button above the composer */

.hi-faq-widget__chat-jump {
    position: absolute;
    top: -46px;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--hifaq-widget-border);
    border-radius: 50%;
    background: var(--hifaq-widget-bg);
    box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
    color: var(--hifaq-widget-text);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s var(--hifaq-widget-spring);
}

.hi-faq-widget__chat-jump--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.hi-faq-widget__chat-jump svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
    transform: rotate(90deg);
}

.hi-faq-widget__chat-jump:hover {
    color: var(--hifaq-widget-color);
}

/* --------------------------------------------------------------------------
   Loading spinner
   -------------------------------------------------------------------------- */

.hi-faq-widget__loading {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.hi-faq-widget__spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--hifaq-widget-border);
    border-top-color: var(--hifaq-widget-color);
    border-radius: 50%;
    animation: hiFaqWidgetSpin 0.7s linear infinite;
}

@keyframes hiFaqWidgetSpin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */

@media (max-width: 575px) {
    .hi-faq-widget__panel {
        position: fixed;
        inset: 0;
        bottom: 0;
        width: 100vw;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }

    .hi-faq-widget__panel--wide {
        width: 100vw;
    }
}

.hi-faq-widget--hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hi-faq-widget--hide-mobile {
        display: block;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .hi-faq-widget__panel,
    .hi-faq-widget__launcher,
    .hi-faq-widget__launcher-icon,
    .hi-faq-widget__view--enter-forward,
    .hi-faq-widget__view--enter-back,
    .hi-faq-widget__view--exit-forward,
    .hi-faq-widget__view--exit-back,
    .hi-faq-widget__chat-mic--recording {
        transition: none;
        animation: none;
    }
}
