/**
 * Messages — Styles pour la messagerie BookConnect
 */

/* Layout principal */
.messages-layout {
    height: calc(100vh - 80px);
    min-height: 500px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

/* Sidebar conversations */
.messages-sidebar {
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f8f9fa;
}

.messages-sidebar-header {
    background: #fff;
    flex-shrink: 0;
}

.messages-search {
    flex-shrink: 0;
    background: #fff;
}

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

/* Conversation item */
.conversation-item {
    border-bottom: 1px solid #eee;
    transition: background-color 0.15s ease;
    color: inherit;
}

.conversation-item:hover {
    background-color: #e9ecef;
    color: inherit;
}

.conversation-item.conversation-active {
    background-color: #e2e6ea;
    border-left: 3px solid #0d6efd;
}

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

.conversation-item.conversation-unread .conversation-preview {
    color: #333 !important;
    font-weight: 500;
}

.conversation-avatar img {
    object-fit: cover;
    border: 2px solid #e9ecef;
}

.conversation-name {
    font-size: 0.95rem;
    color: #212529;
}

.conversation-time {
    font-size: 0.75rem;
    white-space: nowrap;
}

.conversation-preview {
    font-size: 0.85rem;
    line-height: 1.3;
}

/* Zone principale */
.messages-main {
    height: 100%;
    background: #fff;
}

/* Header conversation */
.conversation-header {
    flex-shrink: 0;
    background: #fff;
    z-index: 1;
}

.conversation-header img {
    object-fit: cover;
    border: 2px solid #e9ecef;
}

/* Zone des messages */
.messages-container {
    overflow-y: auto;
    overflow-x: hidden;
    background: #f0f2f5;
    scroll-behavior: smooth;
}

/* Message bubbles */
.message-bubble {
    display: flex;
    align-items: flex-end;
    margin-bottom: 12px;
    max-width: 75%;
    gap: 8px;
}

.message-bubble.message-mine {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-bubble.message-other {
    margin-right: auto;
}

.message-avatar img {
    object-fit: cover;
    flex-shrink: 0;
}

.message-content {
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-mine .message-content {
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-other .message-content {
    background: #fff;
    color: #212529;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message-sender {
    color: #6c757d;
    font-size: 0.78rem;
}

.message-text {
    font-size: 0.925rem;
    line-height: 1.45;
}

.message-time {
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: right;
}

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

.message-other .message-time {
    color: #adb5bd;
}

/* Zone de saisie */
.message-input-area {
    flex-shrink: 0;
    background: #fff;
}

.message-input-area textarea {
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.925rem;
    line-height: 1.4;
    transition: box-shadow 0.15s;
}

.message-input-area textarea:focus {
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
}

.message-input-area .btn-primary {
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Badge non lu */
.badge.bg-primary.rounded-pill {
    font-size: 0.7rem;
    min-width: 20px;
}

/* Responsive */
@media (max-width: 767.98px) {
    .messages-layout {
        height: calc(100vh - 60px);
        border: none;
        border-radius: 0;
    }

    .message-bubble {
        max-width: 88%;
    }
}

@media (min-width: 768px) {
    .messages-sidebar {
        max-height: 100%;
    }
}

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

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

.conversations-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
