/**
 * NEXSAFAR CHAT STYLES
 * Styles pour le widget de messagerie
 */

/* ========================================
   WIDGET DE CHAT FLOTTANT
======================================== */

.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    font-family: 'Montserrat', -apple-system, sans-serif;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C9A962 0%, #A68B4B 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(201, 169, 98, 0.4);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(201, 169, 98, 0.6);
}

.chat-button:active {
    transform: scale(1.05);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #E74C3C;
    color: white;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    padding: 0 6px;
}

/* ========================================
   FENÊTRE DE CHAT
======================================== */

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(44, 62, 80, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #F8F6F1;
}

.chat-window.active {
    display: flex;
    animation: slideUpFade 0.3s ease;
}

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

/* ========================================
   EN-TÊTE DU CHAT
======================================== */

.chat-header {
    background: linear-gradient(135deg, #2C3E50 0%, #34495E 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ========================================
   LISTE DES CONVERSATIONS
======================================== */

.chat-contacts {
    flex: 1;
    overflow-y: auto;
    background: #FDFBF7;
}

.chat-conversations-list {
    padding: 0;
}

.chat-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid #F8F6F1;
    background: white;
}

.chat-contact:hover {
    background: #F8F6F1;
}

.chat-contact.unread {
    background: #FFF9EB;
}

.chat-contact-photo-wrapper {
    position: relative;
    flex-shrink: 0;
}

.chat-contact-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #C9A962;
}

.chat-contact-online {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #1D8348;
    border: 2px solid white;
    border-radius: 50%;
}

.chat-contact-info {
    flex: 1;
    min-width: 0;
}

.chat-contact-name {
    font-weight: 600;
    font-size: 14px;
    color: #2C3E50;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-last-message {
    font-size: 13px;
    color: #5D6D7E;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-contact-time {
    font-size: 11px;
    color: #5D6D7E;
    white-space: nowrap;
}

.chat-contact-unread-badge {
    background: #C9A962;
    color: white;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ========================================
   VUE CONVERSATION
======================================== */

.chat-conversation-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-conversation-header {
    background: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid #F8F6F1;
}

.chat-back-btn {
    background: none;
    border: none;
    color: #2C3E50;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-back-btn:hover {
    background: #F8F6F1;
}

.chat-conversation-info {
    flex: 1;
}

.chat-conversation-name {
    font-weight: 600;
    font-size: 15px;
    color: #2C3E50;
    margin-bottom: 2px;
}

.chat-conversation-status {
    font-size: 12px;
    color: #1D8348;
}

/* ========================================
   MESSAGES
======================================== */

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    background: #FDFBF7;
    padding: 16px;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-date-separator {
    text-align: center;
    font-size: 12px;
    color: #5D6D7E;
    margin: 16px 0 8px;
    position: relative;
}

.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: #E8DCC4;
}

.chat-date-separator::before {
    left: 0;
}

.chat-date-separator::after {
    right: 0;
}

.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: messageSlideIn 0.3s ease;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #C9A962 0%, #A68B4B 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.agency-message .message-bubble {
    background: white;
    color: #2C3E50;
    border: 1px solid #F8F6F1;
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.message-time i {
    font-size: 12px;
}

.message-time i.read {
    color: #4FC3F7;
}

/* ========================================
   INPUT MESSAGE
======================================== */

.chat-input-container {
    background: white;
    padding: 14px 16px;
    border-top: 2px solid #F8F6F1;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-message-input {
    flex: 1;
    border: 2px solid #F8F6F1;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: 'Montserrat', -apple-system, sans-serif;
    transition: all 0.3s ease;
}

.chat-message-input:focus {
    outline: none;
    border-color: #C9A962;
}

.chat-message-input::placeholder {
    color: #5D6D7E;
}

.chat-send-btn {
    background: linear-gradient(135deg, #C9A962 0%, #A68B4B 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(201, 169, 98, 0.3);
}

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

/* ========================================
   ÉTATS VIDES
======================================== */

.chat-empty,
.chat-empty-messages {
    text-align: center;
    padding: 60px 20px;
    color: #5D6D7E;
}

.chat-empty i,
.chat-empty-messages i {
    font-size: 48px;
    color: #C9A962;
    margin-bottom: 15px;
}

.chat-empty p,
.chat-empty-messages p {
    margin: 8px 0;
}

.chat-loading {
    text-align: center;
    padding: 40px 20px;
    color: #5D6D7E;
}

.chat-loading i {
    font-size: 32px;
    color: #C9A962;
    margin-bottom: 12px;
}

/* ========================================
   SCROLLBAR PERSONNALISÉE
======================================== */

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

.chat-contacts::-webkit-scrollbar-track,
.chat-messages-container::-webkit-scrollbar-track {
    background: #F8F6F1;
}

.chat-contacts::-webkit-scrollbar-thumb,
.chat-messages-container::-webkit-scrollbar-thumb {
    background: #C9A962;
    border-radius: 3px;
}

.chat-contacts::-webkit-scrollbar-thumb:hover,
.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: #A68B4B;
}

/* ========================================
   RESPONSIVE MOBILE
======================================== */

@media (max-width: 768px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chat-button {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    
    .chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    
    .chat-window.active {
        animation: slideUpFull 0.3s ease;
    }
    
    @keyframes slideUpFull {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .message-bubble {
        max-width: 80%;
    }
}

/* ========================================
   ANIMATIONS SUPPLÉMENTAIRES
======================================== */

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

.chat-contact-online {
    animation: pulse 2s infinite;
}

/* États de typing (optionnel pour futur) */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5D6D7E;
    animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Notification toast (pour futur) */
.chat-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1001;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
