/* ===== Чат поддержки (витрина + админка). Подключается точечно на страницах
   чата, чтобы не смешиваться с общим стилем витрины и со стилями sqladmin. ===== */

/* --- Пузыри сообщений (общие для обеих сторон) --- */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}
.chat-row { display: flex; width: 100%; }
.chat-self { justify-content: flex-end; }
.chat-other { justify-content: flex-start; }

.chat-bubble {
    max-width: min(78%, 560px);
    padding: 8px 12px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
}
.bubble-self { background: #dcfce7; border-bottom-right-radius: 4px; }
.bubble-other { background: #ffffff; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }

.chat-meta {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
}
.chat-sender { font-weight: 700; color: #047857; }
.chat-text { white-space: pre-wrap; font-size: 15px; line-height: 1.4; color: #111827; }

.chat-attach-img {
    display: block;
    max-width: 260px;
    max-height: 260px;
    border-radius: 10px;
    margin-top: 6px;
    object-fit: cover;
}
.chat-attach-file {
    display: inline-block;
    margin-top: 6px;
    color: #047857;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.chat-attach-file:hover { text-decoration: underline; }
.chat-error { color: #ef4444; font-weight: 600; padding: 8px; }

/* ===== Страница чата на витрине ===== */
.support-wrap {
    max-width: 760px;
    margin: 24px auto;
    padding: 0 16px;
}
.support-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}
.support-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.support-title { font-size: 20px; margin: 0; color: #065f46; }
.support-who { font-size: 13px; color: #4b5563; }
.support-who a { color: #047857; font-weight: 600; }

.support-page .chat-messages {
    height: 52vh;
    min-height: 280px;
    background: #eef2f7;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.chat-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.chat-file-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    user-select: none;
}
.chat-file-btn:hover { background: #f3f4f6; }
.chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
}
.chat-input:focus { outline: none; border-color: #047857; box-shadow: 0 0 0 2px rgba(4, 120, 87, 0.15); }
.chat-send {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: #047857;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.chat-send:hover { background: #065f46; }
.chat-send:disabled { opacity: 0.6; cursor: default; }

.chat-file-name { font-size: 13px; color: #4b5563; margin: 6px 2px 0; min-height: 16px; }

.support-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.chat-reset {
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}
.chat-reset:hover { background: #f3f4f6; }
.chat-hint { font-size: 12px; color: #9ca3af; }

/* ===== Консоль чата в админке ===== */
.admin-chat-messages {
    height: 56vh;
    min-height: 320px;
    background: #eef2f7;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.admin-chat-messages .bubble-other { background: #ffffff; }

/* --- Адаптив: форма ответа (витрина и админка) на узких экранах ---
   Поле ввода переносится на всю ширину первой строкой, а 📎 и «Отправить»
   становятся второй строкой — иначе три элемента не умещаются в одну строку. */
@media (max-width: 576px) {
    .chat-form {
        flex-wrap: wrap;
    }
    .chat-form .chat-input {
        order: -1;
        flex: 1 1 100%;
    }
    .chat-form .chat-send {
        flex: 1;
    }
}
