/* ── CHAT BUBBLE ── */
#ccs-chat-bubble {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.45);
    z-index: 9000;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

#ccs-chat-bubble:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 28px rgba(239, 68, 68, 0.55);
}

/* ── CHAT PANEL ── */
#ccs-chat-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 360px;
    height: 480px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 14px 40px rgba(127, 29, 29, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 8999;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
}

#ccs-chat-panel.ccs-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── HEADER ── */
#ccs-chat-header {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

#ccs-chat-header .ccs-header-actions {
    display: flex;
    gap: 0.4rem;
}

#ccs-chat-header button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

#ccs-chat-header button:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ── MESSAGES ── */
#ccs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    scroll-behavior: smooth;
}

.ccs-message {
    max-width: 82%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
}

.ccs-message-bot {
    background: #fff7f7;
    border: 1px solid #fecaca;
    color: #2d0808;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ccs-message-user {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ── TYPING INDICATOR ── */
.ccs-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.7rem 0.9rem;
}

.ccs-typing span {
    width: 7px;
    height: 7px;
    background: #b91c1c;
    border-radius: 50%;
    animation: ccs-bounce 1.2s infinite ease-in-out;
}

.ccs-typing span:nth-child(2) { animation-delay: 0.2s; }
.ccs-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ccs-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ── INPUT AREA ── */
#ccs-chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #fecaca;
    flex-shrink: 0;
}

#ccs-chat-input {
    flex: 1;
    border: 1.5px solid #fecaca;
    border-radius: 12px;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    font-family: 'Nunito', sans-serif;
    color: #2d0808;
    outline: none;
    transition: border-color 0.15s;
    background: #fff7f7;
}

#ccs-chat-input:focus {
    border-color: #ef4444;
}

#ccs-chat-input:disabled {
    opacity: 0.6;
}

#ccs-chat-send {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}

#ccs-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

#ccs-chat-send:not(:disabled):hover {
    transform: scale(1.08);
}

/* ── LEAD CAPTURE FORM ── */
.ccs-lead-form {
    background: #fff7f7;
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-self: flex-start;
    max-width: 90%;
    font-size: 0.85rem;
    color: #2d0808;
}

.ccs-lead-form p {
    margin: 0;
    font-weight: 600;
}

.ccs-lead-form input {
    border: 1.5px solid #fecaca;
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
    font-family: 'Nunito', sans-serif;
    color: #2d0808;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}

.ccs-lead-form input:focus {
    border-color: #ef4444;
}

.ccs-lead-form .ccs-lead-actions {
    display: flex;
    gap: 0.5rem;
}

.ccs-lead-form button {
    flex: 1;
    padding: 0.45rem;
    border-radius: 10px;
    border: none;
    font-size: 0.82rem;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    font-weight: 700;
    transition: opacity 0.15s;
}

#ccs-lead-submit {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
}

#ccs-lead-skip {
    background: #fecaca;
    color: #7b1d1d;
}

.ccs-lead-form button:hover {
    opacity: 0.85;
}

.ccs-lead-error {
    color: #b91c1c;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
    #ccs-chat-panel {
        width: 100vw;
        right: 0;
        bottom: 0;
        height: 75vh;
        border-radius: 20px 20px 0 0;
    }

    #ccs-chat-bubble {
        bottom: 1.5rem;
        right: 1rem;
    }
}
