/**
 * Messages/Chat Page Styles
 */

/* Messages Container */
.messages-container {
    max-width: 1200px;
    margin: 0 auto;
    height: calc(100vh - 48px);
    display: grid;
    grid-template-columns: 320px 1fr;
    background-color: var(--bg-secondary);
    overflow: hidden;
}

/* Conversations Sidebar */
.conversations-sidebar {
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

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

.conversations-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

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

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

.new-message-btn img {
    width: 18px;
    height: 18px;
}

.conversations-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.conversations-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.conversations-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
    position: relative;
}

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

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

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

.conversation-content {
    display: flex;
    gap: 12px;
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

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

.conversation-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.conversation-time {
    font-size: 12px;
    color: var(--text-muted);
}

.conversation-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.unread-badge {
    position: absolute;
    top: 12px;
    right: 16px;
    background-color: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

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

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

.chat-back-btn {
    display: none;
}

.chat-back-btn.mobile-only {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-right: 8px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
@media (max-width: 1024px) {
    .chat-user-info {
        margin-left: -25%;
    }
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    overflow: hidden;
    position: relative;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.chat-username {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-actions button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.chat-actions button:hover {
    opacity: 1;
}

.chat-actions img {
    width: 20px;
    height: 20px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 24px;
    background-color: var(--bg-secondary);
}

.message-group {
    margin-bottom: 24px;
}

.message-date-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.message-item {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-bottom: 12px;
    width: 100%;
}

.message-item.own {
    justify-content: flex-end;
    padding-left: 20px;
}

.message-item:not(.own) {
    justify-content: flex-start;
    padding-right: 20px;
}

.message-avatar {
    display: none;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-item.own .message-content {
    align-items: flex-end;
}

.message-bubble {
    background-color: lightgray;
    padding: 10px 16px;
    border-radius: 7px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
}

.message-item.own .message-bubble {
    background-color: var(--primary-color);
    color: white;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-input-area {
    padding: 4px;
    background-color: var(--bg-primary);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 60px;
}

.chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.send-message-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.send-message-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-message-btn img {
    width: 20px;
    height: 20px;
}

/* Empty State */
.messages-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px;
    text-align: center;
}

.messages-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.messages-empty-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.messages-empty-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .messages-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 56px);
    }

    /* Show conversations list by default, hide chat */
    .conversations-sidebar {
        display: flex;
    }

    .chat-area {
        display: none;
    }

    /* When viewing a conversation, hide list and show chat */
    .messages-container.chat-open .conversations-sidebar {
        display: none;
    }

    .messages-container.chat-open .chat-area {
        display: flex;
    }

    /* Show back button on mobile */
    .chat-back-btn.mobile-only {
        display: block !important;
    }

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

    .message-item.own {
        padding-left: 10px;
    }

    .message-item:not(.own) {
        padding-right: 10px;
    }

    /* Fix avatar sizing */
    .conversation-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .chat-avatar img,
    .conversation-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Increase touch targets */
    .conversation-item {
        padding: 16px;
    }

    .send-message-btn {
        width: 40px;
        height: 40px;    }

    .chat-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Notification Badge Styles */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    line-height: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-icon-btn {
    position: relative;
}

.bottom-nav-icon-wrapper {
    position: relative;
    display: inline-block;
}

.bottom-nav-item .notification-badge {
    top: -6px;
    right: -6px;
}