/* Messages Page Specific Styles */

/* Layout */
.main-content {
    height: calc(100vh - 76px);
    padding-bottom: 0;
}

@media (max-width: 767px) {
    .main-content {
        height: calc(100vh - 156px);
    }
}

/* Conversations Sidebar */
#conversationsSidebar {
    border-right: 1px solid var(--border);
}

@media (max-width: 767px) {
    #conversationsSidebar {
        display: none;
    }
    
    #conversationsSidebar.show {
        display: flex;
        position: fixed;
        top: 76px;
        left: 0;
        right: 0;
        bottom: 80px;
        z-index: 1000;
        background: white;
    }
}

/* Conversation Items */
.conversation-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

.conversation-item:hover {
    background-color: var(--light);
}

.conversation-item.active {
    background-color: rgba(111, 66, 193, 0.1);
    border-left: 3px solid var(--primary-purple);
}

.conversation-item:last-child {
    border-bottom: none;
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

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

.conversation-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--dark);
}

.conversation-preview {
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    text-align: right;
    min-width: 60px;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.unread-badge {
    background: var(--primary-purple);
    color: white;
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border: 2px solid white;
    border-radius: 50%;
}

/* Chat Area */
#activeChat {
    display: flex;
    flex-direction: column;
}

#messagesArea {
    background: #f8f9fa;
    position: relative;
}

#messagesList {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 1rem;
    animation: messageSlideIn 0.3s ease-out;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-blue) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: var(--dark);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-content {
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

.message-status {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
    text-align: right;
}

.message-status i {
    font-size: 0.875rem;
    vertical-align: middle;
}

/* Message Input */
#messageInput {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.75rem 1rem;
    resize: none;
    transition: all 0.3s ease;
}

#messageInput:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25);
}

#sendBtn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 60px;
    right: 60px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    z-index: 1000;
    max-width: 280px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.emoji-item {
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease;
}

.emoji-item:hover {
    background-color: var(--light);
}

/* Avatar Sizes */
.avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
}

.avatar-sm {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

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

/* Date Separator */
.date-separator {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
}

.date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.date-separator span {
    background: #f8f9fa;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

/* Message Attachments */
.message-attachment {
    margin-top: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
}

.message-attachment img {
    max-width: 100%;
    height: auto;
    display: block;
}

.message-attachment .file-info {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message.received .message-attachment .file-info {
    background: var(--light);
}

/* Search Highlight */
.search-highlight {
    background: yellow;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

/* Mobile Responsive */
@media (max-width: 767px) {
    .message-bubble {
        max-width: 85%;
    }
    
    #messageInput {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .emoji-picker {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    #messagesArea {
        background: #1a1a1a;
    }
    
    .message.received .message-bubble {
        background: #2d2d2d;
        color: white;
        border-color: #404040;
    }
    
    .typing-dots {
        background: #2d2d2d;
        border-color: #404040;
    }
    
    .emoji-picker {
        background: #2d2d2d;
        border-color: #404040;
    }
    
    .date-separator span {
        background: #1a1a1a;
    }
}

/* Accessibility */
.message-bubble:focus {
    outline: 2px solid var(--primary-purple);
    outline-offset: 2px;
}

.conversation-item:focus {
    outline: 2px solid var(--primary-purple);
    outline-offset: -2px;
}

/* Loading states */
.messages-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--text-muted);
}

.conversation-skeleton {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--light);
}

.skeleton-text {
    height: 1rem;
    background: var(--light);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.long {
    width: 80%;
}

