@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600&display=swap');

:root {
    --chatbot-primary-color: #121159;
    --chatbot-primary-hover: #0e0d45;
}

#chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Instrument Sans', sans-serif;
}

/* Bouton flottant style Intercom */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(18, 17, 89, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-toggle:hover {
    background: var(--chatbot-primary-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(18, 17, 89, 0.4);
}

#chatbot-container.chatbot-closed #chatbot-window {
    display: none;
}

#chatbot-container.chatbot-open #chatbot-toggle {
    display: none;
}

/* Fenêtre du chatbot - Style Intercom */
#chatbot-window {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 600px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header style Intercom */
#chatbot-header {
    background: var(--chatbot-primary-color);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #fff !important;
}

.status-online {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 400;
    color: #fff !important;
}

#chatbot-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Zone de messages */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chatbot-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

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

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

.chatbot-user .message-avatar {
    background: #e5e7eb;
    color: #6b7280;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 75%;
}

.chatbot-user .message-wrapper {
    align-items: flex-end;
}

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

.chatbot-assistant .message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-radius: 18px 18px 18px 4px;
}

.chatbot-user .message-content {
    background: var(--chatbot-primary-color);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

/* Liens dans les messages */
.message-content a {
    color: var(--chatbot-primary-color);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid var(--chatbot-primary-color);
    transition: all 0.2s;
    cursor: pointer;
}

.chatbot-assistant .message-content a {
    color: var(--chatbot-primary-color);
}

.chatbot-assistant .message-content a:hover {
    color: var(--chatbot-primary-hover);
    border-bottom-color: var(--chatbot-primary-hover);
}

.chatbot-user .message-content a {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.chatbot-user .message-content a:hover {
    border-bottom-color: #fff;
}

/* Feedback buttons */
.message-feedback {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.feedback-button {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Instrument Sans', sans-serif;
}

.feedback-button:hover {
    color: #6b7280;
    background: #f9fafb;
}

.feedback-button.selected {
    background: var(--chatbot-primary-color);
    color: #fff;
    border-color: var(--chatbot-primary-color);
}

/* Loading indicator */
.chatbot-loading .message-content {
    display: flex;
    gap: 5px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Zone d'input style Intercom */
#chatbot-input-area {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#chatbot-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: 'Instrument Sans', sans-serif;
    resize: none;
    transition: all 0.2s;
    max-height: 120px;
    line-height: 1.5;
}

#chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 0 0 3px rgba(18, 17, 89, 0.1);
}

#chatbot-input::placeholder {
    color: #9ca3af;
}

#chatbot-send {
    width: 44px;
    height: 44px;
    background: var(--chatbot-primary-color);
    color: #fff;
    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:not(:disabled) {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar personnalisée */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive mobile */
@media (max-width: 480px) {
    #chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
    }
    
    #chatbot-window {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }
    
    #chatbot-toggle {
        bottom: 16px;
        right: 16px;
    }
}
