/* FT-Services AI Chatbot - Seamless Native Design */

.chatbot-messages {
    min-height: 150px;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
    overflow: visible;
}

.chat-message {
    max-width: 70%;
    padding: 16px 20px;
    font-size: 15px;
    line-height: 1.6;
    animation: messageSlide 0.3s ease;
    font-family: 'DM Sans', sans-serif;
}

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

.chat-message.bot {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    align-self: flex-start;
    border-radius: 4px 20px 20px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Markdown formatting in bot messages */
.chat-message.bot ul,
.chat-message.bot ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message.bot li {
    margin: 4px 0;
}

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

.chat-message.bot p:first-child {
    margin-top: 0;
}

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

.chat-message.bot strong {
    font-weight: 600;
    color: #23326B;
}

.chat-message.bot code {
    background: rgba(35, 50, 107, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.chat-message.bot a {
    color: #23326B;
    text-decoration: underline;
}

.chat-message.user {
    background: #23326B;
    color: white;
    align-self: flex-end;
    border-radius: 20px 4px 20px 20px;
    box-shadow: 0 2px 12px rgba(35, 50, 107, 0.3);
}

.chat-message.bot.welcome {
    background: rgba(255, 255, 255, 0.98);
    max-width: 85%;
}

.chat-message.typing {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.95);
}

.thinking-status {
    font-size: 14px;
    color: #23326B;
    font-style: italic;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 10px;
    height: 10px;
    background: #23326B;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

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

.suggestion-chip {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(35, 50, 107, 0.15);
    border-radius: 25px;
    font-size: 13px;
    color: #23326B;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
}

.suggestion-chip:hover {
    background: #23326B;
    color: white;
    border-color: #23326B;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(35, 50, 107, 0.25);
}

.chatbot-input-area {
    padding: 0;
    background: transparent;
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 16px 24px;
    border: 2px solid rgba(35, 50, 107, 0.15);
    border-radius: 30px;
    font-size: 15px;
    font-family: 'DM Sans', sans-serif;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.2s;
}

.chatbot-input:focus {
    outline: none;
    border-color: #23326B;
    background: white;
    box-shadow: 0 4px 20px rgba(35, 50, 107, 0.15);
}

.chatbot-input::placeholder {
    color: #64748b;
}

.chatbot-send {
    width: 52px;
    height: 52px;
    background: #23326B;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(35, 50, 107, 0.4);
}

.chatbot-send:active {
    transform: scale(0.98);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chatbot-send svg {
    width: 22px;
    height: 22px;
    stroke: white;
    fill: none;
    stroke-width: 2;
}


/* Lead Capture Form */
.chat-lead-form {
    background: rgba(181, 101, 118, 0.08);
    border: 1px solid #B56576;
    border-radius: 12px;
    padding: 20px;
    margin: 8px 0;
    max-width: 320px;
    animation: messageSlide 0.3s ease;
}

.chat-lead-form h4 {
    color: #23326B;
    font-size: 15px;
    margin: 0 0 16px 0;
    font-weight: 600;
}

.chat-lead-form .form-group {
    margin-bottom: 12px;
}

.chat-lead-form label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    font-weight: 500;
}

.chat-lead-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(181, 101, 118, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    background: white;
    transition: all 0.2s;
    box-sizing: border-box;
}

.chat-lead-form input:focus {
    outline: none;
    border-color: #B56576;
    box-shadow: 0 0 0 3px rgba(181, 101, 118, 0.1);
}

.chat-lead-form input::placeholder {
    color: #94a3b8;
}

.chat-lead-form .form-status {
    text-align: center;
    font-size: 13px;
    color: #B56576;
    margin-top: 8px;
}

/* Rating Form */
.chat-rating-form {
    background: rgba(181, 101, 118, 0.08);
    border: 1px solid #B56576;
    border-radius: 12px;
    padding: 20px;
    margin: 8px 0;
    max-width: 280px;
    animation: messageSlide 0.3s ease;
}

.chat-rating-form h4 {
    color: #23326B;
    font-size: 14px;
    margin: 0 0 16px 0;
    font-weight: 600;
}

.rating-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rating-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.rating-option:hover {
    background: rgba(181, 101, 118, 0.1);
}

.rating-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #B56576;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.rating-option input[type="radio"]:checked {
    background: #B56576;
    border-color: #B56576;
}

.rating-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.rating-option label {
    font-size: 14px;
    color: #1e293b;
    cursor: pointer;
}

/* The panel owns ONE button look: the lead form's Send and the rating form's
   Submit are the same control in two places, so they share the rules rather
   than repeating them. */
.rating-submit,
.lead-submit {
    width: 100%;
    padding: 10px;
    background: #B56576;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.rating-submit:hover,
.lead-submit:hover {
    background: #9d4a5a;
}

.rating-thanks {
    text-align: center;
    color: #B56576;
    font-size: 14px;
    padding: 12px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chatbot-messages {
        min-height: 120px;
    }

    .chat-message {
        max-width: 85%;
        font-size: 14px;
        padding: 14px 18px;
    }

    .suggestion-chip {
        font-size: 12px;
        padding: 8px 14px;
    }

    .chatbot-input {
        padding: 14px 20px;
        font-size: 14px;
    }

    .chatbot-send {
        width: 48px;
        height: 48px;
    }
}

/* System messages (limits, warnings) */
.chat-system-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 14px;
    text-align: center;
}

.chat-system-message.error {
    background: #FEE2E2;
    border: 1px solid #DC2626;
    color: #DC2626;
}

.chat-system-message.warning {
    background: #FEF3C7;
    border: 1px solid #D97706;
    color: #92400E;
}

/* Lead-form validation + disabled input state */
.chat-lead-form input.invalid {
    border-color: #DC2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.chatbot-input.disabled {
    background: #f3f4f6;
}

/* ===================================================================
   FLOATING LAUNCHERS (WhatsApp + chat) + SLIDE-UP PANEL
   Class-driven open/close (ChatPanelController). Ported from the
   approved footer-E prototype.
   =================================================================== */
.fab-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 14px;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    transition: background 0.2s ease;
    padding: 0;
}

.fab svg {
    width: 26px;
    height: 26px;
}

.fab-wa {
    background: #25D366;
}

.fab-wa svg {
    fill: #fff;
}

.fab-wa:hover {
    background: #1da851;
}

.fab-chat {
    background: var(--dusty-rose-action);
}

.fab-chat svg {
    stroke: #fff;
    fill: none;
    stroke-width: 2;
}

.fab-chat:hover {
    background: var(--rose-strong);
}

.fab-chat .ic-close {
    display: none;
}

.fab-chat.open .ic-open {
    display: none;
}

.fab-chat.open .ic-close {
    display: block;
}

.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 96px;
    width: 440px;
    max-width: calc(100vw - 40px);
    height: 70vh;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    overflow: hidden;
    z-index: 9998;
    box-shadow: 0 18px 50px rgba(35, 50, 107, 0.20);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    pointer-events: none;
    /* A closed panel must be UNREACHABLE, not merely invisible. `opacity: 0`
       alone leaves every control inside it in the tab order, so a keyboard user
       tabs into a composer they cannot see and sends messages blind. The `inert`
       attribute (set by js/chatbot.js and present in the markup) covers browsers
       that implement it; `visibility: hidden` covers the rest and is what takes
       the panel out of the tab order. The 0.2s delay keeps the fade-out visible
       instead of cutting the panel off the moment it is closed. */
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.chat-panel.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    /* Opening flips visibility instantly - it must not wait for the fade. */
    visibility: visible;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

.chat-panel .chat-body {
    flex: 1;
    overflow-y: auto;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
}

.chat-head .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--tint-rose);
    display: grid;
    place-items: center;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    color: var(--dusty-rose-action);
    font-size: 15px;
    flex-shrink: 0;
}

.chat-head .who {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.2;
}

.chat-head .who small {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 12px;
    color: var(--text-gray);
}

.chat-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-gray);
    cursor: pointer;
    display: grid;
    place-items: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.chat-close:hover {
    color: var(--dusty-rose-action);
    background: var(--tint-rose);
}

.chat-close svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Panel overrides for the shared chatbot message/suggestion/input styles */
.chat-panel .chatbot-messages {
    min-height: 0;
    padding: 20px;
    border: none;
}

.chat-panel .chatbot-suggestions {
    padding: 0 20px 16px;
}

.chat-panel .chat-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
    border-top: 1px solid var(--hairline);
    margin-top: 0;
}

@media (max-width: 480px) {
    .chat-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 88px;
    }

    .fab-stack {
        right: 16px;
        bottom: 16px;
    }
}

/* Chat open: hide the mobile click-to-call FAB (.ft-call, injected by widgets.js
   at bottom:96px) — it overlaps the panel's send button. .ft-call is appended to
   body after .chat-panel, so it is a following sibling. */
.chat-panel.open ~ .ft-call {
    display: none;
}
