/* ==========================================================================
   CHATBOT FLOTTANT — Flamboyant
   ========================================================================== */

#residence-chatbot {
    --chatbot-primary: #1A1A1A;
    --chatbot-accent: #C8102E;
    --chatbot-light: #FFFFFF;
    --chatbot-bg: #F9FAFB;
    --chatbot-text: #111827;
    --chatbot-muted: #6B7280;
    --chatbot-border: #E5E7EB;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Toggle button — NEUTRE, n'ouvre PAS WhatsApp */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    color: var(--chatbot-light);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(26, 26, 26, 0.35);
    z-index: 998;
    transition: transform 0.3s ease, background 0.3s ease;
}

.chatbot-toggle:hover {
    background: var(--chatbot-accent);
    transform: scale(1.08);
}

/* Petit point rouge animé = "nouveau message possible" */
.chatbot-toggle::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--chatbot-accent);
    border: 2px solid var(--chatbot-light);
    border-radius: 50%;
    animation: chatPing 2s infinite;
}

@keyframes chatPing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.7; }
}

/* Window */
.chatbot-window {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 620px;
    max-height: calc(100vh - 140px);
    background: var(--chatbot-light);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chatbot-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chatbot-header {
    background: var(--chatbot-primary);
    color: var(--chatbot-light);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    font-size: 12px;
    opacity: 0.85;
}

.chatbot-reset {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--chatbot-light);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-reset:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chatbot-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.chatbot-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

.chatbot-message--bot { justify-content: flex-start; }
.chatbot-message--user { justify-content: flex-end; }

.chatbot-bubble {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chatbot-message--bot .chatbot-bubble {
    background: var(--chatbot-light);
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chatbot-message--user .chatbot-bubble {
    background: var(--chatbot-primary);
    color: var(--chatbot-light);
    border-bottom-right-radius: 4px;
}

.chatbot-bubble-success {
    background: #10b981 !important;
    color: #fff !important;
}

.chatbot-bubble-success small {
    opacity: 0.9;
    font-size: 12px;
}

/* Typing */
.chatbot-typing .chatbot-bubble {
    display: flex;
    gap: 4px;
    padding: 14px;
}

.chatbot-typing .chatbot-bubble span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.chatbot-typing .chatbot-bubble span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing .chatbot-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Buttons */
.chatbot-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

.chatbot-button {
    background: var(--chatbot-light);
    border: 1.5px solid var(--chatbot-border);
    color: var(--chatbot-text);
    padding: 11px 15px;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chatbot-button:hover:not(:disabled) {
    border-color: var(--chatbot-primary);
    transform: translateX(4px);
}

.chatbot-button.is-selected {
    background: var(--chatbot-primary);
    color: var(--chatbot-light);
    border-color: var(--chatbot-primary);
}

.chatbot-button.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Bouton principal "Envoyer via WhatsApp" */
.chatbot-button-primary {
    background: var(--chatbot-accent) !important;
    color: var(--chatbot-light) !important;
    border-color: var(--chatbot-accent) !important;
    font-weight: 600 !important;
    text-align: center !important;
    padding: 14px 18px !important;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.chatbot-button-primary:hover:not(:disabled) {
    background: #a00d24 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(200, 16, 46, 0.45);
}

/* Input area */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--chatbot-light);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--chatbot-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    border-color: var(--chatbot-primary);
}

.chatbot-send {
    background: var(--chatbot-primary);
    color: var(--chatbot-light);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: var(--chatbot-accent);
}

/* Footer */
.chatbot-footer {
    padding: 8px;
    background: var(--chatbot-light);
    border-top: 1px solid var(--chatbot-border);
    text-align: center;
}

.chatbot-powered {
    font-size: 11px;
    color: var(--chatbot-muted);
}

/* Animations */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
    }
}