/* 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: 20px;
    z-index: 99999;
    font-family: "Oswald", sans-serif;
    --aichat-brand: #2b3a42;
}

/* Force one font for every bit of text in the widget. The explicit element
   selectors outrank theme defaults (e.g. `li { font-family: Montserrat }`),
   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: "Oswald", sans-serif;
}

.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 */
.aichat__toggle {
    width: 56px;
    height: 56px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background:
        radial-gradient(
            circle at 32% 22%,
            rgba(255, 255, 255, 0.28),
            transparent 34%
        ),
        var(--aichat-brand);
    background-position:
        32% 22%,
        center;
    background-size:
        100% 100%,
        100% 100%;
    color: #fff;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
    transition:
        background-position 0.28s ease,
        background-size 0.28s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.aichat__toggle:hover {
    background-position:
        18% 12%,
        center;
    background-size:
        145% 145%,
        100% 100%;
    border-color: currentColor;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.38);
}

.aichat__toggle-icon {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    transform: translateX(-5px);
}

.aichat__toggle-icon svg {
    width: 35px;
    height: 35px;
    overflow: visible;
}

.aichat__toggle-icon path {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.9;
}

.aichat__toggle-icon path:first-child {
    fill: rgba(255, 255, 255, 0.12);
}

.aichat__toggle:focus-visible {
    outline: 3px solid rgba(0, 0, 0, 0.45);
    outline-offset: 2px;
}

.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: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.aichat__panel[hidden] {
    display: none;
}

.aichat__header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* close button stays on the right */
    padding: 6px 16px;
    background: var(--aichat-brand);
    color: #fff;
    font-weight: 700;
}

/* Centered across the full header width, regardless of the close button */
.aichat__title {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* never block the close button */
}

.aichat__close {
    border: 0;
    background: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    outline: none;
}

.aichat__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* 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;
}

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

.aichat__msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.aichat__msg--user {
    align-self: flex-end;
    background: var(--aichat-brand);
    color: #fff;
}

.aichat__msg--bot {
    align-self: flex-start;
    background: #f0f0f0;
    color: #222;
}

.aichat__msg--notice {
    align-self: flex-start;
    max-width: 88%;
    background: #fafafa;
    border: 1px solid #e6e6e6;
    color: #525b5f;
    font-size: 12px;
}

.aichat__msg--notice p {
    color: inherit;
    font-size: inherit;
    line-height: 1.35;
}

.aichat__msg--bot p {
    color: var(--aichat-brand);
    font-size: 1rem;
    line-height: 1.2rem;
}
/* Rendered markdown inside bot messages */
.aichat__msg p {
    margin: 0 0 0.5em;
}

.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;
    gap: 4px;
    align-items: center;
}

.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;
}

.aichat__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
}

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

.aichat__chip,
.aichat__action {
    border: 1px solid var(--aichat-brand);
    border-radius: 999px;
    background: #fff;
    color: var(--aichat-brand);
    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(--aichat-brand);
    color: #fff;
}

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

/* Input row */
.aichat__form {
    display: flex;
    border-top: 1px solid #eee;
}

.aichat__input {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 1rem;
    border: 0;
    font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
    outline: none;
    margin: 0rem;
    color: #525b5f;
}

.aichat__input:disabled {
    background: #f7f7f7;
}

.aichat__send {
    padding: 0 16px;
    border: 0;
    background: var(--aichat-brand);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.aichat__send:focus-visible {
    outline: 2px solid #000;
    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 (inline email capture) */
.aichat__handoff {
    align-self: flex-start;
    max-width: 90%;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f0f0f0;
}

.aichat__handoff-text {
    margin: 0 0 8px;
    font-size: 13px;
    color: #333;
}

.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;
}

/* Near-fullscreen on small screens */
@media (max-width: 600px) {
    .aichat {
        right: 0;
        bottom: 0;
        --aichat-mobile-bg: #08090b;
        --aichat-mobile-surface: #111419;
        --aichat-mobile-surface-2: #191d24;
        --aichat-mobile-border: rgba(255, 255, 255, 0.1);
        --aichat-mobile-text: #f4f6f8;
        --aichat-mobile-muted: #a8b0bb;
    }

    .aichat__toggle {
        position: fixed;
        right: 16px;
        bottom: 16px;
        width: 60px;
        height: 60px;
        background:
            radial-gradient(
                circle at 30% 22%,
                rgba(255, 255, 255, 0.32),
                transparent 35%
            ),
            linear-gradient(135deg, var(--aichat-brand), #111419 78%);
        background-position:
            30% 22%,
            center;
        background-size:
            100% 100%,
            100% 100%;
        box-shadow:
            0 18px 45px rgba(0, 0, 0, 0.45),
            0 0 0 1px rgba(255, 255, 255, 0.12);
    }

    .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;
        background: var(--aichat-mobile-bg);
        color: var(--aichat-mobile-text);
        box-shadow: none;
    }

    .aichat__header {
        min-height: 56px;
        padding: 10px 16px;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent),
            var(--aichat-mobile-surface);
        border-bottom: 1px solid var(--aichat-mobile-border);
    }

    .aichat__title {
        color: var(--aichat-mobile-text);
        letter-spacing: 0.02em;
    }

    .aichat__close {
        width: 40px;
        height: 40px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.07);
        color: var(--aichat-mobile-text);
    }

    .aichat__log {
        gap: 10px;
        padding: 14px;
        background:
            radial-gradient(
                circle at top right,
                rgba(255, 255, 255, 0.06),
                transparent 28%
            ),
            var(--aichat-mobile-bg);
    }

    .aichat__msg {
        border: 1px solid var(--aichat-mobile-border);
        font-size: 15px;
    }

    .aichat__msg--user {
        background: var(--aichat-brand);
        border-color: rgba(255, 255, 255, 0.16);
        color: #fff;
    }

    .aichat__msg--bot {
        background: var(--aichat-mobile-surface-2);
        color: var(--aichat-mobile-text);
    }

    .aichat__msg--notice {
        background: var(--aichat-mobile-surface);
        border-color: var(--aichat-mobile-border);
        color: var(--aichat-mobile-muted);
    }

    .aichat__msg--bot p {
        color: var(--aichat-mobile-text);
    }

    .aichat__msg--notice p {
        color: inherit;
    }

    .aichat__msg a {
        color: #fff;
    }

    .aichat__event-card {
        width: min(100%, 280px);
        background: var(--aichat-mobile-surface);
        border-color: var(--aichat-mobile-border);
        box-shadow: none;
    }

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

    .aichat__event-meta {
        color: var(--aichat-mobile-muted);
    }

    .aichat__card-action {
        background: var(--aichat-brand);
        color: #fff !important;
    }

    .aichat__typing span {
        background: var(--aichat-mobile-muted);
    }

    .aichat__chips,
    .aichat__actions {
        padding: 0 14px 12px;
        background: var(--aichat-mobile-bg);
    }

    .aichat__chip,
    .aichat__action {
        background: var(--aichat-mobile-surface);
        border-color: var(--aichat-mobile-border);
        color: var(--aichat-mobile-text);
    }

    .aichat__chip:hover,
    .aichat__action:hover {
        background: var(--aichat-brand);
        border-color: var(--aichat-brand);
    }

    .aichat__form {
        gap: 8px;
        padding: 10px;
        background: var(--aichat-mobile-surface);
        border-top: 1px solid var(--aichat-mobile-border);
    }

    .aichat__input {
        border-radius: 999px;
        background: var(--aichat-mobile-bg);
        color: var(--aichat-mobile-text);
    }

    .aichat__input::placeholder {
        color: var(--aichat-mobile-muted);
    }

    .aichat__input:disabled {
        background: #0d0f13;
    }

    .aichat__send,
    .aichat__handoff-send {
        border-radius: 999px;
        background: var(--aichat-brand);
    }

    .aichat__footer {
        color: var(--aichat-mobile-muted);
        background: var(--aichat-mobile-surface);
        border-top: 1px solid var(--aichat-mobile-border);
    }

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

    .aichat__handoff {
        background: var(--aichat-mobile-surface-2);
        border: 1px solid var(--aichat-mobile-border);
    }

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

    .aichat__handoff-input {
        border-color: var(--aichat-mobile-border);
        background: var(--aichat-mobile-bg);
        color: var(--aichat-mobile-text);
    }
}

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