/* public/css/messaging.css */

.messaging-layout {
    display: flex;
    height: calc(100vh - var(--topbar-height) - 1px);
    background: white;
    overflow: hidden;
    border-radius: 0;
}

/* Sidebar: Conversation List */
.msg-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-right: 1px solid var(--ui-border);
    display: flex;
    flex-direction: column;
    background: white;
    transition: transform var(--transition-smooth);
    z-index: 10;
}

.msg-sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--ui-border);
}

.msg-search-wrapper {
    position: relative;
    margin-top: 16px;
}

.msg-search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--ui-border);
    background: var(--ui-bg);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.msg-search-input:focus {
    border-color: var(--brand-primary);
    background: white;
    box-shadow: 0 0 0 3px var(--brand-primary-soft);
    outline: none;
}

.msg-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

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

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--ui-border-soft);
    position: relative;
}

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

.conv-item.active {
    background: #f0fdf4;
}

.conv-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--brand-primary);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.conv-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conv-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

.conv-unread {
    background: var(--brand-primary);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Main Chat Area */
.msg-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--msg-bg);
    position: relative;
    overflow: hidden;
}

.msg-main-header {
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

.back-to-list {
    display: none;
    margin-right: 12px;
    font-size: 20px;
    color: var(--text-main);
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-user-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
}

.chat-user-status {
    font-size: 12px;
    color: var(--brand-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 50vw;
}

.msg-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.msg-bubble {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    animation: fadeIn var(--transition-smooth);
    position: relative;
}

.msg-bubble.mine {
    align-self: flex-end;
}

.msg-bubble.theirs {
    align-self: flex-start;
}

.msg-text {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.msg-bubble.mine .msg-text {
    background: var(--brand-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.msg-bubble.theirs .msg-text {
    background: #f3f4f6;
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

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

.msg-bubble.mine .msg-time {
    text-align: right;
}

/* Chat Input Area */
.msg-input-area {
    padding: 24px;
    background: white;
    border-top: 1px solid var(--ui-border);
}

.msg-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--ui-bg);
    padding: 8px 8px 8px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--ui-border);
}

.msg-textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    outline: none;
}

.msg-send-btn {
    width: 44px;
    height: 44px;
    background: var(--brand-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-bounce);
}

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

/* Empty State */
.msg-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .msg-sidebar {
        position: absolute;
        width: 100%;
        height: 100%;
    }
    
    .msg-sidebar.hide-mobile {
        transform: translateX(-100%);
    }
    
    .msg-main {
        width: 100%;
    }
    
    .back-to-list {
        display: block;
    }
    
    .msg-bubble {
        max-width: 85%;
    }
}
