/* ============================================
   VARIABLES CSS - PERSONNALISEZ ICI
   ============================================ */
:root {
    /* Couleurs principales */
    --primary-color: #ff6b00;
    --primary-hover: #0052a3;
    --secondary-color: #f0f0f0;
    
    /* Couleurs des messages */
    --user-message-bg: #ff6b00;
    --user-message-color: #ffffff;
    --agent-message-bg: #f0f0f0;
    --agent-message-color: #333333;
    
    /* Couleurs Quick Replies (PERSONNALISABLE) */
    --quick-reply-bg: #ffffff;
    --quick-reply-border: #ff6b00;
    --quick-reply-color: #ff6b00;
    --quick-reply-hover-bg: #ff6b00;
    --quick-reply-hover-color: #ffffff;
    
    /* Dimensions */
    --chat-width: 380px;
    --chat-height: 600px;
    --launcher-size: 60px;
    
    /* Espacement */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    
    /* Bordures */
    --border-radius: 8px;
    --message-radius: 18px;
    
    /* Ombres */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ============================================
   STYLES DE BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* ============================================
   BOUTON DE LANCEMENT
   ============================================ */
.chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: var(--launcher-size);
    height: var(--launcher-size);
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 999999999999!important;
}

.chat-launcher:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.chat-launcher svg {
    width: 28px;
    height: 28px;
}

/* ============================================
   FENÊTRE DE CHAT
   ============================================ */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* ============================================
   EN-TÊTE
   ============================================ */
.chat-header {
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
    background-size: 24px;
    background-repeat: no-repeat;
    background-position: center;
}

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

.chat-header p {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.close-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   MODALE DE CONFIRMATION
   ============================================ */
.confirm-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-modal-content {
    background: white;
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin: var(--spacing-md);
    max-width: 320px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.confirm-modal-content p {
    margin: 0 0 var(--spacing-md) 0;
    color: var(--text-color);
    line-height: 1.5;
    text-align: center;
}

.confirm-modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

.confirm-button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.confirm-yes {
    background: #ff6b00;
    color: white;
}

.confirm-yes:hover {
    background: #e55d00;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.confirm-no {
    background: var(--secondary-color);
    color: var(--text-color);
}

.confirm-no:hover {
    background: #e0e0e0;
}

/* ============================================
   ZONE DE MESSAGES
   ============================================ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

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

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

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

/* Messages */
.message {
    display: flex;
    gap: var(--spacing-sm);
    animation: slideIn 0.3s ease;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-color);
    flex-shrink: 0;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
    background-size: 20px;
    background-repeat: no-repeat;
    background-position: center;
}

.message.user .message-avatar {
    background: var(--primary-color);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
    background-size: 20px;
    background-repeat: no-repeat;
    background-position: center;
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--message-radius);
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--user-message-bg);
    color: var(--user-message-color);
    border-bottom-right-radius: 4px;
}

.message.agent .message-bubble {
    background: var(--agent-message-bg);
    color: var(--agent-message-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .message-time {
    text-align: right;
}

/* Images dans les messages */
.message-image {
    max-width: 200px;
    border-radius: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.05);
}

/* Boutons de liens dans les messages */
.link-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 4px 4px 4px 0;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.link-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.link-button svg {
    flex-shrink: 0;
}

.link-email {
    border-color: #ff6b00;
    color: #ff6b00;
}

.link-email:hover {
    background: #ff6b00;
    color: white;
}

.link-email:hover svg {
    stroke: white;
}

.link-whatsapp {
    border-color: #25D366;
    color: #25D366;
}

.link-whatsapp:hover {
    background: #25D366;
    color: white;
}

.link-whatsapp:hover svg {
    fill: white;
}

.link-phone {
    border-color: #ff6b00;
    color: #ff6b00;
}

.link-phone:hover {
    background: #ff6b00;
    color: white;
}

.link-phone:hover svg {
    stroke: white;
}

.link-web {
    border-color: #666;
    color: #666;
}

.link-web:hover {
    background: #666;
    color: white;
}

.link-web:hover svg {
    stroke: white;
}

/* Les liens doivent s'afficher en colonne dans la bulle, taille adaptée au contenu */
.message-bubble .link-button {
    display: inline-flex !important;
    width: fit-content !important;
    max-width: 100%;
}

/* Link-buttons dans les quick replies : compacts avec icône */
.quick-replies .link-button {
    display: inline-flex !important;
    width: fit-content !important;
    max-width: 100%;
}

/* ============================================
   QUICK REPLIES (PERSONNALISABLE)
   ============================================ */
.quick-replies {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    animation: slideIn 0.3s ease;
}

.quick-reply-button {
    background: var(--quick-reply-bg);
    border: 2px solid var(--quick-reply-border);
    color: var(--quick-reply-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: normal;
    word-break: break-word;
    text-align: left;
    width: 100%;
    align-self: stretch;
}

.quick-reply-button:hover {
    background: var(--quick-reply-hover-bg);
    color: var(--quick-reply-hover-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   CAROUSEL / CARDS
   ============================================ */
.carousel-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: var(--spacing-sm) 0;
    animation: slideIn 0.3s ease;
}

.carousel-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
}

.card-title {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.card-description {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: auto;
}

.card-action-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
}

.card-action-button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ============================================
   INDICATEUR DE SAISIE
   ============================================ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--agent-message-bg);
    border-radius: var(--message-radius);
    width: fit-content;
    margin: 0 var(--spacing-md);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* ============================================
   ZONE DE SAISIE
   ============================================ */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: white;
    border-top: 1px solid #e0e0e0;
}

.attach-button {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.attach-button:hover {
    background: var(--secondary-color);
    color: var(--primary-color);
}

.message-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--primary-color);
}

.send-button {
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.send-button:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   BARRE DE CHARGEMENT
   ============================================ */
.loading-bar {
    height: 3px;
    background: #e0e0e0;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: var(--primary-color);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        width: 0;
        margin-left: 0;
    }
    50% {
        width: 50%;
        margin-left: 25%;
    }
    100% {
        width: 0;
        margin-left: 100%;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    .chat-launcher {
        bottom: 10px;
        right: 10px;
    }
}

/* ============================================
   FORMATAGE MARKDOWN DES MESSAGES
   ============================================ */
.message-bubble strong {
    font-weight: 700;
}

.message-bubble em {
    font-style: italic;
}

.message-bubble del {
    text-decoration: line-through;
    opacity: 0.8;
}

.message-bubble code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    word-break: break-all;
}

.message.user .message-bubble code {
    background: rgba(255, 255, 255, 0.25);
}

.message-bubble ul {
    list-style: disc;
    padding-left: 18px;
    margin: 4px 0;
}

.message-bubble li {
    margin: 2px 0;
}

/* ============================================
   UTILITAIRES
   ============================================ */
.text-center {
    text-align: center;
}

.system-message {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: var(--spacing-md) 0;
}