/**
 * Стили для системы личных сообщений Breedbase
 * 
 * @file assets/css/messages.css
 */

/* ================================================================
   СПИСОК ДИАЛОГОВ
   ================================================================ */

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.message-thread-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.message-thread-card:hover {
    border-color: #1e5a8e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.message-thread-card.unread {
    background: #f8fafc;
    border-left: 4px solid #1e5a8e;
}

.message-thread-card__avatar {
    flex-shrink: 0;
}

.message-thread-card__body {
    flex: 1;
    min-width: 0;
}

.message-thread-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.message-thread-card__name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
}

.message-thread-card.unread .message-thread-card__name {
    font-weight: 700;
}

.message-thread-card__time {
    font-size: 0.875rem;
    color: #64748b;
    white-space: nowrap;
}

.message-thread-card__preview {
    margin: 0;
    color: #64748b;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-thread-card.unread .message-thread-card__preview {
    color: #334155;
    font-weight: 500;
}

.message-thread-card__badge {
    flex-shrink: 0;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: #1e5a8e;
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================================================
   СТРАНИЦА ПЕРЕПИСКИ
   ================================================================ */

.messages-chat {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* ШАПКА — Вариант A: [←] [👤] [Имя / подпись] → → → [Кнопка] */
.messages-chat__header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    min-height: 64px;
}

.messages-chat__header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.messages-chat__header-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.messages-chat__header-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-chat__header-sub {
    font-size: 0.78rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-chat__header-actions {
    flex-shrink: 0;
}

.messages-context {
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border-bottom: 1px solid #fbbf24;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.messages-context__icon {
    color: #f59e0b;
    font-size: 1.25rem;
}

.messages-context__body {
    font-size: 0.9rem;
    color: #78350f;
}

.messages-context__body a {
    color: #1e5a8e;
    font-weight: 600;
}

.messages-chat__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f8fafc;
}

.messages-chat__footer {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

/* ================================================================
   ПУЗЫРИ СООБЩЕНИЙ
   ================================================================ */

.message-bubble {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    margin-bottom: 1rem;
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bubble--own {
    align-self: flex-end;
    align-items: flex-end;
}

.message-bubble__sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.25rem;
    padding: 0 0.75rem;
}

.message-bubble__text {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: white;
    color: #1e293b;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-bubble--own .message-bubble__text {
    background: #1e5a8e;
    color: white;
}

.message-bubble__footer {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding: 0 0.75rem;
}

.message-bubble__time {
    font-size: 0.7rem;
    color: #94a3b8;
}

.message-bubble__status {
    font-size: 0.7rem;
    color: #94a3b8;
    letter-spacing: -2px;
}

.message-bubble__status--read {
    color: #1e5a8e;
}

/* ================================================================
   ФОРМА ОТПРАВКИ
   ================================================================ */

#message-input {
    resize: none;
    border-radius: 8px;
}

#message-input:focus {
    border-color: #1e5a8e;
    box-shadow: 0 0 0 0.2rem rgba(30, 90, 142, 0.25);
}

#send-button {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    white-space: nowrap;
}

#error-message {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ================================================================
   СИСТЕМНЫЙ НОТИС БЕЗОПАСНОСТИ
   ================================================================ */

.messages-safety-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    flex-shrink: 0;
}

.messages-safety-notice.is-hidden {
    display: none;
}

.messages-safety-notice__icon {
    color: #2563eb;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.messages-safety-notice__text {
    flex: 1;
    font-size: 0.82rem;
    color: #1e3a5f;
    line-height: 1.5;
}

.messages-safety-notice__text strong {
    color: #1d4ed8;
}

.messages-safety-notice__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #60a5fa;
    font-size: 0.85rem;
    line-height: 1;
    margin-top: 2px;
    transition: color 0.2s;
}

.messages-safety-notice__close:hover {
    color: #1d4ed8;
}

/* ================================================================
   АДАПТИВНОСТЬ
   ================================================================ */

@media (max-width: 768px) {
    .messages-chat {
        height: calc(100vh - 150px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .message-thread-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .message-thread-card__name {
        font-size: 1rem;
    }

    .message-thread-card__preview {
        font-size: 0.85rem;
    }

    .message-bubble {
        max-width: 85%;
    }

    .messages-chat__body {
        padding: 1rem;
    }

    .messages-chat__footer {
        padding: 0.75rem;
    }

    #send-button span {
        display: none !important;
    }

    .messages-safety-notice {
        padding: 0.6rem 0.75rem;
    }

    .messages-safety-notice__text {
        font-size: 0.78rem;
    }
}

@media (max-width: 576px) {
    /* На маленьких экранах текст кнопки блокировки скрывается */
    .messages-chat__header-actions .btn span {
        display: none;
    }
}

/* ================================================================
   ЗНАЧОК НЕПРОЧИТАННЫХ В ШАПКЕ САЙТА
   ================================================================ */

.bb-topbar__messages {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.bb-topbar__messages-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: white;
    border-radius: 9px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* ================================================================
   СОСТОЯНИЯ ЗАГРУЗКИ
   ================================================================ */

.messages-loading {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.messages-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================================
   СКРОЛЛ
   ================================================================ */

.messages-chat__body::-webkit-scrollbar {
    width: 8px;
}

.messages-chat__body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.messages-chat__body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.messages-chat__body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
