/**
 * CuisineCo Chatbot - Styles Frontend
 * Un design moderne et fluide pour l'assistant chatbot
 */

/* Variables CSS */
:root {
    --chatbot-primary: #e74c3c;
    --chatbot-secondary: #2c3e50;
    --chatbot-bg: #ffffff;
    --chatbot-text: #333333;
    --chatbot-text-light: #666666;
    --chatbot-border: #e0e0e0;
    --chatbot-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --chatbot-radius: 16px;
    --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container principal - Position inline (là où on met le shortcode) */
#cuisineco-chatbot-container {
	width: 100%;
    position: relative;
    display: inline-block;
    z-index: 999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Bouton flottant avec texte */
.chatbot-toggle-btn {
    padding: 14px 24px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: var(--chatbot-transition);
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
}

.chatbot-toggle-btn:active {
    transform: scale(0.98);
}

.chatbot-toggle-btn .toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
}

.chatbot-toggle-btn .toggle-icon svg {
    width: 22px;
    height: 22px;
}

.chatbot-toggle-btn .button-text {
    display: inline-block;
}

/* Fenêtre du chat - Position fixe en bas à droite */
.chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 40px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    z-index: 9999999;
}

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

/* Header du chat */
.chatbot-header {
    padding: 16px 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

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

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

.bot-details {
    display: flex;
    flex-direction: column;
}

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

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

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: blink 2s infinite;
}

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

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--chatbot-transition);
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Zone des messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-anchor: none; /* Empêche le scroll automatique */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
}

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

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

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

/* Messages */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

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

.chat-message.bot {
    align-self: flex-start;
}

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

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

.chat-message.bot .message-avatar {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
}

.chat-message.user .message-avatar {
    background: #e0e0e0;
    color: #666;
}

.message-avatar svg {
    width: 18px;
    height: 18px;
}

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

.message-content a {
    color: #d8d300;
    text-decoration: underline;
    font-weight: 500;
    transition: var(--chatbot-transition);
}

.message-content a:hover {
    color: #c0b600;
    text-decoration: none;
}

.chat-message.bot .message-content {
    background: white;
    color: var(--chatbot-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--chatbot-text-light);
    margin-top: 4px;
    opacity: 0.7;
}

/* Indicateur de frappe */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    background: #f8f9fa;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Zone de saisie */
.chatbot-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
}

#cuisineco-chatbot-form {
    margin: 0;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    transition: var(--chatbot-transition);
}

.input-wrapper:focus-within {
    background: #eeeeee;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

#cuisineco-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 24px;
    line-height: 1.5;
    padding: 4px 0;
    font-family: inherit;
}

#cuisineco-chatbot-input:focus {
    outline: none;
}

#cuisineco-chatbot-input::placeholder {
    color: #999;
}

#cuisineco-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--chatbot-transition);
    flex-shrink: 0;
}

#cuisineco-send-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

#cuisineco-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#cuisineco-send-btn svg {
    width: 18px;
    height: 18px;
}

.powered-by {
    text-align: center;
    font-size: 11px;
    color: #999;
    margin-top: 10px;
}

/* Quick replies */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    background: #f8f9fa;
}

.quick-reply-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--chatbot-transition);
    color: var(--chatbot-text);
}

.quick-reply-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-toggle-btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    .chatbot-window {
        position: fixed;
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 10px;
        right: 10px;
        left: 10px;
        margin-bottom: 0;
        border-radius: 12px;
    }

    .chatbot-header {
        padding: 12px 16px;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .message-content {
        padding: 10px 14px;
        font-size: 14px;
    }
}

/* Animation d'entrée pour le bouton */
#cuisineco-chatbot-container {
    animation: fadeInUp 0.5s ease-out;
}

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

/* État de chargement */
.loading-message .message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: var(--chatbot-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Message d'erreur */
.error-message .message-content {
    background: #fff3f3;
    color: #c0392b;
    border: 1px solid #e74c3c;
}
