/* Widget de chat flottant - Style moderne */
.chat-widget {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 1000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Bulle de chat */
.chat-bubble {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 3px solid var(--bg-primary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chat-bubble:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: var(--shadow-xl);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-color) 100%);
}

.chat-bubble i {
    color: white;
    font-size: 24px;
    transition: transform 0.2s ease;
}

.chat-bubble:hover i {
    transform: scale(1.1);
}

/* Badge de notification */
.chat-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--bg-primary);
    animation: chatPulse 2s infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

@keyframes chatPulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    }
    50% { 
        transform: scale(1.1); 
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
    }
}

/* Fenêtre de chat */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.active {
    display: flex;
    animation: chatSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* En-tête du chat */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    padding: var(--spacing-lg) var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.chat-header .chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: 50%;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header .chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

/* Zone des conversations */
.chat-conversations {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-secondary);
    position: relative;
}

.chat-conversation-item {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: var(--bg-primary);
}

.chat-conversation-item:hover {
    background: var(--bg-glass);
    transform: translateX(4px);
}

.chat-conversation-item.active {
    background: var(--bg-glass);
    border-left: 4px solid var(--primary-color);
    transform: translateX(4px);
}

.chat-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.chat-conversation-user {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.chat-conversation-time {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-conversation-subject {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
}

.chat-conversation-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.chat-status-badge {
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-status-badge.open {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.chat-status-badge.closed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.chat-status-badge.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.chat-unread-badge {
    background: var(--error-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Zone des messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    display: none;
    position: relative;
}

.chat-messages.active {
    display: block;
}

.chat-message {
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    animation: chatMessageSlide 0.3s ease;
}

@keyframes chatMessageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.admin {
    align-items: flex-start;
}

.chat-message-bubble {
    max-width: 85%;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border-bottom-right-radius: var(--border-radius-sm);
}

.chat-message.admin .chat-message-bubble {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-bottom-left-radius: var(--border-radius-sm);
    position: relative;
}

.chat-message.admin .chat-message-bubble::before {
    content: '🛠️';
    position: absolute;
    top: -8px;
    left: -8px;
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: 2px solid var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.chat-message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: var(--spacing-sm);
    font-weight: 500;
}

.chat-message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

/* Zone de saisie */
.chat-input-area {
    padding: var(--spacing-lg);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-primary);
    display: none;
}

.chat-input-area.active {
    display: block;
}

.chat-input-container {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
    background: var(--bg-primary);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-color) 100%);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* État vide */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #7f8c8d;
    text-align: center;
    padding: 20px;
}

.chat-empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.chat-empty-state h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.chat-empty-state p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Message de bienvenue fixe */
.chat-welcome-message {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Section de démarrage de conversation */
.chat-start-conversation {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.start-conversation-content {
    text-align: center;
    color: var(--text-muted);
}

.start-conversation-content i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
    color: var(--primary-color);
}

.start-conversation-content h4 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: var(--text-primary);
}

.start-conversation-content p {
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.4;
}

.start-conversation-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.start-conversation-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-color) 100%);
}

.start-conversation-btn:active {
    transform: translateY(0);
}

.start-conversation-btn i {
    font-size: 14px;
    margin: 0;
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-bubble {
        width: 50px;
        height: 50px;
    }
    
    .chat-bubble i {
        font-size: 20px;
    }
}

/* Animation de chargement */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #7f8c8d;
}

.chat-loading i {
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Scrollbar personnalisée */
.chat-conversations::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-conversations::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-conversations::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-conversations::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}