.chatbot-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    font-family: "Poppins", "Inter", sans-serif;
    --chatbot-theme: #1f4dbd;
}

.chatbot-widget.chatbot-left {
    left: 24px;
    right: auto;
}

.chatbot-widget.chatbot-right {
    right: 24px;
    left: auto;
}

.chatbot-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: visible;
    z-index: 9999;
}

.chatbot-fab-tooltip {
    position: absolute;
    top: -52px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: #ffffff;
    color: #173a8b;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(16, 30, 61, 0.18);
    border: 1px solid #dbe6fb;
    /* allow wrapping so the full message is visible on narrow screens */
    white-space: normal;
    max-width: 320px;
    overflow: visible;
    word-wrap: break-word;
    line-height: 1.1;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
    z-index: 10001;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chatbot-fab-tooltip::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-left: 1px solid #dbe6fb;
    border-bottom: 1px solid #dbe6fb;
    transform: translateX(-50%) rotate(-45deg);
}

.chatbot-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(16, 30, 61, 0.3);
}

.chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 64px;
    width: 340px;
    max-height: 520px;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(209, 223, 245, 0.7);
    box-shadow: 0 18px 40px rgba(16, 30, 61, 0.25);
    backdrop-filter: blur(18px);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chatbot-widget.chatbot-left .chatbot-panel {
    left: 0;
    right: auto;
}

.chatbot-widget.chatbot-right .chatbot-panel {
    right: 0;
    left: auto;
}

.chatbot-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chatbot-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(220, 230, 248, 0.8);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.chatbot-header-top {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-avatar {
    width: 56px;
    height: 56px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e8fb;
    padding: 6px;
}

.chatbot-avatar-fallback {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef4ff;
    color: #1f4dbd;
    border-radius: 12px;
    border: 1px solid #dbe6fb;
    font-size: 1.1rem;
}

.chatbot-title {
    font-weight: 700;
    color: #14326b;
    font-size: 0.95rem;
}

.chatbot-subtitle {
    font-size: 0.75rem;
    color: #4b5c7a;
}

.chatbot-close {
    border: none;
    background: transparent;
    font-size: 1.2rem;
    color: #6b7a99;
}

.chatbot-header-actions {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.chatbot-lang {
    border: 1px solid #d4def4;
    background: #f5f8ff;
    color: #2b3f6b;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
}

.chatbot-clear {
    border: 1px solid #d4def4;
    background: #f5f8ff;
    color: #2b3f6b;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
}

.chatbot-chip {
    border: 1px solid rgba(31, 77, 189, 0.25);
    background: rgba(31, 77, 189, 0.08);
    color: #173a8b;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 999px;
}

.chatbot-messages {
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.chatbot-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.chatbot-message.user {
    align-items: flex-end;
}

.chatbot-message.bot {
    align-items: flex-start;
}

.chatbot-message .bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.3;
}

.chatbot-message.bot .bubble {
    background: #eef4ff;
    color: #19335f;
    border: 1px solid #dbe6fb;
}

.chatbot-message.user .bubble {
    background: var(--chatbot-theme);
    color: #fff;
}

.chatbot-time {
    margin-top: 3px;
    font-size: 0.64rem;
    color: #8a98b5;
}

.chatbot-input {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(220, 230, 248, 0.8);
}

.chatbot-input input {
    flex: 1;
    border: 1px solid #d7e2f8;
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 0.82rem;
}

.chatbot-input button {
    border: none;
    background: var(--chatbot-theme);
    color: #fff;
    border-radius: 12px;
    padding: 0 14px;
}

.chatbot-typing {
    font-size: 0.75rem;
    color: #6b7a99;
    padding: 0 14px 10px;
}

.chatbot-typing span {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin-right: 2px;
    border-radius: 50%;
    background: var(--chatbot-theme);
    animation: chatbotPulse 1s infinite ease-in-out;
}

.chatbot-typing span:nth-child(2) {
    animation-delay: .15s;
}

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

@keyframes chatbotPulse {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.chatbot-contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--chatbot-theme);
    color: var(--chatbot-theme);
    text-decoration: none;
    font-size: 0.75rem;
    margin-top: 6px;
}

.chatbot-contact-btn.ghost {
    border-style: dashed;
    background: #fff;
}

.chatbot-result-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.chatbot-result-card {
    overflow: hidden;
    border: 1px solid #dbe6fb;
    border-radius: 14px;
    background: #fff;
}

.chatbot-result-card img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    display: block;
}

.chatbot-result-body {
    padding: 10px;
}

.chatbot-result-group {
    display: inline-flex;
    margin-bottom: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--chatbot-theme);
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.chatbot-result-body h4 {
    margin: 0 0 5px;
    color: #152747;
    font-size: .86rem;
    font-weight: 800;
}

.chatbot-result-body p {
    margin: 0;
    color: #4b5c7a;
    font-size: .76rem;
    line-height: 1.45;
}

.chatbot-result-body mark {
    padding: 0 2px;
    border-radius: 4px;
    background: #fff1a8;
    color: inherit;
}

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

.chatbot-enquiry-form {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.chatbot-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
}

.chatbot-enquiry-form input,
.chatbot-enquiry-form textarea {
    width: 100%;
    border: 1px solid #d7e2f8;
    border-radius: 10px;
    padding: 8px 9px;
    font-size: .76rem;
    outline: none;
}

.chatbot-enquiry-form input:focus,
.chatbot-enquiry-form textarea:focus {
    border-color: var(--chatbot-theme);
    box-shadow: 0 0 0 3px rgba(31, 77, 189, .1);
}

.chatbot-consent {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    font-size: .72rem;
    color: #4b5c7a;
}

.chatbot-consent input {
    width: auto;
    margin-top: 2px;
}

.chatbot-form-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.chatbot-form-actions button {
    border: 1px solid var(--chatbot-theme);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: .74rem;
    font-weight: 800;
    cursor: pointer;
}

.chatbot-form-actions button[type="submit"] {
    background: var(--chatbot-theme);
    color: #fff;
}

.chatbot-form-cancel {
    background: #fff;
    color: var(--chatbot-theme);
}

@media (max-width: 576px) {
    .chatbot-panel {
        width: 90vw;
        right: -6px;
    }
}
.chatbot-fab-bot {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(6px) scale(0.6);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #ffffff;
    color: #1f4dbd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(16, 30, 61, 0.18);
    z-index: 9998;
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.chatbot-fab-icon {
    position: absolute;
    inset: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 6px;
    box-shadow: 0 4px 10px rgba(16, 30, 61, 0.16);
}

.chatbot-fab-icon-fallback {
    position: absolute;
    inset: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    border-radius: 50%;
    background: #ffffff;
    color: #1f4dbd;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(16, 30, 61, 0.16);
}

.chatbot-fab-lottie {
    position: absolute;
    inset: -6px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
}

.chatbot-fab:hover .chatbot-fab-bot {
    opacity: 1;
    transform: translateX(-50%) translateY(-26px) scale(1);
}

.chatbot-fab:hover .chatbot-fab-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chatbot-lottie-fab {
    width: 22px;
    height: 22px;
    display: inline-block;
}

.chatbot-lottie-mini {
    width: 16px;
    height: 16px;
    display: inline-block;
}

/* Left align chatbot and keep up-scroll above it */
.chatbot-widget.chatbot-left {
    left: 24px;
    right: auto;
}

/* Ensure back-to-top stays on the right side of the viewport */
.back-to-top {
    right: 24px !important;
    left: auto !important;
    bottom: 108px !important;
}

@media (max-width: 576px) {
    .chatbot-widget.chatbot-left {
        left: 14px;
    }

    .back-to-top {
        left: 14px !important;
        bottom: 98px !important;
    }
}

/* Mobile: keep back-to-top on right side */
@media (max-width: 576px) {
    .back-to-top {
        right: 14px !important;
        left: auto !important;
        bottom: 98px !important;
    }
}
