/* FFD POWER — website text chat widget (NOT VAPI voice) */
.ffd-chat-fab {
    position: fixed;
    left: 22px;
    bottom: 96px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f2f2c 0%, #0d9488 100%);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(15, 47, 44, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ffd-chat-fab:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 32px rgba(13, 148, 136, 0.45);
}

.ffd-chat-panel {
    position: fixed;
    left: 22px;
    bottom: 164px;
    z-index: 9999;
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 180px));
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(15, 47, 44, 0.22);
    border: 1px solid #d1eae6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
.ffd-chat-panel:has(.ffd-chat-lead:not([hidden])) .ffd-chat-messages {
    min-height: 120px;
}
.ffd-chat-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ffd-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0a1f1d 0%, #0d9488 100%);
    color: #fff;
}
.ffd-chat-title { display: block; font-size: 15px; font-weight: 700; }
.ffd-chat-sub { display: block; font-size: 11px; opacity: 0.85; margin-top: 2px; }
.ffd-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.ffd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    min-height: 220px;
    overscroll-behavior: contain;
}
.ffd-chat-msg {
    max-width: 88%;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ffd-chat-msg__body {
    white-space: pre-wrap;
}
.ffd-chat-msg__time {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    line-height: 1;
    opacity: 0.68;
}
.ffd-chat-msg--assistant {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}
.ffd-chat-msg--user {
    margin-left: auto;
    background: #0d9488;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ffd-chat-msg--typing {
    width: fit-content;
    min-width: 78px;
}
.ffd-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 18px;
}
.ffd-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #0d9488;
    animation: ffd-chat-typing 1.1s ease-in-out infinite;
}
.ffd-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}
.ffd-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes ffd-chat-typing {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.ffd-chat-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.ffd-chat-form input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    min-width: 0;
    background: #fff !important;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
    caret-color: #0d9488;
}
.ffd-chat-form input::placeholder {
    color: #64748b;
    opacity: 1;
    -webkit-text-fill-color: #64748b;
}
.ffd-chat-form input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-text-fill-color: #0f172a !important;
}
.ffd-chat-form input:focus { border-color: #0d9488; }
.ffd-chat-form button {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: #0d9488;
    color: #fff;
    cursor: pointer;
}

.ffd-chat-lead {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #f0fdfa;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-height: min(270px, 42vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.ffd-chat-lead[hidden] { display: none !important; }
.ffd-chat-lead-title {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #0f2f2c;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
}
.ffd-chat-lead-title::after {
    content: "Share your details for engineering review.";
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 11px;
    font-weight: 500;
}
.ffd-chat-lead input,
.ffd-chat-lead select {
    width: 100%;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    background: #fff !important;
    color: #0f172a !important;
    -webkit-text-fill-color: #0f172a !important;
}
.ffd-chat-lead input::placeholder {
    color: #64748b;
    opacity: 1;
    -webkit-text-fill-color: #64748b;
}
.ffd-chat-lead-btn {
    grid-column: 1 / -1;
    border: none;
    border-radius: 999px;
    background: #0f2f2c;
    color: #fff;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
}

body:has(.ffd-sticky-cta.is-visible:not(.is-dismissed)) .ffd-chat-fab {
    bottom: 148px;
}
body:has(.ffd-sticky-cta.is-visible:not(.is-dismissed)) .ffd-chat-panel {
    bottom: 216px;
}

@media (max-width: 480px) {
    .ffd-chat-fab {
        left: 16px;
        bottom: 88px;
        width: 54px;
        height: 54px;
    }
    .ffd-chat-panel {
        left: 10px;
        right: 10px;
        bottom: 88px;
        width: auto;
        max-height: min(82vh, 620px);
        border-radius: 16px;
    }
    body:has(.ffd-sticky-cta.is-visible:not(.is-dismissed)) .ffd-chat-panel {
        bottom: 150px;
    }
    .ffd-chat-messages {
        min-height: 190px;
        padding: 12px;
    }
    .ffd-chat-panel:has(.ffd-chat-lead:not([hidden])) .ffd-chat-messages {
        min-height: 90px;
    }
    .ffd-chat-msg {
        max-width: 92%;
        font-size: 13px;
    }
    .ffd-chat-form {
        padding: 9px 10px;
    }
    .ffd-chat-form input {
        font-size: 16px;
        padding: 10px 12px;
    }
    .ffd-chat-lead {
        grid-template-columns: 1fr;
        max-height: min(310px, 44vh);
        padding: 10px;
        gap: 7px;
    }
    .ffd-chat-lead-title {
        font-size: 12px;
    }
    .ffd-chat-lead input,
    .ffd-chat-lead select {
        font-size: 12px;
        padding: 8px 9px;
    }
    .ffd-chat-lead-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}
