/**
 * CSS pour l'interface du chat
 */

/* Bouton de chat */
#aichat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #2fb5d2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 99999;
    transition: all 0.3s ease;
}

#aichat-button:hover {
    background-color: #2a9db7;
    transform: scale(1.05);
}

#aichat-button i {
    font-size: 24px;
}

/* Fenêtre de chat */
#aichat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#aichat-window.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* En-tête de chat */
#aichat-header {
    background-color: #2fb5d2;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#aichat-header-info {
    display: flex;
    flex-direction: column;
}

#aichat-header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

#aichat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin: 0;
}

#aichat-close {
    cursor: pointer;
    font-size: 20px;
}

/* Zone de messages */
#aichat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#aichat-messages .spacer {
  margin-top: auto;
}

.aichat-message {
    display: flex;
    margin-bottom: 10px;
    align-items: flex-start;
    max-width: 80%;
}

.aichat-user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aichat-assistant-message,
.aichat-human-message {
    align-self: flex-start;
}

.aichat-system-message, 
.aichat-error-message {
    align-self: center;
    max-width: 100%;
    text-align: center;
}

.aichat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px;
    display: none;
}

.aichat-avatar i {
    font-size: 18px;
    color: #777;
}

.aichat-message-content {
    background-color: #f0f0f0;
    padding: 10px 12px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.aichat-user-message .aichat-message-content {
    background-color: #2fb5d2;
    color: white;
    border-top-right-radius: 5px;
}

.aichat-assistant-message .aichat-message-content {
    background-color: #f5f5f5;
    border-top-left-radius: 5px;
}

.aichat-human-message .aichat-message-content {
    background-color: #e9f0fd;
    border-top-left-radius: 5px;
}

.aichat-system-message .aichat-message-content {
    background-color: #f8f9fa;
    color: #6c757d;
    font-style: italic;
    font-size: 13px;
}

.aichat-error-message .aichat-message-content {
    background-color: #fff5f5;
    color: #d63031;
    border: 1px solid #ffcccc;
}

.aichat-assistant-message .aichat-message-content a {
    color: #3399FF;
}

.aichat-assistant-message .aichat-message-content a:hover {
    color: #66B3FF;
}

/* Indicateur de frappe */
.aichat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.aichat-typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #b5b5b5;
    border-radius: 50%;
    display: inline-block;
    animation: typingAnimation 1.5s infinite ease-in-out;
}

.aichat-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Pied de chat */
#aichat-footer {
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-top: 1px solid #eee;
    background-color: #fff;
}

#aichat-footer-buttons {
    display: flex;
    margin-bottom: 10px;
}

#aichat-human-button {
    font-size: 12px;
    color: #777;
    background-color: transparent;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#aichat-human-button:hover {
    background-color: #f5f5f5;
    color: #333;
}

#aichat-input-container {
    display: flex;
    align-items: center;
    background-color: #f5f5f5;
    border-radius: 20px;
    padding: 5px 15px;
}

#aichat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    outline: none;
    font-size: 14px;
}

#aichat-send-button {
    background: none;
    border: none;
    color: #2fb5d2;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#aichat-send-button i {
    font-size: 20px;
}

#aichat-send-button:hover {
    color: #2a9db7;
}

/* Médias queries pour responsive */
@media (max-width: 480px) {
    #aichat-window {
        width: calc(100% - 40px);
        height: calc(100% - 140px);
        right: 20px;
        bottom: 80px;
    }
}

/**
 * AI Customer Chat CSS
 */

#aichat-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#aichat-icon {
    width: 60px;
    height: 60px;
    background-color: #2fb5d2;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#aichat-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#aichat-icon i {
    font-size: 30px;
}

/*#aichat-window {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}*/

#aichat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/*#aichat-header {
    padding: 15px;
    background-color: #2fb5d2;
    color: white;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}*/

#aichat-title h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

#aichat-title p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

#aichat-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

#aichat-human-button, 
#aichat-new-chat-button,
#aichat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

#aichat-human-button:hover, 
#aichat-new-chat-button:hover,
#aichat-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#aichat-human-button.active {
    background-color: rgba(255, 255, 255, 0.3);
}

#aichat-human-button i,
#aichat-new-chat-button i,
#aichat-close i {
    font-size: 16px;
    margin-right: 4px;
}

#aichat-close i {
    margin-right: 0;
}

/*#aichat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f5f5f5;
}

.aichat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.aichat-user {
    align-items: flex-end;
}

.aichat-assistant, .aichat-system {
    align-items: flex-start;
}

.aichat-message-content {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    word-break: break-word;
}

.aichat-user .aichat-message-content {
    background-color: #dcf8c6;
}

.aichat-assistant .aichat-message-content {
    background-color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aichat-system .aichat-message-content {
    background-color: #f0f0f0;
    font-style: italic;
    font-size: 0.9em;
}

#aichat-form {
    padding: 15px;
    border-top: 1px solid #eee;
}

#aichat-input-container {
    display: flex;
    align-items: center;
}

#aichat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 14px;
}

#aichat-input:focus {
    border-color: #2fb5d2;
}

#aichat-form button {
    background: none;
    border: none;
    color: #2fb5d2;
    cursor: pointer;
    margin-left: 10px;
}

#aichat-form button i {
    font-size: 24px;
}*/

/* Loading indicator */
.aichat-loading {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.aichat-loading-dots {
    display: flex;
    justify-content: center;
    align-items: center;
}

.aichat-loading-dots div {
    width: 8px;
    height: 8px;
    background-color: #aaa;
    border-radius: 50%;
    margin: 0 3px;
    animation: aichat-loading-bounce 1.4s infinite ease-in-out both;
}

.aichat-loading-dots div:nth-child(1) {
    animation-delay: -0.32s;
}

.aichat-loading-dots div:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes aichat-loading-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Responsive styles */
@media (max-width: 480px) {
    #aichat-window {
        width: 300px;
        height: 450px;
        bottom: 70px;
    }
    
    .aichat-message-content {
        max-width: 85%;
    }
}

/* Updated footer buttons styling */
#aichat-footer-buttons {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

#aichat-human-button,
#aichat-new-chat-button {
    font-size: 12px;
    color: #777;
    background-color: transparent;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

#aichat-human-button:hover,
#aichat-new-chat-button:hover {
    background-color: #f5f5f5;
    color: #333;
}

#aichat-new-chat-button {
    background-color: #f7f7f7;
}

#aichat-new-chat-button i {
    font-size: 16px;
    margin-right: 4px;
}

/* Add a subtle indicator for when chat has a persistence */
#aichat-button.has-conversation::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: #4CAF50;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    right: 5px;
    border: 2px solid white;
}
