/* AI Chat widget — scoped under #ai-chat to avoid leaks into site styles.
   Bubble sits left of the WhatsApp bubble (.whatsapp at right:20px, height 62px). */

#ai-chat,
#ai-chat * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- Toggle bubble ---
   Sits LEFT of the existing WhatsApp pill (right:20px, ~170px wide with "Book Now" text).
   Gap math: 20px + 170px + 14px gap = 204px. Use 210px for safety.
   Same height/shape as the WhatsApp pill so the two visually pair. --}*/
#ai-chat-toggle {
    position: fixed;
    bottom: 4%;
    right: 210px;
    z-index: 99; /* one below WhatsApp's 100 so a tooltip never covers WhatsApp */
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px; /* matches WhatsApp's inline height: 48px */
    padding: 4px 20px 4px 6px;
    border: none;
    border-radius: 999px;
    background: #0a4b78;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s, box-shadow 0.15s;
}
#ai-chat-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(10, 75, 120, 0.32);
}
#ai-chat-toggle:focus-visible {
    outline: 3px solid #ffd54f;
    outline-offset: 2px;
}
.ai-chat-toggle-label {
    white-space: nowrap;
    font-size: 16px;
}

/* Bot image — larger, no white background, blends with the pill */
.ai-chat-toggle-bot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}
/* SVG fallback only shows if AVIF fails (set inline by onerror) */
.ai-chat-toggle-fallback {
    display: none;
    width: 26px;
    height: 26px;
    margin-left: 8px;
}

/* Tablet / small desktop: keep gap above WhatsApp */
@media (max-width: 991px) {
    #ai-chat-toggle {
        right: 210px;
    }
}

/* Mobile: stack ABOVE the WhatsApp bubble (avoids horizontal squash) */
@media (max-width: 575px) {
    #ai-chat-toggle {
        right: 20px;
        bottom: calc(4% + 60px);
        padding: 4px 16px 4px 6px;
        height: 44px;
    }
    .ai-chat-toggle-bot { width: 36px; height: 36px; }
    .ai-chat-toggle-label { font-size: 14px; }
}

/* --- Drawer --- */
#ai-chat-drawer {
    position: fixed;
    right: 20px;
    bottom: calc(4% + 80px);
    z-index: 101;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    animation: aiChatSlideIn 0.18s ease-out;
}

@keyframes aiChatSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 575px) {
    #ai-chat-drawer {
        right: 8px;
        left: 8px;
        bottom: calc(4% + 80px);
        width: auto;
        max-width: none;
        height: 75vh;
    }
}

/* --- Header --- */
.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #0a4b78;
    color: #fff;
}
.ai-chat-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}
.ai-chat-subtitle {
    margin: 4px 0 0;
    font-size: 0.78rem;
    opacity: 0.9;
    line-height: 1.3;
}
.ai-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    line-height: 0;
}
.ai-chat-close:hover { background: rgba(255, 255, 255, 0.15); }

/* --- Message log --- */
.ai-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ai-chat-msg {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: #111;
}
.ai-chat-msg p { margin: 0 0 6px; }
.ai-chat-msg p:last-child { margin-bottom: 0; }
.ai-chat-msg a {
    color: #0a4b78;
    text-decoration: underline;
}
.ai-chat-msg-user {
    align-self: flex-end;
    background: #0a4b78;
    color: #fff;
    border-bottom-right-radius: 3px;
}
.ai-chat-msg-user a { color: #ffd54f; }
.ai-chat-msg-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 3px;
}
.ai-chat-msg-bot .ai-chat-sources {
    margin-top: 6px;
    font-size: 0.78rem;
    color: #475569;
}
.ai-chat-msg-bot .ai-chat-sources a {
    color: #475569;
    margin-right: 8px;
}

.ai-chat-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}
.ai-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: aiChatTyping 1.2s infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiChatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* --- Form --- */
.ai-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
#ai-chat-input {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    color: #111;
    background: #fff;
}
#ai-chat-input:focus { border-color: #0a4b78; }

.ai-chat-mic,
#ai-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: #f1f5f9;
    color: #0a4b78;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    flex-shrink: 0;
}
.ai-chat-mic:hover,
#ai-chat-send:hover { background: #e2e8f0; }
#ai-chat-send { background: #0a4b78; color: #fff; }
#ai-chat-send:hover { background: #0d5a91; }
#ai-chat-send:disabled { opacity: 0.5; cursor: wait; }

.ai-chat-mic.is-recording {
    background: #dc2626;
    color: #fff;
    animation: aiChatPulse 1.1s infinite;
}
@keyframes aiChatPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Error chip */
.ai-chat-error {
    align-self: stretch;
    padding: 8px 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 0.85rem;
}
