/* AI Events Chatbot widget. The brand color is set at runtime via the
   --aichat-brand custom property (see widget.js). */

.aichat {
    position: fixed;
    right: 20px;
    bottom: 70px;
    z-index: 99999;
    font-family: var(--aichat-font);
    --aichat-brand: #2b3a42;

    /* WhatsApp palette. The site's own face is deliberately not used here: the
       panel is meant to read as a messaging app, not as part of the page. */
    --aichat-font: "Segoe UI", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
    --wa-header: #008069;
    --wa-accent: #00a884;
    --wa-paper: #efeae2;
    --wa-in: #ffffff;
    --wa-out: #d9fdd3;
    --wa-text: #111b21;
    --wa-meta: #667781;
    --wa-tick: #53bdeb;
    --wa-bar: #f0f2f5;
}

/* Force one font for every bit of text in the widget. The explicit element
   selectors outrank the theme's `* { font-family: Sequel }`, and form controls
   are listed because they don't inherit font-family. */
.aichat,
.aichat p,
.aichat ul,
.aichat ol,
.aichat li,
.aichat a,
.aichat span,
.aichat strong,
.aichat input,
.aichat button,
.aichat textarea {
    font-family: var(--aichat-font);
}

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

/* Launcher — the supplied WhatsApp logo, shown as-is. No background, border,
   shadow or rounding: the artwork already carries its own ring and shadow. */
.aichat__toggle {
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    /* The theme puts "outline: 1px solid #fdfffc" on every <button>, which drew a
       thin white ring around the logo. Class beats element, so this clears it. */
    outline: none;
    background: none;
    line-height: 1;
    cursor: pointer;
}

.aichat__toggle-icon {
    display: block;
    width: 100%;
    height: 100%;
}

/* contain, so the full logo is always visible and never cropped. */
.aichat__toggle-img,
.aichat__toggle-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.aichat__toggle:focus-visible {
    outline: 3px solid #25d366;
    outline-offset: 3px;
}

.aichat.is-open .aichat__toggle {
    display: none;
}

/* Panel */
.aichat__panel {
    display: flex;
    flex-direction: column;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 460px;
    max-height: calc(100vh - 120px);
    overflow: hidden;
    background: var(--wa-paper);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.aichat__panel[hidden] {
    display: none;
}

.aichat__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--wa-header);
    color: #fff;
}

/* Contact row: photo, then name over presence. */
.aichat__avatar {
    flex: none;
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    background: #ccd0d5;
}

.aichat__avatar img,
.aichat__avatar svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aichat__peer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.aichat__title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aichat__status {
    font-size: 11px;
    font-weight: 400;
    line-height: 1.1;
    opacity: 0.85;
}

/* Back arrow, as in a WhatsApp conversation. */
.aichat__close {
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    line-height: 1;
    cursor: pointer;
    outline: none;
}

.aichat__close svg {
    width: 18px;
    height: 18px;
}

.aichat__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
    border-radius: 50%;
}

/* Message area */
.aichat__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain; /* keep scrolling inside the panel */
    -webkit-overflow-scrolling: touch;
    background: var(--wa-paper);
}

.aichat__log:focus-visible {
    outline: 2px solid var(--aichat-brand);
    outline-offset: -2px;
}

.aichat__msg {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 80%;
    padding: 6px 9px 6px 9px;
    font-size: 14.2px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--wa-text);
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.aichat__msg-body {
    white-space: pre-wrap;
}

/* Time, and the read receipt on the visitor's own messages. */
.aichat__meta {
    align-self: flex-end;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1;
    color: var(--wa-meta);
    white-space: nowrap;
}

.aichat__tick {
    width: 15px;
    height: 11px;
    color: var(--wa-tick);
}

.aichat__msg--user {
    align-self: flex-end;
    background: var(--wa-out);
    border-radius: 7.5px 0 7.5px 7.5px;
}

.aichat__msg--bot {
    align-self: flex-start;
    background: var(--wa-in);
    border-radius: 0 7.5px 7.5px 7.5px;
}

/* The little pointer at the top corner of each bubble. */
.aichat__msg--user::before,
.aichat__msg--bot::before {
    content: "";
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
}

.aichat__msg--user::before {
    right: -8px;
    border-top-color: var(--wa-out);
    border-right: 8px solid transparent;
}

.aichat__msg--bot::before {
    left: -8px;
    border-top-color: var(--wa-in);
    border-left: 8px solid transparent;
}

.aichat__msg--bot p {
    color: inherit;
    font-size: 14.2px;
    line-height: 1.35;
}
/* Rendered markdown inside bot messages */
.aichat__msg p {
    margin: 0 0 0.5em;
}

.aichat__msg a {
    color: #027eb5;
}

.aichat__msg p:last-child {
    margin-bottom: 0;
}

.aichat__msg ul,
.aichat__msg ol {
    margin: 0.25em 0 0.5em;
    padding-left: 1.25em;
}

.aichat__msg li {
    margin: 0.15em 0;
}

.aichat__msg strong {
    font-weight: 700;
}

.aichat__msg a {
    color: var(--aichat-brand);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
}

.aichat__msg a:hover {
    border-bottom-color: transparent;
}

.aichat__event-card {
    width: min(100%, 250px);
    margin: 2px 0;
    padding: 10px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(43, 58, 66, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    white-space: normal;
}

.aichat__event-img-wrap {
    margin: -10px -10px 8px; /* bleed to the card edges */
}

.aichat__event-img {
    display: block;
    width: 100%;
    max-height: 110px; /* keep thumbnails small */
    object-fit: cover;
    border-radius: 10px 10px 0 0;
}

.aichat__event-title {
    color: var(--aichat-brand);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.aichat__event-meta {
    margin-top: 4px;
    color: #525b5f;
    font-size: 12px;
    line-height: 1.35;
}

.aichat__event-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.aichat__card-action {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--aichat-brand);
    color: #fff !important;
    border: 1px solid var(--aichat-brand) !important;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.aichat__card-action.is-muted {
    background: #eef1f2;
    color: #525b5f !important;
    border-color: #dfe4e6 !important;
}

.aichat__reveal {
    white-space: pre-wrap;
}

/* Typing indicator */
.aichat__typing {
    display: flex;
    flex-direction: row; /* the bubble itself is a column */
    gap: 4px;
    align-items: center;
    padding: 10px 12px;
}

.aichat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #888;
    animation: aichat-bounce 1.2s infinite ease-in-out;
}

.aichat__typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.aichat__typing span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Starter question chips */
.aichat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
    background: var(--wa-paper);
}

.aichat__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
    background: var(--wa-paper);
}

.aichat__chips[hidden],
.aichat__actions[hidden] {
    display: none;
}

.aichat__chip,
.aichat__action {
    border: 1px solid rgba(0, 168, 132, 0.5);
    border-radius: 999px;
    background: var(--wa-in);
    color: #027a63;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    padding: 6px 12px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.aichat__chip:hover,
.aichat__action:hover {
    background: var(--wa-accent);
    border-color: var(--wa-accent);
    color: #fff;
}

.aichat__chip:focus-visible,
.aichat__action:focus-visible {
    outline: 2px solid var(--wa-accent);
    outline-offset: 2px;
}

/* Composer: rounded field plus a round send button, on its own bar. */
.aichat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 10px;
}

.aichat__inputwrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 4px;
    background: #fff;
    /* Long messages wrap and the field grows; past this it scrolls instead of
       pushing the conversation off screen. */
    max-height: 96px;
    overflow-y: auto;
}

.aichat__input {
    width: 100%;
    min-width: 0;
    height: 21px; /* one line; grown from JS as the text wraps */
    max-height: 80px;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
    line-height: 1.3;
    outline: none;
    color: var(--wa-text);
    resize: none;
    overflow-y: auto;
    display: block;
}

.aichat__input::placeholder {
    color: #8696a0;
}

.aichat__inputwrap:focus-within {
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.35);
}

.aichat__input:disabled {
    background: none;
    opacity: 0.6;
}

.aichat__send {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--wa-accent);
    color: #fff;
    cursor: pointer;
    outline: none;
}

.aichat__send svg {
    width: 20px;
    height: 20px;
    margin-left: 2px; /* optical centring of the paper plane */
}

.aichat__send:focus-visible {
    outline: 2px solid var(--wa-header);
    outline-offset: 2px;
}

/* Footer: Powered by [site] */
.aichat__footer {
    padding: 6px 12px;
    text-align: center;
    font-size: 11px;
    color: #999;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
}

.aichat__footer a {
    color: var(--aichat-brand);
    text-decoration: none;
}

.aichat__footer a:hover {
    text-decoration: underline;
}

/* Human handoff (WhatsApp button, or inline email capture) */
.aichat__handoff {
    align-self: flex-start;
    max-width: 90%;
    padding: 10px 12px;
    border-radius: 0 7.5px 7.5px 7.5px;
    background: var(--wa-in);
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.aichat__handoff-text {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--wa-text);
}

.aichat__handoff-form {
    display: flex;
    gap: 6px;
}

.aichat__handoff-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
}

.aichat__handoff-input:focus-visible {
    outline: 2px solid var(--aichat-brand);
    outline-offset: -1px;
}

.aichat__handoff-send {
    border: 0;
    border-radius: 8px;
    background: var(--aichat-brand);
    color: #fff;
    font-weight: 700;
    padding: 0 12px;
    cursor: pointer;
}

.aichat__handoff-send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* WhatsApp handoff — WhatsApp brand green, not the site brand color, so the
   button reads as "this leaves the site and opens WhatsApp". */
.aichat__handoff--wa {
    background: transparent;
    padding: 0;
}

.aichat__handoff--wa .aichat__handoff-text {
    padding: 0 2px;
}

.aichat__wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: #25d366;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.28);
    transition:
        background 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.aichat__wa-btn:hover,
.aichat__wa-btn:focus-visible {
    background: #1ebe5b;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 211, 102, 0.34);
}

.aichat__wa-btn:focus-visible {
    outline: 2px solid #0f5132;
    outline-offset: 2px;
}

.aichat__wa-icon {
    width: 18px;
    height: 18px;
    flex: none;
}

.aichat__wa-icon path {
    fill: currentColor;
}

/* Near-fullscreen on small screens */
@media (max-width: 600px) {
    /* Full-screen, and WhatsApp's dark palette. Because the colours live in
       custom properties, the whole theme swaps by redefining them here rather
       than by restating every rule. */
    .aichat {
        right: 0;
        bottom: 0;
        --wa-header: #202c33;
        --wa-paper: #0b141a;
        --wa-in: #202c33;
        --wa-out: #005c4b;
        --wa-text: #e9edef;
        --wa-meta: #8696a0;
        --wa-bar: #202c33;
    }

    .aichat__toggle {
        position: fixed;
        right: 16px;
        bottom: 16px;
        width: 60px;
        height: 60px;
    }

    .aichat__panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh; /* account for mobile browser chrome where supported */
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    .aichat__header {
        min-height: 36px;
    }

    .aichat__log {
        gap: 10px;
        padding: 14px;
    }

    .aichat__msg {
        font-size: 15px;
    }

    /* Outgoing bubbles are dark green here, so their meta needs lifting. */
    .aichat__msg--user .aichat__meta {
        color: rgba(233, 237, 239, 0.6);
    }

    .aichat__msg a {
        color: #53bdeb;
    }

    .aichat__event-card {
        width: min(100%, 280px);
        background: #111b21;
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow: none;
    }

    .aichat__event-title {
        color: var(--wa-text);
    }

    .aichat__event-meta {
        color: var(--wa-meta);
    }

    .aichat__card-action {
        background: var(--wa-accent);
        border-color: var(--wa-accent) !important;
        color: #fff !important;
    }

    .aichat__typing span {
        background: var(--wa-meta);
    }

    .aichat__chips,
    .aichat__actions {
        padding: 0 14px 12px;
    }

    .aichat__chip,
    .aichat__action {
        color: #6fe0c4;
    }

    .aichat__form {
        padding: 10px;
    }

    .aichat__inputwrap {
        background: #2a3942;
    }

    .aichat__input {
        color: var(--wa-text);
    }

    .aichat__input::placeholder {
        color: var(--wa-meta);
    }

    .aichat__footer {
        color: var(--wa-meta);
        background: var(--wa-bar);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .aichat__footer a {
        color: var(--wa-text);
    }

    .aichat__handoff-text {
        color: var(--wa-text);
    }

    /* The WhatsApp button is its own card — no surface behind it. */
    .aichat__handoff--wa {
        background: transparent;
        box-shadow: none;
    }

    .aichat__handoff-input {
        border-color: rgba(255, 255, 255, 0.14);
        background: #2a3942;
        color: var(--wa-text);
    }

    .aichat__handoff-send {
        border-radius: 999px;
        background: var(--wa-accent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .aichat__toggle,
    .aichat__wa-btn,
    .aichat__typing span {
        transition: none;
        animation: none;
    }

    .aichat__wa-btn:hover,
    .aichat__wa-btn:focus-visible {
        transform: none;
    }
}
