/* ============================================ */
/* EDENLANG CHATBOT WIDGET - STYLES CSS */
/* ============================================ */

/* Animations */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* ============================================ */
/* CONTENEUR PRINCIPAL */
/* ============================================ */

.chatbot-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 5000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================ */
/* BOUTON DE DÉCLENCHEMENT */
/* ============================================ */

.chatbot-trigger {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    animation: pulse 3s ease-in-out infinite;
}

.chatbot-trigger:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
    animation: bounce 0.6s ease;
}

.chatbot-trigger.chat-open {
    background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
    animation: none;
}

.trigger-icon {
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
}

.icon-chat,
.icon-close {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.icon-close {
    font-size: 18px;
    font-weight: bold;
}

/* Badge de notification */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
    animation: bounce 1s ease infinite;
}

/* ============================================ */
/* PANEL DE CHAT */
/* ============================================ */

.chatbot-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
}

.chatbot-panel.hidden {
    display: none;
}

/* ============================================ */
/* HEADER DU CHAT */
/* ============================================ */

.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px 16px 0 0;
    position: relative;
    flex-shrink: 0;
}

.chatbot-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chatbot-info {
    flex: 1;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
    font-weight: 400;
}

.chatbot-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ============================================ */
/* ZONE DE CONVERSATION */
/* ============================================ */

.chatbot-conversation {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

.chatbot-conversation::-webkit-scrollbar {
    width: 6px;
}

.chatbot-conversation::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-conversation::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chatbot-conversation::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Loading de conversation */
.conversation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
}

.conversation-loading p {
    margin-top: 16px;
    font-size: 14px;
}

/* ============================================ */
/* MESSAGES */
/* ============================================ */

.message {
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.message.message-user {
    align-self: flex-end;
}

.message-content {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.message-user .message-content {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-bubble {
    max-width: 280px;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message-assistant .message-bubble {
    background: #f1f3f4;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
}

.message-user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-text {
    line-height: 1.4;
    font-size: 14px;
}

.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

.message-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}

.message-user .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.code-block {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    margin: 8px 0;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-user .message-time {
    text-align: left;
}

/* ============================================ */
/* ACTIONS DES MESSAGES */
/* ============================================ */

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.insert-code {
    background: #28a745;
}

.insert-code:hover {
    background: #1e7e34;
}

.run-code {
    background: #17a2b8;
}

.run-code:hover {
    background: #117a8b;
}

.copy-code {
    background: #6c757d;
}

.copy-code:hover {
    background: #545b62;
}

/* ============================================ */
/* INDICATEUR DE FRAPPE */
/* ============================================ */

.typing {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.typing-indicator,
.typing-animation {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 0;
}

.typing-indicator span,
.typing-animation span {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2),
.typing-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3),
.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ============================================ */
/* ACTIONS RAPIDES */
/* ============================================ */

.chatbot-quick-actions {
    padding: 12px 16px;
    background: rgba(102, 126, 234, 0.05);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.quick-action-btn {
    background: white;
    border: 1px solid #e1e5e9;
    color: #495057;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.quick-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================ */
/* ZONE DE SAISIE */
/* ============================================ */

.chatbot-input-area {
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
    align-items: flex-end;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.4;
}

#chatbot-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chatbot-input::placeholder {
    color: #6c757d;
}

.send-button {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-icon,
.send-loading {
    font-size: 16px;
    transition: all 0.2s ease;
}

.send-loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* FOOTER DE L'INPUT */
/* ============================================ */

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px 12px;
    font-size: 12px;
    color: #6c757d;
}

.input-actions {
    display: flex;
    gap: 12px;
}

.input-action {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-action:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.input-action.active {
    background: #667eea;
    color: white;
}

.input-counter {
    font-size: 11px;
    opacity: 0.7;
}

/* ============================================ */
/* TOAST NOTIFICATIONS */
/* ============================================ */

.chatbot-toast {
    animation: slideInRight 0.3s ease;
}

/* ============================================ */
/* RESPONSIVE DESIGN */
/* ============================================ */

@media screen and (max-width: 768px) {
    .chatbot-widget-container {
        bottom: 80px !important;
        right: 10px !important;
        left: 10px !important;
    }
    
    .chatbot-panel {
        width: calc(100vw - 20px);
        max-width: 380px;
        height: calc(100vh - 160px);
        max-height: 500px;
        bottom: 70px;
        right: 0;
        left: 0;
        transform: none;
        border-radius: 16px 16px 0 0;
    }
    
    .chatbot-trigger {
        width: 50px !important;
        height: 50px !important;
    }

    
    .message-bubble {
        max-width: 240px;
    }
    
    .quick-action-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .trigger-icon {
        font-size: 20px !important;
    }
}

@media screen and (max-width: 480px) {
    .chatbot-widget-container {
        bottom: 75px !important;
        right: 10px !important;
    }
    
    .chatbot-trigger {
        width: 45px !important;
        height: 45px !important;
    }
    
    .chatbot-panel {
        height: 80vh;
        border-radius: 12px 12px 0 0;
    }
    
    .chatbot-header {
        padding: 16px;
    }
    
    .chatbot-conversation {
        padding: 12px;
    }
    
    .message-bubble {
        max-width: 200px;
        padding: 10px 14px;
    }
    
    .input-wrapper {
        padding: 10px 12px;
    }
    
    .input-footer {
        padding: 6px 12px 10px;
    }
    
    .chatbot-quick-actions {
        padding: 10px 12px;
    }
    
    .quick-action-btn {
        font-size: 10px;
        padding: 5px 8px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
}

/* ============================================ */
/* THÈME SOMBRE (optionnel) */
/* ============================================ */

@media (prefers-color-scheme: dark) {
    .chatbot-panel {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .chatbot-conversation {
        background: linear-gradient(to bottom, #1a202c 0%, #2d3748 100%);
    }
    
    .message-assistant .message-bubble {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    #chatbot-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    #chatbot-input::placeholder {
        color: #a0aec0;
    }
    
    .input-footer {
        color: #a0aec0;
    }
    
    .quick-action-btn {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }
    
    .quick-action-btn:hover {
        background: #667eea;
        color: white;
    }
}