/**
 * Messaging System Styles
 *
 * Custom styles and animations for the chat sidebar and components.
 */

/* Sidebar Slide Animation */
.slide-enter-active,
.slide-leave-active {
    transition: transform 0.3s ease-out;
}

.slide-enter-from {
    transform: translateX(100%);
}

.slide-leave-to {
    transform: translateX(100%);
}

/* Backdrop Fade Animation */
.fade-enter-active,
.fade-leave-active {
    transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
    opacity: 0;
}

/* Dropdown Menu Fade Scale Animation */
.fade-scale-enter-active,
.fade-scale-leave-active {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.fade-scale-enter-from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
}

.fade-scale-leave-to {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
}

/* Custom Scrollbar for Message List */
.overflow-y-auto::-webkit-scrollbar {
    width: 8px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Message Bubble Animations */
.message-enter-active {
    transition: all 0.3s ease-out;
}

.message-enter-from {
    opacity: 0;
    transform: translateY(10px);
}

/* Typing Indicator Animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* Online Status Pulse Animation */
@keyframes pulse-green {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.online-pulse {
    animation: pulse-green 2s ease-in-out infinite;
}

/* Unread Badge Pulse */
@keyframes pulse-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.unread-badge-pulse {
    animation: pulse-scale 1s ease-in-out infinite;
}

/* Message Status Icons */
.message-status {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Hover Effects for Conversation Items */
.conversation-item {
    transition: background-color 0.2s ease;
}

.conversation-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.conversation-item:active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Message Input Focus State */
.message-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Send Button Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.send-button:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: ripple 0.6s ease-out;
}

/* Loading Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Mobile Responsive Adjustments */
@media (max-width: 640px) {
    .chat-sidebar {
        width: 100%;
    }

    .message-bubble {
        max-width: 85%;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .chat-sidebar {
        background-color: #1f2937;
        color: #f9fafb;
    }

    .message-bubble.received {
        background-color: #374151;
        color: #f9fafb;
    }

    .message-input {
        background-color: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
}

/* Accessibility: Focus Visible */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .chat-sidebar {
        display: none;
    }
}

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: #fbbf24;
    color: #78350f;
    border-radius: 9999px;
    font-size: 0.875rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
}

.connection-status.connected {
    background: #10b981;
    color: white;
}

.connection-status.disconnected {
    background: #ef4444;
    color: white;
}

/* File Upload Preview */
.file-preview {
    position: relative;
    display: inline-block;
}

.file-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

/* Emoji Picker (Future Feature) */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Context Menu (Future Feature) */
.message-context-menu {
    position: absolute;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    min-width: 150px;
    z-index: 1000;
}

.message-context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-context-menu-item:hover {
    background-color: #f3f4f6;
}

/* Smooth Transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}
