/* Chat Widget Styles */
#chat-widget {
    --chat-primary: #1f2937;
    --chat-secondary: #f3f4f6;
    --chat-text: #1f2937;
    --chat-border: #e5e7eb;
    --chat-bubble-bg: white;
    --chat-bubble-border: #e5e7eb;
}

/* Mode sombre */
[data-theme="dark"] #chat-widget {
    --chat-primary: #f3f4f6;
    --chat-secondary: #1f2937;
    --chat-text: #f3f4f6;
    --chat-border: #4b5563;
    --chat-bubble-bg: #111827;
    --chat-bubble-border: #374151;
}

/* Bouton toggle (bulle flottante) */
.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-primary);
    border: 2px solid var(--chat-primary);
    color: var(--chat-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 998;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Fenêtre du chat */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 500px;
    background: var(--chat-bubble-bg);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 999;
    border: 1px solid var(--chat-bubble-border);
    overflow: hidden;
}

/* Header du chat */
.chat-header {
    background: var(--chat-primary);
    color: var(--chat-secondary);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--chat-border);
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--chat-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-close-btn:hover {
    transform: rotate(90deg);
}

/* Conteneur des messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-secondary);
}

/* Message utilisateur */
.chat-message-user {
    display: flex;
    justify-content: flex-end;
}

.chat-message-user .chat-message-content {
    background: var(--chat-primary);
    color: var(--chat-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-right-radius: 4px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

/* Message assistant */
.chat-message-assistant {
    display: flex;
    justify-content: flex-start;
}

.chat-message-assistant .chat-message-content {
    background: var(--chat-bubble-bg);
    color: var(--chat-text);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid var(--chat-border);
}

/* Message erreur */
.chat-message-error {
    display: flex;
    justify-content: center;
}

.chat-message-error .chat-message-content {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
}

[data-theme="dark"] .chat-message-error .chat-message-content {
    background: #7f1d1d;
    color: #fecaca;
}

/* Zone d'input */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--chat-bubble-bg);
    border-top: 1px solid var(--chat-border);
}

#chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--chat-text);
    background: var(--chat-secondary);
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* Bouton d'envoi */
.chat-send-btn {
    padding: 10px 12px;
    background: var(--chat-primary);
    color: var(--chat-secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    opacity: 0.8;
}

.chat-send-btn:active {
    transform: scale(0.95);
}

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

/* Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 48px);
        height: 60vh;
        max-height: 600px;
        bottom: 100px;
        right: 24px;
    }

    .chat-message-user .chat-message-content,
    .chat-message-assistant .chat-message-content {
        max-width: 90%;
    }
}

/* Empêcher le zoom au focus sur iOS */
#chat-input {
    font-size: 16px;
}

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

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

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

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

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
    background: #4b5563;
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
