/* Messages Page Styles */
.messages-page-content {
    padding: 0;
    height: calc(100vh - 70px);
}

.messages-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100%;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Messages Sidebar */
.messages-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.messages-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.btn-new-message {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-new-message:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Message Filters */
.message-filters {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.filter-tab {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: all 0.3s;
}

.filter-tab:hover {
    background: var(--bg-tertiary);
}

.filter-tab.active {
    background: var(--primary-light);
    color: var(--primary-color);
}

.filter-tab .count {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.625rem;
}

.filter-tab.active .count {
    background: var(--primary-color);
    color: white;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.active {
    background: var(--bg-primary);
    border-left-color: var(--primary-color);
}

.conversation-item.unread .last-message {
    font-weight: 600;
    color: var(--text-primary);
}

.conversation-avatar {
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.conversation-avatar.group {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.status-dot.online {
    background: var(--success-color);
}

.status-dot.away {
    background: var(--warning-color);
}

.status-dot.offline {
    background: var(--text-tertiary);
}

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

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.conversation-header h4 {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin: 0;
}

.time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.last-message {
    font-size: 0.813rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-new {
    background: var(--danger-color);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
}

.unread-count {
    background: var(--primary-color);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.625rem;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.starred {
    color: var(--warning-color);
}

/* Chat Area */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.chat-user-info h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.chat-user-info .status {
    font-size: 0.75rem;
    color: var(--success-color);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-actions .icon-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-actions .icon-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-tertiary);
}

.message-date {
    text-align: center;
    margin: 1.5rem 0;
}

.message-date span {
    background: var(--bg-primary);
    padding: 0.375rem 1rem;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: messageSlide 0.3s ease;
}

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

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

.message img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    max-width: 60%;
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.message.sent .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-time {
    display: block;
    font-size: 0.625rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Message Attachment */
.message-attachment {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.message-attachment i {
    font-size: 1.5rem;
    color: var(--danger-color);
}

.message-attachment div {
    flex: 1;
}

.message-attachment p {
    font-weight: 500;
    margin: 0;
}

.message-attachment span {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.btn-download {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-download:hover {
    background: var(--primary-dark);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.typing-indicator img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite;
}

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

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

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.btn-attach,
.btn-emoji {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1.125rem;
}

.btn-attach:hover,
.btn-emoji:hover {
    color: var(--primary-color);
}

#messageInput {
    flex: 1;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s;
}

#messageInput:focus {
    border-color: var(--primary-color);
}

.btn-send {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Scrollbar Styling */
.conversations-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Dark Theme */
body.dark-theme .messages-sidebar {
    background: var(--bg-secondary);
}

body.dark-theme .conversation-item.active {
    background: var(--bg-tertiary);
}

body.dark-theme .chat-messages {
    background: var(--bg-secondary);
}

body.dark-theme .message-content {
    background: var(--bg-tertiary);
}

body.dark-theme .message-attachment {
    background: var(--bg-primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .messages-container {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 768px) {
    .messages-page-content {
        padding: 0;
    }
    
    .messages-container {
        grid-template-columns: 1fr;
        position: relative;
    }
    
    .messages-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: 10;
        transition: transform 0.3s;
    }
    
    .messages-sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .chat-area {
        display: flex;
    }
    
    .chat-header {
        padding-left: 3.5rem;
    }
    
    .chat-header::before {
        content: '\f104';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        position: absolute;
        left: 1rem;
        font-size: 1.25rem;
        color: var(--primary-color);
        cursor: pointer;
    }
    
    .message-content {
        max-width: 75%;
    }
}

@media (max-width: 480px) {
    .conversation-item {
        padding: 0.75rem 1rem;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .btn-attach,
    .btn-emoji {
        width: 32px;
        height: 32px;
    }
    
    .btn-send {
        width: 32px;
        height: 32px;
    }
}