/* ========================================
   Chat Widget - Positionnement Fixe
   Fichier dédié pour éviter les conflits CSS
   ======================================== */

.chat-widget {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 10000;
    margin: 0;
    padding: 0;
}

.chat-button {
    width: 64px;
    height: 64px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    transition: all var(--transition-base);
    position: relative;
    border: 1px solid var(--border-color);
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    background: var(--electric);
}

.chat-button i {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.chat-button:hover i {
    color: white;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--bg-primary);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.chat-window {
    position: fixed;
    bottom: 100px;
    right: 32px;
    width: 380px;
    max-width: calc(100vw - 64px);
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 10001;
    border: 1px solid var(--border-color);
}

.chat-window.active {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

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

.chat-header-info i {
    font-size: 1.5rem;
    color: var(--electric);
}

.chat-header-info h4 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.chat-header-info small {
    display: block;
    font-size: 0.8rem;
    margin-top: 2px;
    color: var(--text-secondary);
}

.status {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-close {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close:hover {
    background: var(--error);
    color: white;
    transform: rotate(90deg);
}

.chat-identity-form {
    padding: 32px 24px;
    background: var(--bg-primary);
}

.chat-form-content h5 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.chat-identity-form .form-group {
    margin-bottom: 16px;
}

.chat-identity-form .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chat-identity-form .form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    color: var(--text-primary);
}

.chat-identity-form .form-group input::placeholder {
    color: var(--text-muted);
}

.chat-identity-form .form-group input:focus {
    border-color: var(--electric);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
    background: var(--bg-secondary);
}

.chat-body {
    display: flex;
    flex-direction: column;
    height: 450px;
    background: var(--bg-primary);
}

.chat-user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.chat-user-details {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.chat-user-details i {
    color: var(--electric);
    font-size: 1.25rem;
}

.chat-edit-btn {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.chat-edit-btn:hover {
    background: var(--electric);
    color: white;
}

.chat-edit-form {
    padding: 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.chat-edit-form .form-group {
    margin-bottom: 12px;
}

.chat-edit-form .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.chat-edit-form .form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.chat-edit-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.chat-edit-actions .btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.chat-messages .message {
    display: flex;
    margin-bottom: 16px;
    gap: 12px;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-messages .message.bot {
    justify-content: flex-start;
}

.chat-messages .message.user {
    justify-content: flex-end;
}

.chat-messages .message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.chat-messages .message.bot .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-messages .message.user .message-content {
    background: var(--gradient-accent);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.chat-messages .message-content p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-messages .message-content .message-time {
    display: block;
    font-size: 0.75rem;
    margin-top: 6px;
}

.chat-messages .message.bot .message-content .message-time {
    color: var(--gray-500);
}

.chat-messages .message.user .message-content .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.chat-input {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.chat-input input {
    flex: 1;
    padding: 12px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-base);
    color: var(--text-primary);
}

.chat-input input::placeholder {
    color: var(--text-muted);
}

.chat-input input:focus {
    background: var(--bg-secondary);
    border-color: var(--electric);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

.chat-input button {
    width: 44px;
    height: 44px;
    background: var(--gradient-accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

/* Responsive Chat - Mobile */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
    }

    .chat-window {
        width: calc(100vw - 40px);
        bottom: 76px;
        right: -10px;
    }

    .chat-body {
        height: 60vh;
    }
}
