/**
 * TGM ChatBot — Widget Styles v1.2.0 (Phase 1.6: Granular Visual Controls)
 *
 * All colours, sizes, and fonts use CSS custom properties injected by PHP
 * in <style id="tgm-chatbot-vars"> on the .jc-launcher / .jc-window scope.
 * All classes prefixed with jc- to prevent theme conflicts.
 */

/* ── Reset & Base ──────────────────────────── */
.jc-launcher,
.jc-window,
.jc-window * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--tgm-font-body, sans-serif);
    font-weight: var(--tgm-font-body-weight, 400);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ══════════════════════════════════════════════
   LAUNCHER — shared base
   ══════════════════════════════════════════════ */
.jc-launcher {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    border: none;
    background: var(--tgm-launcher-bg, #3498db);
    color: var(--tgm-launcher-icon, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--tgm-launcher-shadow, rgba(0,0,0,0.18));
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.25s ease;
}
.jc-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px var(--tgm-launcher-shadow, rgba(0,0,0,0.22));
}
.jc-launcher:active {
    transform: scale(0.95);
}
.jc-launcher:focus-visible {
    outline: 3px solid var(--tgm-header-bg, #2c3e50);
    outline-offset: 3px;
}
.jc-pos-right { right: 24px; }
.jc-pos-left  { left: 24px; }

/* ── Launcher shape: ROUND (icon only) ── */
.jc-launcher--round {
    width: var(--tgm-launcher-size, 60px);
    height: var(--tgm-launcher-size, 60px);
    border-radius: 50%;
}

/* ── Launcher shape: PILL (text, or text + icon) ── */
.jc-launcher--pill {
    height: var(--tgm-launcher-size, 52px);
    min-width: var(--tgm-launcher-size, 52px);
    padding: 0 22px;
    border-radius: calc(var(--tgm-launcher-size, 52px) / 2);
    gap: 10px;
}
.jc-launcher--pill.jc-icon-right {
    flex-direction: row-reverse;
}

/* ── Launcher text (pill only) ── */
.jc-launcher-text {
    color: var(--tgm-launcher-text, #fff);
    font-size: var(--tgm-launcher-text-size, 15px);
    font-weight: var(--tgm-launcher-text-weight, 600);
    white-space: nowrap;
    line-height: 1;
    transition: opacity 0.2s ease, max-width 0.3s ease;
}

/* When the chat window opens, the launcher collapses back to a round X button.
   Text hides, and pill shrinks back to the round footprint. */
.jc-launcher.jc-open.jc-launcher--pill {
    width: var(--tgm-launcher-size, 60px);
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    gap: 0;
}
.jc-launcher.jc-open .jc-launcher-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

/* ── Launcher icons ── */
.jc-launcher-icon {
    transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
                opacity 0.25s ease;
    flex-shrink: 0;
}
/* SVG icons (the default close X, and any SVG chat icon) use absolute overlay */
svg.jc-launcher-icon {
    position: absolute;
    pointer-events: none;
}
/* Emoji and image icons are inline (not absolute) so the pill layout flows */
.jc-icon-emoji {
    font-size: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jc-icon-image {
    /* Admin-tunable via "Launcher → Avatar Size". Can exceed the launcher
     * button size to intentionally pop out above/below the pill. The
     * launcher has no overflow:hidden so this renders cleanly. */
    width: var( --tgm-launcher-avatar-size, 32px );
    height: var( --tgm-launcher-avatar-size, 32px );
    object-fit: contain;
    background: transparent;
    padding: 0;
    display: block;
    flex-shrink: 0;
}
/* Make sure nothing above the launcher button clips a pop-out avatar. */
.jc-launcher {
    overflow: visible;
}

/* Round launcher: SVG chat icon stays absolute-centered */
.jc-launcher--round svg.jc-icon-chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Close SVG: hidden by default, shown when .jc-open */
.jc-icon-close {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

/* When chat is open: swap to close icon, hide chat icon */
.jc-launcher.jc-open .jc-icon-chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}
.jc-launcher.jc-open .jc-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    position: absolute;
}

/* Ping / pulse animation — stops via .jc-pinged class */
.jc-launcher-ping {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--tgm-launcher-bg, #3498db);
    opacity: 0;
    pointer-events: none;
    animation: jc-ping 2s cubic-bezier(0,0,0.2,1) infinite;
}
.jc-launcher.jc-pinged .jc-launcher-ping {
    animation: none;
    display: none;
}
@keyframes jc-ping {
    0%   { transform: scale(1); opacity: 0.45; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* ══════════════════════════════════════════════
   CHAT WINDOW
   ══════════════════════════════════════════════ */
.jc-window {
    position: fixed;
    bottom: 100px;
    z-index: 999998;
    width: 420px;
    max-height: calc(100vh - 120px);
    background: var(--tgm-window-bg, #f9f9f9);
    border: 1px solid var(--tgm-window-border, #e0e0e0);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15),
                0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Spring animation */
    transform-origin: bottom right;
    opacity: 0;
    transform: scale(0.6) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1),
                opacity 0.25s ease;
    pointer-events: none;
    visibility: hidden;
}
.jc-window.jc-pos-right { right: 24px; }
.jc-window.jc-pos-left  { left: 24px; transform-origin: bottom left; }

/* Open state */
.jc-window.jc-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
    visibility: visible;
}

/* ══════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════ */
.jc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--tgm-header-bg, #2c3e50);
    color: var(--tgm-header-title, #fff);
    flex-shrink: 0;
    font-family: var(--tgm-font-header, var(--tgm-font-body, sans-serif));
}
.jc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.jc-header-avatar {
    /* Admin-tunable via "Theme → Header Avatar → Avatar Size". Container
     * is centered inside the header via flex, no padding so the image
     * can fill it edge to edge. When `avatar_bg_transparent` is on,
     * --tgm-avatar-bg resolves to `transparent`. */
    width: var( --tgm-header-avatar-size, 38px );
    height: var( --tgm-header-avatar-size, 38px );
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc( var( --tgm-header-avatar-size, 38px ) * 0.63 );
    background: var( --tgm-avatar-bg, rgba(255,255,255,0.15) );
    border-radius: 50%;
    flex-shrink: 0;
    padding: 0;
    overflow: visible;
}
.jc-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: transparent;
    padding: 0;
    display: block;
}
/* When the background is transparent, drop the circular clipping so SVG
 * avatars can show their natural silhouette instead of being cropped to
 * a circle (which looks odd on most character SVGs). Applied via a
 * conditional class on the container; see TGM_Widget::render(). */
.jc-header-avatar.is-transparent {
    border-radius: 0;
}
.jc-header-avatar.is-transparent .jc-avatar-img {
    border-radius: 0;
    object-fit: contain;
}
.jc-header-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.jc-header-name {
    font-weight: var(--tgm-font-header-weight, 700);
    font-size: var(--tgm-size-header, 18px);
    color: var(--tgm-header-title, #fff);
    font-family: var(--tgm-font-header, var(--tgm-font-body, sans-serif));
}
.jc-header-status {
    font-size: 13px;
    color: var(--tgm-header-subtitle, #bdc3c7);
    display: flex;
    align-items: center;
    gap: 5px;
}
.jc-status-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
    animation: jc-pulse 1.5s ease-in-out infinite;
}
@keyframes jc-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.85); }
}
.jc-close {
    background: none;
    border: none;
    color: var(--tgm-header-close, #fff);
    font-size: 26px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    opacity: 0.75;
    border-radius: 6px;
    transition: opacity 0.15s, background 0.15s;
}
.jc-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}

/* ══════════════════════════════════════════════
   MESSAGES AREA
   ══════════════════════════════════════════════ */
.jc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 140px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.jc-messages::-webkit-scrollbar {
    width: 5px;
}
.jc-messages::-webkit-scrollbar-track {
    background: transparent;
}
.jc-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}
.jc-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

/* ── Message Bubbles ──────────────────────── */
.jc-msg {
    max-width: 85%;
    padding: 11px 16px;
    border-radius: 16px;
    font-size: var(--tgm-size-message, 15px);
    line-height: 1.55;
    word-wrap: break-word;
    animation: jc-msg-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes jc-msg-in {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.jc-msg-bot {
    align-self: flex-start;
    background: var(--tgm-bot-bg, #ecf0f1);
    color: var(--tgm-bot-text, #333);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.jc-msg-bot a {
    color: var(--tgm-bot-link, #3498db);
    text-decoration: underline;
}
.jc-msg-user {
    align-self: flex-end;
    background: var(--tgm-user-bg, #d5f5e3);
    color: var(--tgm-user-text, #333);
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ── Images inside bot messages (Phase 1.6 data layer) ── */
.jc-msg img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 6px 0;
    display: block;
}

/* ── Typing Indicator ─────────────────────── */
.jc-typing {
    display: inline-flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--tgm-bot-bg, #ecf0f1);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    animation: jc-msg-in 0.3s ease both;
}
.jc-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--tgm-ai-typing, #aaa);
    border-radius: 50%;
    animation: jc-bounce 1.4s ease-in-out infinite;
}
.jc-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.jc-typing-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes jc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-8px); opacity: 1; }
}

/* ══════════════════════════════════════════════
   REPLIES AREA (Q&A buttons)
   ══════════════════════════════════════════════ */
.jc-replies {
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    animation: jc-replies-in 0.3s ease both;
}
@keyframes jc-replies-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stacked layout (default) */
.jc-replies .jc-reply-btn {
    display: block;
    width: 100%;
    padding: 13px 18px;
    border: 2px solid var(--tgm-qa-border, #3498db);
    border-radius: 12px;
    background: var(--tgm-qa-bg, #fff);
    color: var(--tgm-qa-text, #2c3e50);
    font-size: var(--tgm-size-qa-btn, 15px);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: var(--tgm-font-body, sans-serif);
    transition: background 0.2s ease,
                color 0.2s ease,
                transform 0.15s ease,
                box-shadow 0.2s ease;
}
.jc-replies .jc-reply-btn:hover {
    background: var(--tgm-qa-hover-bg, #3498db);
    color: var(--tgm-qa-hover-text, #fff);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
.jc-replies .jc-reply-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Pill grid layout */
.jc-replies.jc-pill-grid {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
}
.jc-pill-grid .jc-reply-btn {
    width: auto;
    flex: 0 0 auto;
    padding: 8px 18px;
    border-radius: 22px;
    font-size: 13px;
}

/* Action row — Contact + Get Updates side by side */
.jc-action-row {
    display: flex;
    gap: 8px;
    width: 100%;
}
.jc-action-row .jc-reply-action {
    flex: 1;
    min-width: 0;
}

/* Action buttons — use CTA colours to stand apart from Q&A buttons */
.jc-replies .jc-reply-action {
    background: var(--tgm-cta-bg, #e67e22);
    color: var(--tgm-cta-text, #fff);
    border-color: var(--tgm-cta-bg, #e67e22);
    font-size: var(--tgm-size-cta-btn, 14px);
}
.jc-replies .jc-reply-action:hover {
    background: var(--tgm-cta-hover-bg, #d35400);
    color: var(--tgm-cta-hover-text, #fff);
    border-color: var(--tgm-cta-hover-bg, #d35400);
}

/* Back to Main Menu — visually muted */
.jc-replies .jc-reply-back {
    border-style: dashed;
    border-color: #aaa;
    color: #888;
    opacity: 0.7;
    font-weight: 400;
    font-size: 13px;
    margin-top: 4px;
}
.jc-replies .jc-reply-back:hover {
    opacity: 1;
    border-color: var(--tgm-qa-border, #3498db);
    color: var(--tgm-qa-text, #2c3e50);
    background: var(--tgm-qa-bg, #fff);
}

/* ══════════════════════════════════════════════
   CTA BUTTONS (inside contact card)
   ══════════════════════════════════════════════ */
.jc-cta-card .jc-cta-btn {
    background: var(--tgm-cta-bg, #e67e22);
    color: var(--tgm-cta-text, #fff);
    border: none;
    transition: background 0.2s ease, color 0.2s ease;
}
.jc-cta-card .jc-cta-btn:hover {
    background: var(--tgm-cta-hover-bg, #d35400);
    color: var(--tgm-cta-hover-text, #fff);
}

/* ══════════════════════════════════════════════
   INLINE CTA (appended after AI responses)
   ══════════════════════════════════════════════ */
.jc-inline-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 4px;
    animation: jcFadeIn 0.3s ease;
}
.jc-inline-cta .jc-cta-contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: var(--tgm-cta-bg, #e67e22);
    color: var(--tgm-cta-text, #fff);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--tgm-font-body, sans-serif);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.jc-inline-cta .jc-cta-contact-btn:hover {
    background: var(--tgm-cta-hover-bg, #d35400);
    color: var(--tgm-cta-hover-text, #fff);
    transform: translateY(-1px);
}
.jc-inline-cta .jc-cta-contact-btn svg {
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   INLINE CONTACT FORM (in chat messages area)
   ══════════════════════════════════════════════ */
.jc-contact-form {
    padding: 10px 12px;
    animation: jcFadeIn 0.3s ease;
}
.jc-contact-field {
    margin-bottom: 8px;
}
.jc-contact-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--tgm-input-border, rgba(0,0,0,0.15));
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--tgm-font-body, sans-serif);
    background: var(--tgm-input-bg, #fff);
    color: var(--tgm-input-text, #333);
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.jc-contact-input:focus {
    border-color: var(--tgm-qa-border, #3498db);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}
.jc-contact-input::placeholder {
    color: var(--tgm-input-placeholder, #aaa);
}
.jc-contact-textarea {
    resize: vertical;
    min-height: 60px;
}
.jc-contact-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.jc-contact-submit {
    flex: 1;
}
.jc-contact-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.jc-contact-cancel {
    background: none;
    border: none;
    color: var(--tgm-input-placeholder, #999);
    font-size: 13px;
    cursor: pointer;
    padding: 8px 12px;
    font-family: var(--tgm-font-body, sans-serif);
    transition: color 0.15s;
}
.jc-contact-cancel:hover {
    color: var(--tgm-input-text, #333);
}
.jc-contact-status {
    font-size: 12px;
    min-height: 16px;
    padding: 4px 2px 0;
    font-family: var(--tgm-font-body, sans-serif);
}

/* ══════════════════════════════════════════════
   FREE-TEXT INPUT BAR
   ══════════════════════════════════════════════ */
.jc-input-bar {
    display: flex;
    border-top: 1px solid var(--tgm-window-border, #e8e8e8);
    padding: 10px 14px;
    gap: 8px;
    background: var(--tgm-input-bg, #fff);
    flex-shrink: 0;
    border-radius: 0 0 16px 16px;
}
.jc-input {
    flex: 1;
    border: 1.5px solid var(--tgm-input-border, #ddd);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 14px;
    color: var(--tgm-input-text, #2c3e50);
    background: var(--tgm-input-bg, #fff);
    font-family: var(--tgm-font-body, sans-serif);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.jc-input:focus {
    border-color: var(--tgm-qa-border, #3498db);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.jc-input::placeholder {
    color: var(--tgm-input-placeholder, #aaa);
}
.jc-send {
    background: var(--tgm-header-bg, #2c3e50);
    border: none;
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--tgm-header-title, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: transform 0.15s ease, opacity 0.15s;
}
.jc-send:hover {
    opacity: 0.85;
    transform: scale(1.05);
}
.jc-send:active {
    transform: scale(0.95);
}

/* ══════════════════════════════════════════════
   AI DISCLOSURE BADGE
   ══════════════════════════════════════════════ */
.jc-ai-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.4;
    border-radius: 8px;
    background: var(--tgm-ai-badge-bg, #f0f8ff);
    color: var(--tgm-ai-badge-text, #666);
    font-family: var(--tgm-font-body, sans-serif);
}

/* ══════════════════════════════════════════════
   PRIVACY NOTICE BANNER
   ══════════════════════════════════════════════ */
.jc-privacy-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    margin: 0 0 4px;
    background: #f0f4f8;
    border-bottom: 1px solid #dde3ea;
    font-size: 11px;
    line-height: 1.4;
    color: #5a6a7a;
    font-family: var(--tgm-font-body, sans-serif);
}
.jc-privacy-text {
    flex: 1;
}
.jc-privacy-text a {
    color: var(--tgm-header-bg, #2c3e50);
    text-decoration: underline;
}
.jc-privacy-dismiss {
    background: none;
    border: none;
    font-size: 14px;
    line-height: 1;
    color: #8a9aaa;
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
}
.jc-privacy-dismiss:hover {
    color: #4a5a6a;
}

/* ══════════════════════════════════════════════
   AI DISCLAIMER FOOTER
   ══════════════════════════════════════════════ */
.jc-ai-disclaimer {
    margin: 6px 0 0;
    padding-top: 5px;
    border-top: 1px solid rgba(0,0,0,0.06);
    font-size: 11px;
    font-style: italic;
    opacity: 0.7;
    line-height: 1.3;
}

/* ══════════════════════════════════════════════
   POWERED-BY FOOTER
   ══════════════════════════════════════════════ */
.jc-powered-by {
    text-align: center;
    font-size: 10px;
    color: #aab;
    padding: 4px 8px 6px;
    background: var(--tgm-window-bg, #f7f7f7);
    border-top: 1px solid var(--tgm-window-border, #e8e8e8);
    border-radius: 0 0 16px 16px;
    font-family: var(--tgm-font-body, sans-serif);
    letter-spacing: 0.3px;
}
/* When powered-by is present, input bar loses its bottom radius */
.jc-input-bar:has(+ .jc-powered-by),
.jc-window:has(.jc-powered-by) .jc-input-bar {
    border-radius: 0;
}

/* ══════════════════════════════════════════════
   LAUNCHER ANIMATIONS
   ══════════════════════════════════════════════ */

/* Bounce — gentle hop every few seconds */
.jc-launcher.jc-anim-bounce:not(.jc-open) {
    animation: jc-anim-bounce 2s ease-in-out infinite;
}
@keyframes jc-anim-bounce {
    0%, 100% { transform: translateY(0); }
    20%      { transform: translateY(-10px); }
    40%      { transform: translateY(-4px); }
    60%      { transform: translateY(-7px); }
    80%      { transform: translateY(0); }
}

/* Pulse — rhythmic scale throb */
.jc-launcher.jc-anim-pulse:not(.jc-open) {
    animation: jc-anim-pulse 2.5s ease-in-out infinite;
}
@keyframes jc-anim-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

/* Wiggle — playful rotation wobble */
.jc-launcher.jc-anim-wiggle:not(.jc-open) {
    animation: jc-anim-wiggle 2.4s ease-in-out infinite;
}
@keyframes jc-anim-wiggle {
    0%, 100% { transform: rotate(0deg); }
    15%      { transform: rotate(-6deg); }
    30%      { transform: rotate(5deg); }
    45%      { transform: rotate(-4deg); }
    60%      { transform: rotate(2deg); }
    75%      { transform: rotate(0deg); }
}

/* Float — dreamy up-and-down drift */
.jc-launcher.jc-anim-float:not(.jc-open) {
    animation: jc-anim-float 3s ease-in-out infinite;
}
@keyframes jc-anim-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* When chat is open, pause all launcher animations */
.jc-launcher.jc-open {
    animation: none !important;
}

/* Preserve hover/active effects on animated launchers */
.jc-launcher.jc-anim-bounce:not(.jc-open):hover,
.jc-launcher.jc-anim-pulse:not(.jc-open):hover,
.jc-launcher.jc-anim-wiggle:not(.jc-open):hover,
.jc-launcher.jc-anim-float:not(.jc-open):hover {
    animation-play-state: paused;
    transform: scale(1.05);
}
.jc-launcher.jc-anim-bounce:not(.jc-open):active,
.jc-launcher.jc-anim-pulse:not(.jc-open):active,
.jc-launcher.jc-anim-wiggle:not(.jc-open):active,
.jc-launcher.jc-anim-float:not(.jc-open):active {
    animation-play-state: paused;
    transform: scale(0.95);
}

/* Persona avatar on launcher — inherits admin-configurable avatar size
 * from --tgm-launcher-avatar-size, just like the regular image path.
 * border-radius kept so circular persona headshots still crop cleanly;
 * the user can override visually by picking a library SVG + transparent
 * background. */
.jc-icon-persona.jc-icon-emoji {
    font-size: calc( var( --tgm-launcher-avatar-size, 32px ) * 1.0 );
    line-height: 1;
}
.jc-icon-persona.jc-icon-image {
    width: var( --tgm-launcher-avatar-size, 32px );
    height: var( --tgm-launcher-avatar-size, 32px );
    border-radius: 50%;
    object-fit: cover;
}

/* ══════════════════════════════════════════════
   SPEECH BUBBLE TEASER
   ══════════════════════════════════════════════ */
.jc-teaser {
    position: fixed;
    bottom: 92px;  /* sits above the launcher */
    z-index: 999998;
    max-width: 280px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    padding: 12px 36px 12px 14px;
    cursor: pointer;
    /* Animate in */
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
    visibility: hidden;
}
.jc-teaser.jc-pos-right {
    right: 24px;
}
.jc-teaser.jc-pos-left {
    left: 24px;
}

/* Visible state */
.jc-teaser.jc-teaser-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    visibility: visible;
}

/* Triangle pointer arrow — points down toward the launcher */
.jc-teaser::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 16px;
    height: 16px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.06);
    border-radius: 0 0 3px 0;
}
.jc-teaser.jc-pos-right::after {
    right: 26px;
}
.jc-teaser.jc-pos-left::after {
    left: 26px;
}

/* Notch follows the AVATAR position within the launcher, not just the
 * launcher's side of the screen. When the icon sits to the LEFT of the
 * launcher text, the avatar is on the left end of the pill, so the
 * teaser should point down-left. When the icon is on the RIGHT of the
 * text, the avatar is on the right end, so point down-right. These
 * selectors come after the pos-right / pos-left rules above and
 * deliberately override them via auto + explicit side. */
.jc-teaser.jc-icon-left::after {
    left: 26px;
    right: auto;
}
.jc-teaser.jc-icon-right::after {
    right: 26px;
    left: auto;
}

/* Teaser content layout */
.jc-teaser-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.jc-teaser-avatar {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}
.jc-teaser-text {
    font-family: var(--tgm-font-body, -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: 14px;
    line-height: 1.45;
    color: #1d2327;
    word-wrap: break-word;
}

/* Close button */
.jc-teaser-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    font-size: 18px;
    color: #aaa;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}
.jc-teaser-close:hover {
    color: #666;
    background: rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 420px) {
    .jc-window {
        width: calc(100vw - 16px);
        right: 8px !important;
        left: 8px !important;
        bottom: 90px;
        max-height: calc(100vh - 100px);
        border-radius: 14px;
    }
    .jc-launcher {
        bottom: 16px;
    }
    /* Cap launcher at 56px on mobile regardless of desktop setting */
    .jc-launcher--round {
        width: min(var(--tgm-launcher-size, 60px), 56px);
        height: min(var(--tgm-launcher-size, 60px), 56px);
    }
    /* Pill launcher: cap height + tighten padding */
    .jc-launcher--pill {
        height: min(var(--tgm-launcher-size, 52px), 48px);
        min-width: min(var(--tgm-launcher-size, 52px), 48px);
        padding: 0 14px;
        gap: 6px;
        border-radius: calc(min(var(--tgm-launcher-size, 52px), 48px) / 2);
    }
    .jc-launcher--pill .jc-launcher-text {
        font-size: min(var(--tgm-launcher-text-size, 15px), 14px);
    }
    /* On mobile, the launcher itself is capped (line above) but we let the
     * admin-configured --tgm-launcher-avatar-size ride through as-is. If
     * the admin wants the avatar to pop out on mobile too, that's their
     * call. Only the emoji fallback gets a sensible cap so a huge emoji
     * doesn't break a tiny pill. */
    .jc-launcher .jc-icon-emoji {
        font-size: min( calc( var( --tgm-launcher-avatar-size, 32px ) * 0.88 ), 24px );
    }
    .jc-launcher .jc-icon-persona.jc-icon-emoji {
        font-size: min( var( --tgm-launcher-avatar-size, 32px ), 26px );
    }
    .jc-pos-right.jc-launcher { right: 16px; }
    .jc-pos-left.jc-launcher  { left: 16px; }

    .jc-header { padding: 12px 14px; }
    .jc-messages { padding: 12px; }
    .jc-replies { padding: 6px 12px 12px; }

    .jc-replies .jc-reply-btn {
        padding: 12px 14px;
        font-size: 15px;
        min-height: 44px;
    }
    .jc-cta-card .jc-cta-btn {
        padding: 13px 14px;
        min-height: 44px;
    }

    /* Teaser: tighter spacing on mobile */
    .jc-teaser {
        bottom: 68px;
        max-width: calc(100vw - 80px);
        padding: 10px 30px 10px 12px;
        font-size: 13px;
    }
    .jc-teaser.jc-pos-right { right: 16px; }
    .jc-teaser.jc-pos-left  { left: 16px; }
}

/* ══════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .jc-launcher,
    .jc-launcher-icon,
    .jc-launcher-ping,
    .jc-launcher-text,
    .jc-window,
    .jc-msg,
    .jc-typing-dot,
    .jc-status-dot,
    .jc-replies,
    .jc-cta-card,
    .jc-replies .jc-reply-btn,
    .jc-cta-card .jc-cta-btn,
    .jc-teaser {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    /* Disable launcher animations entirely for motion-sensitive users */
    .jc-launcher.jc-anim-bounce,
    .jc-launcher.jc-anim-pulse,
    .jc-launcher.jc-anim-wiggle,
    .jc-launcher.jc-anim-float {
        animation: none !important;
    }
}

/* ══════════════════════════════════════════════
   EMAIL CAPTURE (Kit Integration)
   ══════════════════════════════════════════════ */
.jc-email-capture {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.jc-email-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--tgm-input-border, rgba(0, 0, 0, 0.15));
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--tgm-font-body, sans-serif);
    background: var(--tgm-input-bg, #fff);
    color: var(--tgm-input-text, #333);
    outline: none;
    transition: border-color 0.15s;
}

.jc-email-input:focus {
    border-color: var(--tgm-qa-border, #3498db);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.jc-email-input::placeholder {
    color: var(--tgm-input-placeholder, #aaa);
}

.jc-email-submit {
    background: var(--tgm-cta-bg, #e67e22) !important;
    color: var(--tgm-cta-text, #fff) !important;
    border-color: var(--tgm-cta-bg, #e67e22) !important;
    font-weight: 600;
}

.jc-email-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.jc-email-status {
    font-size: 12px;
    min-height: 16px;
    padding: 0 2px;
    font-family: var(--tgm-font-body, sans-serif);
}
