/*! GroundedChat | (C) 2026 GroundedChat | GPL-2.0-or-later */
/* GroundedChat widget styles. Licence GPL-2.0-or-later.
 * Everything is scoped under .gc-root (plus html.gc-lock). Theme through the custom properties below;
 * --gc-accent and --gc-accent-text are set by the script from the module/plugin parameters. */

.gc-root {
    --gc-accent: #2563eb;
    --gc-accent-text: #ffffff;
    --gc-bg: #ffffff;
    --gc-fg: #1f2937;
    --gc-muted: #4b5563;
    --gc-border: #cbd5e1;
    --gc-surface: #f1f5f9;
    --gc-danger: #b91c1c;
    --gc-radius: 12px;
    --gc-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --gc-z: 2147483000;
    --gc-offset: 16px;
    --gc-target: 44px;
    /* Launcher (V110): the script sets the -d/-m source values inline; the fallbacks equal the 1.0.1 look */
    --gc-l-size: var(--gc-l-size-d, 56px);
    --gc-l-icon: var(--gc-l-icon-d, 24px);
    --gc-l-bottom: var(--gc-l-bottom-d, var(--gc-offset, 16px));
    --gc-l-side: var(--gc-l-side-d, var(--gc-offset, 16px));
    --gc-l-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    --gc-ring-in: #ffffff;
    --gc-ring-out: #1a1a1a;
    --gc-ring-wi: 0px;
    --gc-ring-wo: 0px;
    --gc-pulse: var(--gc-accent);
    --gc-pulse-ms: 1600ms;
    --gc-pulse-n: 3;
    font-family: var(--gc-font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--gc-fg);
    text-align: start;
    -webkit-text-size-adjust: 100%;
}

@media (max-width: 600px) {
    .gc-root {
        --gc-l-size: var(--gc-l-size-m, 56px);
        --gc-l-icon: var(--gc-l-icon-m, 24px);
        --gc-l-bottom: var(--gc-l-bottom-m, var(--gc-offset, 16px));
        --gc-l-side: var(--gc-l-side-m, var(--gc-offset, 16px));
    }
}

@media (prefers-color-scheme: dark) {
    .gc-root {
        --gc-bg: #1b2130;
        --gc-fg: #e5e7eb;
        --gc-muted: #aab3c2;
        --gc-border: #3b4559;
        --gc-surface: #283044;
        --gc-danger: #fca5a5;
        --gc-halo: #0b1020;
    }
}

.gc-root[hidden],
.gc-root [hidden] {
    display: none !important;
}

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

.gc-root button,
.gc-root textarea {
    font: inherit;
    color: inherit;
}

.gc-root .gc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Launcher (floating mode) */
.gc-root .gc-launcher {
    position: fixed;
    inset-block-end: calc(var(--gc-l-bottom) + env(safe-area-inset-bottom, 0px));
    inset-inline-end: calc(var(--gc-l-side) + env(safe-area-inset-right, 0px));
    z-index: var(--gc-z);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: var(--gc-l-size);
    min-height: var(--gc-l-size);
    max-width: calc(100vw - 2 * var(--gc-l-side));
    padding: 0;
    border: 0;
    border-radius: calc(var(--gc-l-size) / 2);
    background: var(--gc-accent);
    color: var(--gc-accent-text);
    box-shadow: var(--gc-l-shadow);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.gc-root .gc-launcher:hover {
    transform: scale(1.05);
}

.gc-root .gc-launcher svg {
    width: var(--gc-l-icon);
    height: var(--gc-l-icon);
    fill: currentColor;
    flex: none;
}

.gc-root.gc-left .gc-launcher {
    inset-inline-end: auto;
    inset-inline-start: calc(var(--gc-l-side) + env(safe-area-inset-left, 0px));
}

/* Shadow presets (no class = standard = 1.0.1); "none" is a transparent layer so it stays valid in a shadow list */
.gc-root.gc-shadow-none {
    --gc-l-shadow: 0 0 0 0 transparent;
}

.gc-root.gc-shadow-soft {
    --gc-l-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gc-root.gc-shadow-strong {
    --gc-l-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* Two-tone ring: inner then outer spread, in front of the drop shadow */
.gc-root.gc-ring .gc-launcher {
    box-shadow: 0 0 0 var(--gc-ring-wi) var(--gc-ring-in), 0 0 0 calc(var(--gc-ring-wi) + var(--gc-ring-wo)) var(--gc-ring-out), var(--gc-l-shadow);
}

/* Focus on a ringed launcher: the outline sits outside the ring; a 2px halo fills the gap (D-275) */
.gc-root.gc-ring .gc-launcher:focus-visible {
    outline-offset: calc(var(--gc-ring-wi) + var(--gc-ring-wo) + 2px);
    box-shadow: 0 0 0 var(--gc-ring-wi) var(--gc-ring-in), 0 0 0 calc(var(--gc-ring-wi) + var(--gc-ring-wo)) var(--gc-ring-out), 0 0 0 calc(var(--gc-ring-wi) + var(--gc-ring-wo) + 2px) var(--gc-halo, #ffffff), var(--gc-l-shadow);
}

/* Attention pulse: the script adds .gc-pulsing after the delay */
.gc-root .gc-launcher::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

.gc-root.gc-pulsing .gc-launcher::after {
    animation: gc-pulse var(--gc-pulse-ms, 1600ms) ease-out 0s var(--gc-pulse-n, 3);
}

.gc-root.gc-pulsing .gc-launcher:hover::after,
.gc-root.gc-pulsing .gc-launcher:focus-visible::after {
    animation-play-state: paused;
}

@keyframes gc-pulse {
    from {
        box-shadow: 0 0 0 0 var(--gc-pulse);
        opacity: 0.7;
    }
    to {
        box-shadow: 0 0 0 18px var(--gc-pulse);
        opacity: 0;
    }
}

/* Optional visible label: hidden by default, shown per viewport class */
.gc-root .gc-launcher .gc-l-text {
    display: none;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (min-width: 601px) {
    .gc-root.gc-label-d .gc-launcher .gc-l-text {
        display: inline;
    }

    .gc-root.gc-label-d .gc-launcher {
        width: auto;
        min-width: var(--gc-l-size);
        padding: 0 1rem;
    }
}

@media (max-width: 600px) {
    .gc-root.gc-label-m .gc-launcher .gc-l-text {
        display: inline;
    }

    .gc-root.gc-label-m .gc-launcher {
        width: auto;
        min-width: var(--gc-l-size);
        padding: 0 1rem;
    }
}

.gc-root.gc-open .gc-launcher {
    display: none;
}

/* Panel: full screen on phones, floating card above 600px */
.gc-root .gc-panel {
    position: fixed;
    inset: 0;
    z-index: var(--gc-z);
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: var(--gc-bg);
    color: var(--gc-fg);
    overflow: hidden;
}

.gc-root.gc-open .gc-panel,
.gc-root .gc-panel.gc-open {
    display: flex;
}

html.gc-lock {
    overflow: hidden;
}

@media (min-width: 601px) {
    .gc-root .gc-panel {
        inset: auto;
        inset-block-end: var(--gc-offset);
        inset-inline-end: var(--gc-offset);
        width: 380px;
        max-width: calc(100vw - 2 * var(--gc-offset));
        height: 640px;
        max-height: calc(100vh - 2 * var(--gc-offset));
        padding: 0;
        border: 1px solid var(--gc-border);
        border-radius: var(--gc-radius);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }

    .gc-root.gc-left .gc-panel {
        inset-inline-end: auto;
        inset-inline-start: var(--gc-offset);
    }

    html.gc-lock {
        overflow: visible;
    }
}

/* Inline mode: the panel sits in the module position, always open */
.gc-root.gc-inline .gc-launcher {
    display: none;
}

.gc-root.gc-inline .gc-panel {
    position: relative;
    inset: auto;
    display: flex;
    width: 100%;
    max-width: 100%;
    height: 32rem;
    max-height: 80vh;
    padding: 0;
    border: 1px solid var(--gc-border);
    border-radius: var(--gc-radius);
    box-shadow: none;
    z-index: auto;
}

/* Header */
.gc-root .gc-header {
    display: flex;
    flex: none;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    padding-inline: 1rem 0.5rem;
    background: var(--gc-accent);
    color: var(--gc-accent-text);
}

.gc-root .gc-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding-block: 0.65rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}

.gc-root .gc-disclosure {
    flex: none;
    width: 100%;
    margin: 0;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--gc-border);
    background: var(--gc-surface);
    color: var(--gc-muted);
    font-size: 0.8125rem;
    line-height: 1.4;
}

.gc-root .gc-privacy {
    color: var(--gc-fg);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gc-root .gc-icon-btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    min-width: var(--gc-target);
    min-height: var(--gc-target);
    padding: 0 0.5rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.gc-root .gc-icon-btn:hover {
    background: rgba(127, 127, 127, 0.25);
}

.gc-root .gc-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.gc-root .gc-icon-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: progress;
}

.gc-root .gc-icon-btn[aria-pressed="true"] {
    background: var(--gc-surface);
    color: var(--gc-fg);
    outline: 2px solid var(--gc-border);
    outline-offset: -2px;
}

/* Transcript */
.gc-root .gc-log {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.75rem 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.gc-root .gc-msg {
    max-width: 88%;
    margin: 0 0 0.6rem;
    padding: 0.5rem 0.8rem;
    border-radius: var(--gc-radius);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.gc-root .gc-msg p {
    margin: 0 0 0.5em;
}

.gc-root .gc-msg > :last-child {
    margin-bottom: 0;
}

.gc-root .gc-msg ul,
.gc-root .gc-msg ol {
    margin: 0 0 0.5em;
    padding-inline-start: 1.4em;
}

.gc-root .gc-msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gc-root .gc-msg--user {
    margin-inline-start: auto;
    background: var(--gc-accent);
    color: var(--gc-accent-text);
    border-end-end-radius: 4px;
    white-space: pre-wrap;
}

.gc-root .gc-msg--assistant {
    margin-inline-end: auto;
    background: var(--gc-surface);
    color: var(--gc-fg);
    border-end-start-radius: 4px;
}

.gc-root .gc-msg--welcome {
    white-space: pre-line;
}

.gc-root .gc-msg--notice {
    max-width: 100%;
    margin-inline: auto;
    background: transparent;
    color: var(--gc-muted);
    font-size: 0.875rem;
    text-align: center;
}

/* Typing indicator (dots are aria-hidden) */
.gc-root .gc-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 1.4em;
}

.gc-root .gc-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
    animation: gc-bounce 1.2s infinite ease-in-out;
}

.gc-root .gc-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.gc-root .gc-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

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

/* Actions region (M5): soft-offer buttons, inline forms, notices */
.gc-root .gc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.gc-root .gc-panel > .gc-actions {
    flex: none;
    max-height: 60vh;
    padding: 0.25rem 1rem 0.5rem;
    overflow-y: auto;
}

.gc-root .gc-form > a {
    display: inline-flex;
    align-items: center;
    min-height: var(--gc-target);
    margin-inline-end: 0.75rem;
    color: var(--gc-fg);
}

.gc-root .gc-actions:empty {
    display: none;
}

.gc-root .gc-actions > button,
.gc-root .gc-form button {
    min-height: var(--gc-target);
    padding: 0 0.9rem;
    border: 1px solid var(--gc-border);
    border-radius: 10px;
    background: var(--gc-surface);
    color: var(--gc-fg);
    font-size: 0.9375rem;
    cursor: pointer;
}

.gc-root .gc-form button[type="submit"] {
    border-color: transparent;
    background: var(--gc-accent);
    color: var(--gc-accent-text);
    font-weight: 600;
}

.gc-root .gc-form {
    flex: 1 1 100%;
    min-width: 0;
    margin: 0;
    padding: 0.75rem;
    border: 1px solid var(--gc-border);
    border-radius: var(--gc-radius);
    background: var(--gc-bg);
}

.gc-root .gc-form--upfront {
    background: var(--gc-surface);
}

.gc-root .gc-form-intro {
    margin: 0 0 0.6rem;
    color: var(--gc-muted);
    font-size: 0.875rem;
}

.gc-root .gc-field {
    display: block;
    margin: 0 0 0.6rem;
}

.gc-root .gc-field label {
    display: block;
    margin-block-end: 0.2rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.gc-root .gc-field input[type="text"],
.gc-root .gc-field input[type="email"],
.gc-root .gc-field textarea {
    display: block;
    width: 100%;
    min-height: var(--gc-target);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--gc-border);
    border-radius: 10px;
    background: var(--gc-bg);
    color: var(--gc-fg);
    font: inherit;
    font-size: 16px; /* no zoom on iOS focus */
    line-height: 1.35;
}

.gc-root .gc-field textarea {
    min-height: 5.5rem;
    resize: vertical;
}

.gc-root .gc-field input[aria-invalid="true"],
.gc-root .gc-field textarea[aria-invalid="true"] {
    border-color: var(--gc-danger);
}

.gc-root .gc-form > .gc-notice[role="alert"] {
    color: var(--gc-danger);
}

.gc-root .gc-field-error {
    margin: 0.25rem 0 0;
    color: var(--gc-danger);
    font-size: 0.8125rem;
}

.gc-root .gc-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    min-height: var(--gc-target);
    margin: 0 0 0.6rem;
    font-size: 0.875rem;
}

.gc-root .gc-check input[type="checkbox"] {
    flex: none;
    width: 24px;
    height: 24px;
    margin: 0.55rem 0 0;
    accent-color: var(--gc-accent);
}

.gc-root .gc-check label {
    flex: 1 1 auto;
    min-width: 0;
    padding-block: 0.6rem;
    font-weight: 400;
    cursor: pointer;
}

.gc-root .gc-notice,
.gc-root .gc-thanks {
    flex: 1 1 100%;
    margin: 0;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    background: var(--gc-surface);
    color: var(--gc-fg);
    font-size: 0.875rem;
}

.gc-root .gc-thanks {
    border-inline-start: 4px solid var(--gc-accent);
}

/* Honeypot: off-screen, not display:none (some bots skip those) */
.gc-root .gc-hp {
    position: absolute;
    inset-inline-start: -10000px;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
}

.gc-root .gc-rating {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    padding: 0 0.75rem;
    color: var(--gc-muted);
    font-size: 0.875rem;
}

/* Alert and captcha */
.gc-root .gc-alert {
    flex: none;
    margin: 0 1rem 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gc-danger);
    border-radius: 8px;
    color: var(--gc-danger);
    font-size: 0.875rem;
}

.gc-root .gc-alert:empty {
    display: none;
}

.gc-root .gc-alert button {
    margin-inline-start: 0.5rem;
    min-height: var(--gc-target);
    padding: 0 0.75rem;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.gc-root [data-gc-captcha] {
    flex: none;
    max-height: 40vh;
    overflow: auto;
}

.gc-root .gc-captcha {
    padding: 0.25rem 1rem;
}

/* Composer */
.gc-root .gc-composer {
    display: flex;
    flex: none;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--gc-border);
    background: var(--gc-bg);
}

.gc-root .gc-input {
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--gc-target);
    max-height: 9rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--gc-border);
    border-radius: 10px;
    background: var(--gc-bg);
    color: var(--gc-fg);
    font-size: 16px; /* 16px or more: no zoom on iOS focus */
    line-height: 1.35;
    resize: none;
}

.gc-root .gc-input::placeholder {
    color: var(--gc-muted);
    opacity: 1;
}

.gc-root .gc-send {
    flex: none;
    min-width: var(--gc-target);
    min-height: var(--gc-target);
    padding: 0 1rem;
    border: 0;
    border-radius: 10px;
    background: var(--gc-accent);
    color: var(--gc-accent-text);
    font-weight: 600;
    cursor: pointer;
}

.gc-root .gc-counter {
    flex: 0 0 100%;
    margin: 0;
    color: var(--gc-muted);
    font-size: 0.75rem;
    text-align: end;
}

/* States */
.gc-root.gc-busy .gc-send,
.gc-root .gc-busy .gc-send {
    opacity: 0.7;
}

.gc-root.gc-disabled .gc-input,
.gc-root .gc-disabled .gc-input,
.gc-root .gc-disabled .gc-send,
.gc-root.gc-disabled .gc-send,
.gc-root button:disabled,
.gc-root textarea:disabled,
.gc-root input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Focus: visible for keyboard users, with a two-colour ring that works on any background */
.gc-root :focus {
    outline: none;
}

.gc-root :focus-visible,
.gc-root .gc-icon-btn[aria-pressed="true"]:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #ffffff;
}

@media (prefers-color-scheme: dark) {
    .gc-root :focus-visible,
    .gc-root .gc-icon-btn[aria-pressed="true"]:focus-visible {
        outline-color: #93c5fd;
        box-shadow: 0 0 0 5px #0b1020;
    }
}

@media (forced-colors: active) {
    .gc-root :focus-visible,
    .gc-root .gc-icon-btn[aria-pressed="true"]:focus-visible {
        outline-color: Highlight;
        box-shadow: none;
    }

    .gc-root.gc-ring .gc-launcher,
    .gc-root.gc-ring .gc-launcher:focus-visible {
        border: 2px solid ButtonText;
        box-shadow: none;
    }
}

/* Reduced motion: nothing moves; the typing dots stay as a static "..." */
@media (prefers-reduced-motion: reduce) {
    .gc-root,
    .gc-root *,
    .gc-root *::before,
    .gc-root *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .gc-root .gc-typing span {
        opacity: 0.7;
    }

    .gc-root .gc-launcher:hover {
        transform: none;
    }

    .gc-root .gc-launcher::after {
        animation: none !important;
    }
}

@media print {
    .gc-root {
        display: none !important;
    }
}
