/* ================================================================
   Chat widget — front end
   Floating launcher + panel, inline embed, light and dark modes.
   Accessibility: WCAG 2.1 AA contrast, visible focus, reduced motion.
   ================================================================ */

:root {
    /* Chat button. A theme can set the shared floating-button style
       (--tf-float-size, -bg, -bg-hover, -fg, -border, -shadow, -icon, -offset);
       those win over these, which come from the plugin's own settings. */
    --gochatterbot-launcher-size: 60px;
    --gochatterbot-launcher-offset: 24px;
    --gochatterbot-launcher-border: none;
    --gochatterbot-accent: #6366f1;
    --gochatterbot-accent-dark: #4f46e5;
    --gochatterbot-accent-light: #e0e7ff;
    /* Set from the accent by frontend.js; these are safe defaults. */
    --gochatterbot-on-accent: #000000;          /* text/icons on the accent */
    --gochatterbot-accent-ink: #4338ca;         /* accent-coloured text on the panel */
    --gochatterbot-accent-overlay: rgba(255,255,255,0.4);
    --gochatterbot-accent-overlay-strong: rgba(255,255,255,0.6);
    --gochatterbot-bg: #ffffff;
    --gochatterbot-bg-secondary: #f9fafb;
    --gochatterbot-text: #111827;
    --gochatterbot-text-secondary: #4b5563;     /* 7.5:1 on white */
    --gochatterbot-text-light: #6b7280;         /* 4.8:1 on white, 4.6:1 on bg-secondary */
    --gochatterbot-border: #e5e7eb;
    --gochatterbot-border-light: #f3f4f6;
    --gochatterbot-control-border: #868e96;     /* form controls, 3.3:1 */
    --gochatterbot-focus-outer: #111827;
    --gochatterbot-focus-inner: #ffffff;
    --gochatterbot-notice-bg: #f1f5f9;
    --gochatterbot-notice-border: #cbd5e1;
    --gochatterbot-notice-text: #334155;
    --gochatterbot-notice-icon: #475569;
    --gochatterbot-emergency-bg: #fef2f2;
    --gochatterbot-emergency-border: #b91c1c;
    --gochatterbot-emergency-text: #7f1d1d;
    --gochatterbot-emergency-button: #b91c1c;
    --gochatterbot-emergency-button-hover: #991b1b;
    --gochatterbot-radius: 16px;
    --gochatterbot-radius-sm: 12px;
    --gochatterbot-radius-msg: 18px;
    --gochatterbot-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
    --gochatterbot-shadow-launcher: 0 8px 30px rgba(99,102,241,0.35);
    --gochatterbot-shadow-launcher-hover: 0 12px 40px rgba(99,102,241,0.45);
    --gochatterbot-panel-width: 400px;
    --gochatterbot-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --gochatterbot-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode */
.gochatterbot-dark {
    --gochatterbot-bg: #1f2937;
    --gochatterbot-bg-secondary: #111827;
    --gochatterbot-text: #f9fafb;
    --gochatterbot-text-secondary: #d1d5db;
    --gochatterbot-text-light: #9ca3af;         /* 5.8:1 on bg, 7:1 on bg-secondary */
    --gochatterbot-border: #374151;
    --gochatterbot-border-light: #1f2937;
    --gochatterbot-accent-light: #312e81;
    --gochatterbot-accent-ink: #a5b4fc;
    --gochatterbot-control-border: #7b8494;
    --gochatterbot-focus-outer: #ffffff;
    --gochatterbot-focus-inner: #111827;
    --gochatterbot-notice-bg: #111827;
    --gochatterbot-notice-border: #4b5563;
    --gochatterbot-notice-text: #e5e7eb;
    --gochatterbot-notice-icon: #cbd5e1;
    --gochatterbot-emergency-bg: #450a0a;
    --gochatterbot-emergency-border: #f87171;
    --gochatterbot-emergency-text: #fee2e2;
}

/* ── Reset for widget scope ───────────────────────────── */
.gochatterbot-widget,
.gochatterbot-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--gochatterbot-font);
    -webkit-font-smoothing: antialiased;
}

/* ── Screen-reader-only text ──────────────────────────── */
.gochatterbot-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── Focus ────────────────────────────────────────────────
   Two-tone ring (dark + light) so it shows on any background,
   including the accent colour and the host page. */
.gochatterbot-widget :focus:not(:focus-visible) {
    outline: none;
}

.gochatterbot-widget :focus-visible {
    outline: 3px solid var(--gochatterbot-focus-outer);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--gochatterbot-focus-inner);
}

/* The panel and dialogs take focus only to move the reading position. */
.gochatterbot-widget .gochatterbot-panel:focus,
.gochatterbot-widget .gochatterbot-feedback-card:focus {
    outline: none;
}
.gochatterbot-widget .gochatterbot-panel:focus-visible {
    box-shadow: var(--gochatterbot-shadow);
}
.gochatterbot-widget .gochatterbot-feedback-card:focus-visible {
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* The borderless textarea: its row shows the ring (see .gochatterbot-input-focused). */
.gochatterbot-widget .gochatterbot-input:focus-visible {
    outline: none;
    box-shadow: none;
}

/* The scrolling message list: ring drawn inside (the panel clips outside). */
.gochatterbot-widget .gochatterbot-messages:focus-visible {
    outline-offset: -3px;
    box-shadow: none;
}

/* ── Launcher Button ──────────────────────────────────── */
.gochatterbot-launcher {
    position: fixed;
    z-index: 2147483646;
    bottom: var(--tf-float-offset, var(--gochatterbot-launcher-offset));
    right: var(--tf-float-offset, var(--gochatterbot-launcher-offset));
    width: var(--tf-float-size, var(--gochatterbot-launcher-size));
    height: var(--tf-float-size, var(--gochatterbot-launcher-size));
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--tf-float-bg, var(--gochatterbot-accent));
    color: var(--tf-float-fg, var(--gochatterbot-on-accent));
    border: var(--tf-float-border, var(--gochatterbot-launcher-border));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--tf-float-shadow, var(--gochatterbot-shadow-launcher));
    transition: transform var(--gochatterbot-transition), box-shadow var(--gochatterbot-transition), background-color var(--gochatterbot-transition);
}

.gochatterbot-launcher:hover {
    transform: scale(1.08);
    background: var(--tf-float-bg-hover, var(--tf-float-bg, var(--gochatterbot-accent)));
    box-shadow: var(--tf-float-shadow, var(--gochatterbot-shadow-launcher-hover));
}

.gochatterbot-launcher:active {
    transform: scale(0.95);
}

/* Two-tone focus: a dark outline inside a white halo, so it shows on light
   pages and on dark sections alike, separate from the button's own ring. */
.gochatterbot-widget .gochatterbot-launcher:focus-visible {
    outline: 3px solid var(--gochatterbot-focus-outer);
    outline-offset: 2px;
    box-shadow: 0 0 0 7px var(--gochatterbot-focus-inner), var(--tf-float-shadow, var(--gochatterbot-shadow-launcher));
}

.gochatterbot-launcher.bottom-left {
    right: auto;
    left: var(--tf-float-offset, var(--gochatterbot-launcher-offset));
}

.gochatterbot-launcher svg {
    width: var(--tf-float-icon, calc(var(--gochatterbot-launcher-size) * 0.47));
    height: var(--tf-float-icon, calc(var(--gochatterbot-launcher-size) * 0.47));
    transition: transform var(--gochatterbot-transition), opacity var(--gochatterbot-transition);
}

.gochatterbot-launcher .gochatterbot-icon-chat,
.gochatterbot-launcher .gochatterbot-icon-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--gochatterbot-transition), transform var(--gochatterbot-transition);
}

.gochatterbot-launcher .gochatterbot-icon-chat {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.gochatterbot-launcher .gochatterbot-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.gochatterbot-launcher.open .gochatterbot-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.gochatterbot-launcher.open .gochatterbot-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ── Chat Panel ───────────────────────────────────────── */
/* Closed: visibility:hidden (after the fade-out) takes it out of the tab
   order and the accessibility tree. Open: visibility inherits, so the
   whole-widget hide used during session restore still works. */
.gochatterbot-panel {
    position: fixed;
    z-index: 2147483647;
    bottom: calc(var(--tf-float-offset, var(--gochatterbot-launcher-offset)) + var(--tf-float-size, var(--gochatterbot-launcher-size)) + 16px);
    right: var(--tf-float-offset, var(--gochatterbot-launcher-offset));
    width: var(--gochatterbot-panel-width);
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - var(--tf-float-offset, var(--gochatterbot-launcher-offset)) - var(--tf-float-size, var(--gochatterbot-launcher-size)) - 56px);
    background: var(--gochatterbot-bg);
    border-radius: var(--gochatterbot-radius);
    box-shadow: var(--gochatterbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity var(--gochatterbot-transition), transform var(--gochatterbot-transition), visibility 0s linear 0.3s;
    border: 1px solid var(--gochatterbot-border);
}

.gochatterbot-panel.bottom-left {
    right: auto;
    left: var(--tf-float-offset, var(--gochatterbot-launcher-offset));
}

.gochatterbot-panel.open {
    opacity: 1;
    visibility: inherit;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity var(--gochatterbot-transition), transform var(--gochatterbot-transition), visibility 0s linear 0s;
}

/* ── Panel Header ─────────────────────────────────────── */
.gochatterbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: var(--gochatterbot-accent);
    color: var(--gochatterbot-on-accent);
    flex-shrink: 0;
}

.gochatterbot-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gochatterbot-accent-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gochatterbot-header-avatar svg {
    width: 22px;
    height: 22px;
}

.gochatterbot-header-info {
    flex: 1;
    min-width: 0;
}

.gochatterbot-header-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.gochatterbot-header-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.gochatterbot-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    display: inline-block;
}

.gochatterbot-header-actions {
    display: flex;
    gap: 4px;
}

.gochatterbot-header-btn {
    width: 32px;
    height: 32px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 8px;
    border: none;
    background: var(--gochatterbot-accent-overlay);
    color: var(--gochatterbot-on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--gochatterbot-transition);
}

.gochatterbot-close-btn {
    display: none;
}

.gochatterbot-header-btn:hover {
    background: var(--gochatterbot-accent-overlay-strong);
}

.gochatterbot-header-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Messages Area ────────────────────────────────────── */
.gochatterbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Force instant scroll — never inherit smooth scrolling from the
       host site's theme or global CSS resets. */
    scroll-behavior: auto !important;
}

.gochatterbot-messages::-webkit-scrollbar {
    width: 5px;
}

.gochatterbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.gochatterbot-messages::-webkit-scrollbar-thumb {
    background: var(--gochatterbot-border);
    border-radius: 10px;
}

/* ── AI notice (informational, top of the conversation) ── */
.gochatterbot-ai-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--gochatterbot-notice-bg);
    border: 1px solid var(--gochatterbot-notice-border);
    border-radius: var(--gochatterbot-radius-sm);
    color: var(--gochatterbot-notice-text);
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    flex-shrink: 0;
}

.gochatterbot-ai-notice-icon {
    display: flex;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--gochatterbot-notice-icon);
}

.gochatterbot-ai-notice-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.gochatterbot-ai-notice-text {
    min-width: 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* ── Emergency notice (before the question; not sent to the server) ── */
.gochatterbot-emergency {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--gochatterbot-emergency-bg);
    border: 2px solid var(--gochatterbot-emergency-border);
    border-radius: var(--gochatterbot-radius-sm);
    color: var(--gochatterbot-emergency-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    text-align: left;
    flex-shrink: 0;
    animation: gochatterbot-msg-in 0.3s ease;
}

.gochatterbot-emergency-icon {
    display: flex;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--gochatterbot-emergency-border);
}

.gochatterbot-emergency-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.gochatterbot-emergency-body {
    min-width: 0;
    overflow-wrap: anywhere;
}

.gochatterbot-widget .gochatterbot-emergency-call {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 999px;
    background: var(--gochatterbot-emergency-button);
    color: #ffffff;                 /* 6.5:1 on #b91c1c */
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
}

.gochatterbot-widget .gochatterbot-emergency-call:hover {
    background: var(--gochatterbot-emergency-button-hover);
    color: #ffffff;
    text-decoration: underline;
}

.gochatterbot-emergency-call svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Welcome message ──────────────────────────────────── */
.gochatterbot-welcome {
    text-align: center;
    padding: 20px 10px;
}

.gochatterbot-welcome-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: var(--gochatterbot-accent-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gochatterbot-welcome-icon svg {
    width: 28px;
    height: 28px;
    color: var(--gochatterbot-accent);
}

.gochatterbot-welcome-text {
    font-size: 15px;
    color: var(--gochatterbot-text);
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 6px;
}

.gochatterbot-welcome-sub {
    font-size: 13px;
    color: var(--gochatterbot-text-light);
    line-height: 1.4;
}

/* ── Suggestion Chips ─────────────────────────────────── */
.gochatterbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 4px 0 8px;
}

.gochatterbot-chip {
    padding: 8px 16px;
    font-size: 13px;
    line-height: 1.35;
    background: var(--gochatterbot-bg);
    border: 1px solid var(--gochatterbot-border);
    border-radius: 18px;
    color: var(--gochatterbot-text-secondary);
    cursor: pointer;
    transition: all var(--gochatterbot-transition);
    /* Wrap long suggestions instead of cutting them off (reflow at 320px). */
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
    max-width: 100%;
}

.gochatterbot-chip:hover {
    background: var(--gochatterbot-accent-light);
    border-color: var(--gochatterbot-accent);
    color: var(--gochatterbot-accent-ink);
}

/* ── Message Bubbles ──────────────────────────────────── */
.gochatterbot-message {
    display: flex;
    gap: 10px;
    max-width: 88%;
    min-width: 0;
    animation: gochatterbot-msg-in 0.3s ease;
}

/* Suppress all animations/transitions during session restore so
   messages appear instantly with zero flicker. */
.gochatterbot-restoring .gochatterbot-message,
.gochatterbot-restoring .gochatterbot-emergency {
    animation: none !important;
}
.gochatterbot-restoring,
.gochatterbot-restoring * {
    transition: none !important;
}

@keyframes gochatterbot-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gochatterbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.gochatterbot-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.gochatterbot-message.bot .gochatterbot-message-avatar {
    background: var(--gochatterbot-accent-light);
    color: var(--gochatterbot-accent);
}

.gochatterbot-message.user .gochatterbot-message-avatar {
    background: #e0e7eb;
    color: #4b5563;
}

.gochatterbot-bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    border-radius: var(--gochatterbot-radius-msg);
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

.gochatterbot-message.bot .gochatterbot-bubble {
    background: var(--gochatterbot-bg-secondary);
    color: var(--gochatterbot-text);
    border-bottom-left-radius: 6px;
}

/* Links in answers: underlined (not colour alone) and 4.5:1 in both modes. */
.gochatterbot-message.bot .gochatterbot-bubble a {
    color: var(--gochatterbot-accent-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gochatterbot-message.bot .gochatterbot-bubble a:hover {
    text-decoration-thickness: 2px;
}

.gochatterbot-message.user .gochatterbot-bubble {
    background: var(--gochatterbot-accent);
    color: var(--gochatterbot-on-accent);
    border-bottom-right-radius: 6px;
}

/* ── Source Cards ──────────────────────────────────────── */
.gochatterbot-sources {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-left: 40px;
    min-width: 0;
}

.gochatterbot-sources-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gochatterbot-text-light);
    margin-bottom: 2px;
}

.gochatterbot-source-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--gochatterbot-bg);
    border: 1px solid var(--gochatterbot-border);
    border-radius: var(--gochatterbot-radius-sm);
    text-decoration: none;
    transition: all var(--gochatterbot-transition);
    overflow: hidden;
    min-width: 0;
}

.gochatterbot-source-card:hover {
    border-color: var(--gochatterbot-accent);
    background: var(--gochatterbot-accent-light);
}

.gochatterbot-source-card:hover .gochatterbot-source-title {
    text-decoration: underline;
}

.gochatterbot-source-card:hover .gochatterbot-source-type {
    color: var(--gochatterbot-text-secondary);
}

.gochatterbot-source-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--gochatterbot-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gochatterbot-source-icon svg {
    width: 14px;
    height: 14px;
    color: var(--gochatterbot-accent);
}

.gochatterbot-source-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gochatterbot-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.gochatterbot-source-type {
    font-size: 11px;
    color: var(--gochatterbot-text-light);
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Structured Data Cards ────────────────────────────── */
.gochatterbot-structured-data {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-left: 40px;
    min-width: 0;
}

.gochatterbot-sd-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 14px;
    background: var(--gochatterbot-accent-light);
    border: 1px solid var(--gochatterbot-accent);
    border-radius: var(--gochatterbot-radius-sm);
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

.gochatterbot-sd-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gochatterbot-text-secondary);
}

.gochatterbot-sd-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--gochatterbot-text);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.gochatterbot-sd-value a {
    color: var(--gochatterbot-accent-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gochatterbot-sd-value a:hover {
    text-decoration-thickness: 2px;
}

/* ── Typing Indicator & Step Labels ───────────────────── */
.gochatterbot-typing {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 0;
}

.gochatterbot-typing-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gochatterbot-typing .gochatterbot-bubble {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 14px 20px;
    background: var(--gochatterbot-bg-secondary);
    border-radius: var(--gochatterbot-radius-msg);
    border-bottom-left-radius: 6px;
}

.gochatterbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gochatterbot-text-light);
    animation: gochatterbot-bounce 1.4s ease-in-out infinite;
}

.gochatterbot-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.gochatterbot-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes gochatterbot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* Step label below the typing dots */
.gochatterbot-step-label {
    font-size: 11px;
    color: var(--gochatterbot-text-light);
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-height: 0;
    overflow: hidden;
}

.gochatterbot-step-label.visible {
    opacity: 1;
    max-height: 20px;
}

/* ── Streaming word fade-in (ChatGPT-style) ─────────── */
.gcb-word {
    opacity: 0;
    animation: gcb-fade-in 0.25s ease forwards;
}

@keyframes gcb-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Skeleton shimmer (ChatGPT-style loading cards) ── */
.gcb-skeleton-card {
    overflow: hidden;
}

.gcb-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--gochatterbot-border-light) 25%, var(--gochatterbot-border) 50%, var(--gochatterbot-border-light) 75%);
    background-size: 200% 100%;
    animation: gcb-shimmer 1.5s ease infinite;
    width: 80%;
    margin: 4px 0;
}

.gcb-skeleton-line.gcb-skeleton-short {
    width: 45%;
}

.gcb-skeleton-circle {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    background: linear-gradient(90deg, var(--gochatterbot-border-light) 25%, var(--gochatterbot-border) 50%, var(--gochatterbot-border-light) 75%);
    background-size: 200% 100%;
    animation: gcb-shimmer 1.5s ease infinite;
}

@keyframes gcb-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Card reveal animation (replaces skeleton with real content) ── */
.gcb-card-reveal {
    animation: gcb-card-in 0.35s ease forwards;
}

@keyframes gcb-card-in {
    from { opacity: 0.4; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Input Footer ─────────────────────────────────────── */
.gochatterbot-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--gochatterbot-border-light);
    background: var(--gochatterbot-bg);
    flex-shrink: 0;
}

.gochatterbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--gochatterbot-bg-secondary);
    border: 1px solid var(--gochatterbot-control-border);
    border-radius: var(--gochatterbot-radius-sm);
    padding: 4px 4px 4px 16px;
    transition: border-color var(--gochatterbot-transition), box-shadow var(--gochatterbot-transition);
}

/* Focus ring for the textarea, drawn on its row. */
.gochatterbot-input-row.gochatterbot-input-focused {
    border-color: var(--gochatterbot-accent-ink);
    box-shadow: 0 0 0 2px var(--gochatterbot-accent-ink);
}

.gochatterbot-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--gochatterbot-text);
    outline: none;
    resize: none;
    height: 36px;
    min-height: 36px;
    max-height: 100px;
    line-height: 1.5;
    padding: 8px 0;
    font-family: var(--gochatterbot-font);
    overflow-y: hidden;
}

.gochatterbot-input::placeholder {
    color: var(--gochatterbot-text-light);
    opacity: 1;
}

.gochatterbot-input:focus::placeholder {
    color: var(--gochatterbot-text-light);
    opacity: 1;
}

.gochatterbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: var(--gochatterbot-accent);
    color: var(--gochatterbot-on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--gochatterbot-transition), transform var(--gochatterbot-transition);
}

.gochatterbot-send-btn:hover {
    background: var(--gochatterbot-accent-dark);
}

.gochatterbot-send-btn:active {
    transform: scale(0.92);
}

.gochatterbot-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.gochatterbot-send-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    pointer-events: none;
}

/* ── Disclaimer ───────────────────────────────────────── */
.gochatterbot-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--gochatterbot-text-light);
    padding: 0 20px 12px;
    line-height: 1.4;
}

/* ── Error state ──────────────────────────────────────── */
.gochatterbot-error {
    text-align: center;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--gochatterbot-radius-sm);
    color: #991b1b;
    font-size: 13px;
    flex-shrink: 0;
}

/* ── Embed container ──────────────────────────────────── */
.gochatterbot-embed-container .gochatterbot-panel {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
    opacity: 1;
    visibility: inherit;
    transform: none;
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
    height: 500px;
    border-radius: var(--gochatterbot-radius);
}

/* ── Mobile ─────────────────────────────────────────────
   Below 480px the floating panel covers the screen, so frontend.js
   treats it as a modal dialog (aria-modal, focus kept inside). */
@media (max-width: 480px) {
    /* top + bottom rather than 100vh: fills the visible screen on phones
       whose toolbars change the viewport height. */
    .gochatterbot-panel {
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
        border-radius: 0;
    }

    .gochatterbot-panel.bottom-left {
        left: 0;
        right: 0;
    }

    /* Prevent iOS auto-zoom on input focus (requires >= 16px). */
    .gochatterbot-input {
        font-size: 16px;
    }

    .gochatterbot-launcher {
        bottom: var(--tf-float-offset, 16px);
        right: var(--tf-float-offset, 16px);
        width: var(--tf-float-size, calc(var(--gochatterbot-launcher-size) * 0.9));
        height: var(--tf-float-size, calc(var(--gochatterbot-launcher-size) * 0.9));
    }

    .gochatterbot-launcher svg {
        width: var(--tf-float-icon, calc(var(--gochatterbot-launcher-size) * 0.42));
        height: var(--tf-float-icon, calc(var(--gochatterbot-launcher-size) * 0.42));
    }

    .gochatterbot-launcher.bottom-left {
        left: var(--tf-float-offset, 16px);
        right: auto;
    }

    .gochatterbot-close-btn {
        display: flex;
    }
}

/* Short windows (e.g. 400% zoom on a laptop): keep room for the messages. */
@media (max-height: 420px) {
    .gochatterbot-header {
        padding: 8px 14px;
        gap: 8px;
    }

    .gochatterbot-header-avatar,
    .gochatterbot-header-status,
    .gochatterbot-welcome-icon {
        display: none;
    }

    .gochatterbot-messages {
        padding: 10px 12px;
        gap: 10px;
    }

    .gochatterbot-input-area {
        padding: 8px 12px;
    }

    .gochatterbot-disclaimer {
        padding: 0 12px 6px;
    }
}

/* ── User text selection ─────────────────────────────── */
.gochatterbot-message.user .gochatterbot-bubble {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    cursor: text;
}

.gochatterbot-message.user .gochatterbot-bubble::selection {
    background: var(--gochatterbot-on-accent);
    color: var(--gochatterbot-accent);
}

.gochatterbot-message.user .gochatterbot-bubble::-moz-selection {
    background: var(--gochatterbot-on-accent);
    color: var(--gochatterbot-accent);
}

/* ── Response action buttons ─────────────────────────── */
.gochatterbot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 0 2px 42px;
}

.gochatterbot-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gochatterbot-text-light);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.gochatterbot-action-btn svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.gochatterbot-action-btn:hover {
    background: var(--gochatterbot-border-light);
    color: var(--gochatterbot-text-secondary);
}

.gochatterbot-action-btn.active {
    color: var(--gochatterbot-accent-ink);
}

/* ── Stop button mode ────────────────────────────────── */
.gochatterbot-send-btn.gochatterbot-stop-mode {
    background: var(--gochatterbot-accent);
    color: var(--gochatterbot-on-accent);
    border-radius: 50%;
}

.gochatterbot-send-btn.gochatterbot-stop-mode:hover {
    background: var(--gochatterbot-accent-dark);
}

/* ── Feedback modal ──────────────────────────────────── */
.gochatterbot-feedback-modal {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--gochatterbot-radius);
}

.gochatterbot-feedback-card {
    background: var(--gochatterbot-bg);
    border-radius: 12px;
    padding: 20px;
    width: 300px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.gochatterbot-feedback-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gochatterbot-text);
    margin-bottom: 12px;
}

.gochatterbot-feedback-select {
    width: 100%;
    padding: 9px 32px 9px 12px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid var(--gochatterbot-control-border);
    border-radius: 8px;
    background-color: var(--gochatterbot-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    color: var(--gochatterbot-text);
    margin-bottom: 10px;
    outline: none;
    font-family: var(--gochatterbot-font);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gochatterbot-dark .gochatterbot-feedback-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.gochatterbot-feedback-select:hover {
    border-color: var(--gochatterbot-text-light);
}

.gochatterbot-feedback-select:focus {
    border-color: var(--gochatterbot-accent-ink);
}

.gochatterbot-feedback-details {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    border: 1px solid var(--gochatterbot-control-border);
    border-radius: 8px;
    background: var(--gochatterbot-bg);
    color: var(--gochatterbot-text);
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
    margin-bottom: 12px;
    outline: none;
    font-family: var(--gochatterbot-font);
    line-height: 1.5;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gochatterbot-feedback-details::placeholder {
    color: var(--gochatterbot-text-light);
    opacity: 1;
}

.gochatterbot-feedback-details:hover {
    border-color: var(--gochatterbot-text-light);
}

.gochatterbot-feedback-details:focus {
    border-color: var(--gochatterbot-accent-ink);
}

.gochatterbot-feedback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.gochatterbot-feedback-cancel,
.gochatterbot-feedback-submit {
    padding: 7px 18px;
    min-height: 32px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--gochatterbot-font);
    transition: background 0.15s ease, transform 0.1s ease;
}

.gochatterbot-feedback-cancel:active,
.gochatterbot-feedback-submit:active {
    transform: scale(0.96);
}

.gochatterbot-feedback-cancel {
    background: var(--gochatterbot-border-light);
    color: var(--gochatterbot-text-secondary);
}

.gochatterbot-dark .gochatterbot-feedback-cancel {
    background: var(--gochatterbot-border);
}

.gochatterbot-feedback-cancel:hover {
    background: var(--gochatterbot-border);
}

.gochatterbot-dark .gochatterbot-feedback-cancel:hover {
    background: #4b5563;
}

.gochatterbot-feedback-submit {
    background: var(--gochatterbot-accent);
    color: var(--gochatterbot-on-accent);
}

.gochatterbot-feedback-submit:hover {
    background: var(--gochatterbot-accent-dark);
}

/* ── Inline embed ([gochatterbot embed]) ─────────────── */
.gochatterbot-embed-container { width: 100%; margin: 24px 0; }
.gochatterbot-widget.gochatterbot-embedded .gochatterbot-launcher,
.gochatterbot-widget.gochatterbot-embedded .gochatterbot-close-btn { display: none; }
.gochatterbot-widget.gochatterbot-embedded .gochatterbot-panel {
    position: relative;
    z-index: auto;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    max-width: 100%;
    max-height: none;
    opacity: 1;
    visibility: inherit;
    transform: none;
    pointer-events: auto;
}

/* ── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .gochatterbot-widget,
    .gochatterbot-widget *,
    .gochatterbot-widget *::before,
    .gochatterbot-widget *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    /* Streamed words start transparent for the fade-in: show them as is. */
    .gochatterbot-widget .gcb-word {
        opacity: 1;
    }

    .gochatterbot-launcher:hover,
    .gochatterbot-launcher:active,
    .gochatterbot-send-btn:active,
    .gochatterbot-feedback-cancel:active,
    .gochatterbot-feedback-submit:active {
        transform: none;
    }

    .gochatterbot-panel {
        transform: none;
    }
}
