/* TwinsEstate AI Chatbot Styles */

:root {
    --twinsestate-primary: #0066cc;
    --twinsestate-primary-dark: #0052a3;
    --twinsestate-secondary: #f0f2f5;
    --twinsestate-text: #1c1e21;
    --twinsestate-text-light: #65676b;
    --twinsestate-border: #e4e6eb;
    --twinsestate-white: #ffffff;
    --twinsestate-shadow: rgba(0, 0, 0, 0.1);
    --twinsestate-success: #00a400;
}

/* Container principal */
#twinsestate-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Bouton de toggle */
.twinsestate-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--twinsestate-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.twinsestate-chat-toggle:hover {
    background: var(--twinsestate-primary-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 102, 204, 0.5);
}

.twinsestate-chat-toggle svg {
    width: 28px;
    height: 28px;
    color: var(--twinsestate-white);
    transition: all 0.3s ease;
}

.twinsestate-chat-icon {
    display: block;
}

.twinsestate-close-icon {
    display: none;
}

.twinsestate-chat-toggle.active .twinsestate-chat-icon {
    display: none;
}

.twinsestate-chat-toggle.active .twinsestate-close-icon {
    display: block;
}

/* Badge de notification */
.twinsestate-notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4444;
    color: var(--twinsestate-white);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid var(--twinsestate-white);
}

.twinsestate-notification-badge.hidden {
    display: none;
}

/* Fenêtre de chat */
.twinsestate-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--twinsestate-white);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--twinsestate-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.twinsestate-chat-window.active {
    display: flex;
}

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

/* En-tête du chat */
.twinsestate-chat-header {
    background: var(--twinsestate-primary);
    color: var(--twinsestate-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.twinsestate-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.twinsestate-bot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.twinsestate-bot-avatar svg {
    width: 24px;
    height: 24px;
}

.twinsestate-bot-info {
    display: flex;
    flex-direction: column;
}

.twinsestate-bot-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.twinsestate-bot-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.twinsestate-status-dot {
    width: 8px;
    height: 8px;
    background: var(--twinsestate-success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.twinsestate-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.twinsestate-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.twinsestate-close-btn svg {
    width: 20px;
    height: 20px;
    color: var(--twinsestate-white);
}

/* Zone de messages */
.twinsestate-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--twinsestate-secondary);
}

.twinsestate-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.twinsestate-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.twinsestate-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Messages */
.twinsestate-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.twinsestate-message-user {
    flex-direction: row-reverse;
}

.twinsestate-message-avatar {
    width: 32px;
    height: 32px;
    background: var(--twinsestate-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.twinsestate-message-avatar svg {
    width: 18px;
    height: 18px;
    color: var(--twinsestate-white);
}

.twinsestate-message-user .twinsestate-message-avatar {
    background: var(--twinsestate-text-light);
}

.twinsestate-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 75%;
}

.twinsestate-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.twinsestate-message-bot .twinsestate-message-bubble {
    background: var(--twinsestate-white);
    color: var(--twinsestate-text);
    border-bottom-left-radius: 4px;
}

.twinsestate-message-user .twinsestate-message-bubble {
    background: var(--twinsestate-primary);
    color: var(--twinsestate-white);
    border-bottom-right-radius: 4px;
}

.twinsestate-message-time {
    font-size: 11px;
    color: var(--twinsestate-text-light);
    padding: 0 8px;
}

.twinsestate-message-user .twinsestate-message-time {
    text-align: right;
}

/* Indicateur de frappe */
.twinsestate-typing-indicator {
    display: none;
    padding: 0 20px 10px 20px;
    background: var(--twinsestate-secondary);
}

.twinsestate-typing-indicator.active {
    display: flex;
    gap: 4px;
    align-items: center;
}

.twinsestate-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--twinsestate-text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.twinsestate-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.twinsestate-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Zone de saisie */
.twinsestate-chat-input-container {
    background: var(--twinsestate-white);
    border-top: 1px solid var(--twinsestate-border);
}

.twinsestate-chat-form {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 10px;
}

.twinsestate-chat-input {
    flex: 1;
    border: 1px solid var(--twinsestate-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    background: var(--twinsestate-secondary);
    transition: border-color 0.2s ease;
}

.twinsestate-chat-input:focus {
    outline: none;
    border-color: var(--twinsestate-primary);
    background: var(--twinsestate-white);
}

.twinsestate-chat-input::-webkit-scrollbar {
    width: 4px;
}

.twinsestate-chat-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.twinsestate-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--twinsestate-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.twinsestate-send-btn:hover {
    background: var(--twinsestate-primary-dark);
    transform: scale(1.05);
}

.twinsestate-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.twinsestate-send-btn svg {
    width: 20px;
    height: 20px;
    color: var(--twinsestate-white);
}

.twinsestate-chat-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: var(--twinsestate-text-light);
    border-top: 1px solid var(--twinsestate-border);
}

/* Responsive */
@media (max-width: 480px) {
    #twinsestate-chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .twinsestate-chat-window {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 80px;
        max-width: none;
        border-radius: 16px 16px 0 0;
    }

    .twinsestate-chat-toggle {
        position: absolute;
        right: 10px;
        bottom: 0;
    }
}

/* Animation d'envoi */
@keyframes sendPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.twinsestate-send-btn.sending {
    animation: sendPulse 0.3s ease;
}

/* Message d'erreur */
.twinsestate-error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 13px;
    text-align: center;
    margin: 10px 20px;
}
