/* ============================================================
   MESSAGES PAGE STYLES
   ============================================================ */

.messages-page {
    padding-top: 64px;
    height: 100vh;
    overflow: hidden;
}

.messages-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 64px);
}

/* Conversations Sidebar */
.conversations-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    border-bottom: 1px solid var(--border);
}

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

.conversation-item.active {
    background: var(--accent-light);
}

.conversation-item.unread {
    background: rgba(15, 118, 110, 0.05);
}

.conversation-item.unread .conversation-name {
    font-weight: 600;
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

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

.conversation-avatar span {
    color: white;
    font-weight: 600;
    font-size: 1.125rem;
}

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

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

.conversation-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--text-3);
    flex-shrink: 0;
}

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

.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.empty-conversations {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-conversations p {
    color: var(--text-2);
    margin-bottom: 1rem;
}

/* Chat Area */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-2);
}

.no-chat-selected svg {
    width: 64px;
    height: 64px;
    color: var(--text-3);
    margin-bottom: 1rem;
}

.no-chat-selected h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.back-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius);
}

.back-btn:hover {
    background: var(--bg);
}

.back-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-2);
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 0.8125rem;
    color: var(--text-2);
}

.chat-product-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.chat-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-content {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    line-height: 1.5;
}

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

.message.received .message-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-meta {
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 0.25rem;
}

.message.sent .message-time {
    text-align: right;
}

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

.chat-input textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font: inherit;
    font-size: 0.9375rem;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
}

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

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

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

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

    .conversations-sidebar {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
    }

    .chat-area {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 20;
    }

    .messages-layout.chat-open .chat-area {
        transform: translateX(0);
    }

    .back-btn {
        display: flex;
    }

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

/* Header Override */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-greeting {
    color: var(--text-2);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
}
