/* Message Animations and Styling */

/* Fade-in animation for new messages */
.message-fade-in {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* New message highlight */
.new-message {
    background-color: rgba(255, 255, 0, 0.1);
    border-left: 3px solid #ffc107;
    transition: all 0.3s ease;
}

.new-message:hover {
    background-color: rgba(255, 255, 0, 0.2);
}

/* Message status indicators */
.message-status {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
}

.message-status.sent {
    color: #6c757d;
}

.message-status.delivered {
    color: #17a2b8;
}

.message-status.read {
    color: #28a745;
}

/* Message type specific styling */
.message-image {
    width: auto;
    height: auto;
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.message-file i {
    font-size: 20px;
    color: #6c757d;
}

.message-file a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.message-file a:hover {
    text-decoration: underline;
}

.message-voice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #e3f2fd;
    border-radius: 8px;
    border: 1px solid #bbdefb;
}

.message-voice i {
    font-size: 18px;
    color: #1976d2;
}

.message-voice audio {
    max-width: 200px;
}

.message-video {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #f3e5f5;
    border-radius: 8px;
    border: 1px solid #e1bee7;
}

.message-video video {
    max-width: 300px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-location {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #e8f5e8;
    border-radius: 8px;
    border: 1px solid #c8e6c9;
}

.message-location i {
    font-size: 18px;
    color: #388e3c;
}

.message-location strong {
    color: #2e7d32;
}

.message-location small {
    color: #666;
    display: block;
    margin-top: 2px;
}

.message-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #fff3e0;
    border-radius: 8px;
    border: 1px solid #ffcc80;
}

.message-contact i {
    font-size: 18px;
    color: #f57c00;
}

.message-contact strong {
    color: #e65100;
}

.message-contact small {
    color: #666;
    display: block;
    margin-top: 2px;
}

/* Message bubble enhancements */
.message-bubble {
    position: relative;
    max-width: 70%;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background-color: #007bff;
    color: white;
    border-radius: 18px 18px 4px 18px;
    margin-left: auto;
}

.message.received .message-bubble {
    background-color: #f1f3f4;
    color: #333;
    border-radius: 18px 18px 18px 4px;
    margin-right: auto;
}

.message-content {
    padding: 8px 12px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message.received .message-time {
    color: #666;
}

/* Responsive design */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
    }
    
    .message-video video {
        max-width: 250px;
    }
    
    .message-voice audio {
        max-width: 150px;
    }
    
    .message-image {
        max-width: 160px;
        max-height: 160px;
    }
}

/* Loading animation for long polling */
.polling-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state styling */
.message-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.message-error .message-time {
    color: #721c24;
}
