/* Chat assistant widget (markup in footerView.php, behaviour in js/chatbot.js) */

.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', system-ui, sans-serif;
}

.chatbot-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ---------- Launcher ---------- */
.chatbot-button {
    position: relative;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 16px 30px -12px rgba(37, 99, 235, 0.75);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.chatbot-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 36px -14px rgba(37, 99, 235, 0.85);
}

.chatbot-button:focus-visible,
.chatbot-close:focus-visible,
.chatbot-send:focus-visible,
.chatbot-suggestion:focus-visible {
    outline: 3px solid #7dd3fc;
    outline-offset: 2px;
}

/* Soft ring that draws the eye while the chat is closed */
.chatbot-button::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #38bdf8;
    opacity: 0;
    pointer-events: none;
    animation: chatbotPulse 2.8s ease-out infinite;
}

@keyframes chatbotPulse {
    0% { transform: scale(1); opacity: 0.7; }
    70%, 100% { transform: scale(1.5); opacity: 0; }
}

.chatbot-button i {
    position: absolute;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.chatbot-button-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.chatbot-widget.is-open .chatbot-button-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.chatbot-widget.is-open .chatbot-button-close {
    opacity: 1;
    transform: none;
}

.chatbot-widget.is-open .chatbot-button::after {
    animation: none;
}

/* ---------- Window ---------- */
.chatbot-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: min(580px, calc(100vh - 140px));
    background: #ffffff;
    border-radius: 22px;
    border: 1px solid #e1eafa;
    box-shadow: 0 40px 80px -30px rgba(9, 9, 121, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.chatbot-window.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* ---------- Header ---------- */
.chatbot-header {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 16px 18px;
    color: #ffffff;
    background: linear-gradient(110deg, #060552 0%, #090979 38%, #0482c9 100%);
}

.chatbot-header::after {
    content: '';
    position: absolute;
    top: -70px;
    right: -40px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.chatbot-avatar {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.24);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chatbot-avatar::after {
    content: '';
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid #0a2f8f;
}

.chatbot-heading {
    flex: 1;
    min-width: 0;
}

.chatbot-title {
    margin: 0;
    font-family: "Sora", "Inter", system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.chatbot-status {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.85);
}

.chatbot-close {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ---------- Messages ---------- */
.chatbot-messages {
    flex: 1;
    padding: 18px 16px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #f3f7fe;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    animation: chatMessageIn 0.25s ease;
}

@keyframes chatMessageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.message-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #0a1633;
    border: 1px solid #e1eafa;
    border-bottom-left-radius: 4px;
    box-shadow: 0 10px 20px -16px rgba(37, 99, 235, 0.5);
}

.chat-message p {
    margin: 0 0 8px;
}

.chat-message ul {
    margin: 0 0 8px;
    padding-left: 18px;
}

.chat-message li + li {
    margin-top: 3px;
}

.chat-message > :last-child {
    margin-bottom: 0;
}

.message-bot a {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-bot code {
    padding: 1px 5px;
    border-radius: 6px;
    background: #eaf2ff;
    color: #0a1633;
    font-size: 0.92em;
}

/* Three bouncing dots while the reply is on its way */
.chatbot-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
}

.chatbot-typing[hidden] {
    display: none;
}

.chatbot-typing > span[aria-hidden] {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7c9be8;
    animation: chatbotDot 1.2s ease-in-out infinite;
}

.chatbot-typing > span[aria-hidden]:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing > span[aria-hidden]:nth-child(3) { animation-delay: 0.3s; }

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

/* ---------- Suggested questions ---------- */
.chatbot-suggestions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 14px;
    background: #f3f7fe;
}

.chatbot-suggestions[hidden] {
    display: none;
}

.chatbot-suggestion {
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid #c7dbfb;
    background: #ffffff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.chatbot-suggestion:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

/* ---------- Input ---------- */
.chatbot-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 8px;
    background: #ffffff;
    border-top: 1px solid #e1eafa;
}

.chatbot-input-area input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d5e3fb;
    border-radius: 999px;
    background: #f7faff;
    color: #0a1633;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chatbot-input-area input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.chatbot-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    color: #ffffff;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.chatbot-send:hover:not(:disabled) {
    transform: translateY(-2px);
}

.chatbot-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chatbot-note {
    flex-shrink: 0;
    margin: 0;
    padding: 0 16px 10px;
    background: #ffffff;
    color: #7c89a6;
    font-size: 11.5px;
    text-align: center;
}

.chatbot-note a {
    color: #1d4ed8;
    font-weight: 600;
}

.chatbot-privacy {
    display: block;
    margin-top: 3px;
    font-size: 10.5px;
}

.chatbot-privacy a {
    font-weight: 500;
}

/* Restart sits next to close in the header */
.chatbot-restart {
    font-size: 13px;
}

/* ---------- Answer rating ---------- */
.chatbot-feedback {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 11.5px;
    color: #7c89a6;
}

.chatbot-feedback button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid #e1eafa;
    border-radius: 50%;
    background: #ffffff;
    color: #7c89a6;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.chatbot-feedback button:hover,
.chatbot-feedback button:focus-visible {
    color: #1d4ed8;
    border-color: #93c5fd;
    outline: none;
}

/* ---------- Enquiry form in the chat ---------- */
.chatbot-lead-offer {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}

.chatbot-lead-open,
.chatbot-lead-send {
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.chatbot-lead-open:focus-visible,
.chatbot-lead-send:focus-visible,
.chatbot-lead-cancel:focus-visible {
    outline: 3px solid #7dd3fc;
    outline-offset: 2px;
}

.chatbot-lead-holder {
    max-width: 100%;
    width: 100%;
}

.chatbot-lead {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-lead-title {
    margin: 0 0 2px;
    font-weight: 600;
}

.chatbot-lead label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12.5px;
    font-weight: 600;
    color: #33415c;
}

.chatbot-lead label small {
    font-size: inherit;
    font-weight: 400;
    color: #7c89a6;
}

.chatbot-lead input,
.chatbot-lead textarea {
    width: 100%;
    border: 1px solid #d5e1f5;
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 400;
    color: #0a1633;
    background: #f8fbff;
    resize: vertical;
}

.chatbot-lead input:focus,
.chatbot-lead textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

/* Spam trap: hidden from people */
.chatbot-lead .chatbot-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.chatbot-lead-error {
    margin: 0;
    color: #b91c1c;
    font-size: 12.5px;
}

.chatbot-lead-error[hidden] {
    display: none;
}

.chatbot-lead-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-lead-send:disabled {
    opacity: 0.6;
    cursor: wait;
}

.chatbot-lead-cancel {
    border: 0;
    background: none;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    padding: 8px 6px;
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c7dbfb;
    border-radius: 10px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .chatbot-widget {
        right: 14px;
        bottom: 14px;
    }

    .chatbot-button {
        width: 54px;
        height: 54px;
        font-size: 21px;
    }

    .chatbot-window {
        width: calc(100vw - 28px);
        height: min(560px, calc(100vh - 180px));
        height: min(560px, calc(100dvh - 180px));
        bottom: 68px;
        border-radius: 20px;
    }

    /* 16px stops iOS zooming the page when the field is focused */
    .chatbot-input-area input,
    .chatbot-lead input,
    .chatbot-lead textarea {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-button::after,
    .chatbot-typing > span[aria-hidden],
    .chat-message {
        animation: none;
    }

    .chatbot-window,
    .chatbot-button,
    .chatbot-button i {
        transition: none;
    }
}
