/* ===== CHAT ===== */
.stb-view--chat { max-width: 760px; }
.stb-view--chat.is-active {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100dvh; /* десктоп: sidebar слева не занимает высоту */
}

@media (max-width: 768px) {
    .stb-view--chat.is-active {
        height: calc(100dvh - 64px); /* минус нижний таб-бар (та же высота, что в styles.css) */
    }
}

.stb-chat-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* без этого flex-ребёнок не сожмётся и внутренний скролл не заработает */
    background: #fff;
    border-radius: 20px;
    border: 1px solid #f0f0f5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.stb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
}

.stb-chat-day-divider {
    display: flex;
    justify-content: center;
    margin: 6px 0 2px;
}
.stb-chat-day-divider span {
    background: rgba(0, 0, 0, 0.07);
    color: #888;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 100px;
}

.stb-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 75%;
    align-self: flex-start;
}

.stb-chat-msg--me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.stb-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stb-chat-bubble {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f5;
}

.stb-chat-msg--me .stb-chat-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
}

.stb-chat-meta {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 12px;
    margin-bottom: 3px;
}

.stb-chat-name {
    font-weight: 700;
    color: #667eea;
}

.stb-chat-msg--me .stb-chat-name { color: rgba(255, 255, 255, 0.85); }

.stb-chat-time {
    color: #999;
}

.stb-chat-msg--me .stb-chat-time { color: rgba(255, 255, 255, 0.65); }

.stb-chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.stb-chat-form {
    display: flex;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border-top: 1px solid #f0f0f5;
}

.stb-chat-form textarea {
    flex: 1;
    resize: none;
    border: 2px solid #e8e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.stb-chat-form textarea:focus {
    outline: none;
    border-color: #667eea;
}

.stb-chat-form button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stb-chat-form button:hover {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.stb-chat-delete-btn {
    display: none;
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
    color: #c0392b;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Показываем только там, где есть настоящая наводка мышью — на телефоне удаление через долгий тап */
@media (hover: hover) {
    .stb-chat-msg:hover .stb-chat-delete-btn { display: flex; }
}

.stb-chat-msg--deleted .stb-chat-text { font-style: italic; color: #8a8a94; }
.stb-chat-msg--deleted .stb-chat-bubble { background: #ececf1; border-color: #e0e0e8; }
.stb-chat-msg--me.stb-chat-msg--deleted .stb-chat-bubble {
    background: #ececf1;
    border: 1px solid #e0e0e8;
}
.stb-chat-msg--me.stb-chat-msg--deleted .stb-chat-name,
.stb-chat-msg--me.stb-chat-msg--deleted .stb-chat-time,
.stb-chat-msg--me.stb-chat-msg--deleted .stb-chat-text {
    color: #8a8a94;
}

@media (max-width: 768px) {
    .stb-chat-msg { max-width: 88%; }
}
