/* ============ CHAT LIST PAGE ============ */
.chat-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

.chat-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chat-page-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.chat-page-badge {
    background: #FF4053;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
}

/* Поиск */
.chat-search-wrap {
    position: relative;
    margin-bottom: 12px;
}
.chat-search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
}
.chat-search-input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.chat-search-input:focus {
    outline: none;
    border-color: #00AAFF;
}

/* Фильтры */
.chat-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}
.chat-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.chat-filter-tab:hover { color: #00AAFF; text-decoration: none; }
.chat-filter-tab.active { color: #00AAFF; border-bottom-color: #00AAFF; }
.chat-filter-count {
    background: #FF4053;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

/* Список */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-list-item {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: #fff;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.chat-list-item:hover {
    background: #f8f8f8;
    text-decoration: none;
    color: inherit;
}
.chat-list-item.unread {
    background: #f5f9ff;
}
.chat-list-item.unread:hover {
    background: #eaf4ff;
}

.chat-list-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-list-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #FFC107;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px; font-weight: 700; color: #1a1a1a;
}
.chat-list-avatar img { width: 100%; height: 100%; object-fit: cover; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00C853;
    flex-shrink: 0;
}
.status-dot-avatar {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    box-sizing: content-box;
}

.chat-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-list-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.chat-list-name {
    font-size: 15px; font-weight: 700; color: #1a1a1a;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-list-time {
    font-size: 12px; color: #999; flex-shrink: 0;
}

.chat-list-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.chat-list-preview {
    font-size: 13px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.chat-list-preview b { color: #1a1a1a; }

.chat-list-unread {
    background: #00AAFF;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.chat-list-ad {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-list-ad i { margin-right: 4px; }

/* Пустое состояние */
.chat-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}
.chat-empty i { font-size: 64px; color: #ddd; }
.chat-empty h3 {
    font-size: 18px; color: #666;
    margin: 20px 0 8px;
}
.chat-empty p { font-size: 14px; margin: 0; }

/* ============ CHAT DETAIL ============ */
.chat-detail-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    max-width: 800px;
    margin: 24px auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.chat-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
}
.chat-detail-back {
    color: #1a1a1a;
    font-size: 20px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}
.chat-detail-back:hover {
    color: #00AAFF;
    background: #f0f8ff;
    text-decoration: none;
}

.chat-detail-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    overflow: hidden; flex-shrink: 0;
    background: #FFC107;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #1a1a1a;
}
.chat-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-detail-info { flex: 1; min-width: 0; }
.chat-detail-name {
    font-size: 15px; font-weight: 700; color: #1a1a1a;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-detail-status {
    font-size: 12px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.chat-detail-status-online {
    color: #00A046;
    font-weight: 600;
}
.chat-detail-ad {
    font-size: 12px; color: #999;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-detail-ad i { margin-right: 4px; }

.chat-detail-ad-link {
    color: #666;
    font-size: 18px;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.chat-detail-ad-link:hover {
    color: #00AAFF;
    background: #f0f8ff;
}

.chat-detail-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* ============ ПУЗЫРИ ============ */
.chat-bubble {
    max-width: 75%;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.35;
    word-wrap: break-word;
    white-space: pre-wrap;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}
.chat-bubble.sent {
    background: #00AAFF;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-bubble.received {
    background: #fff;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.chat-bubble-text {
    word-wrap: break-word;
    white-space: pre-wrap;
    flex: 1 1 auto;
    min-width: 0;
}

.chat-bubble-time {
    font-size: 11px;
    opacity: 0.7;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 1px;
}
.chat-bubble.sent .chat-bubble-time { color: rgba(255,255,255,0.85); }
.chat-bubble.received .chat-bubble-time { color: #999; }

.chat-bubble-check {
    margin-left: 3px;
    font-size: 12px;
    vertical-align: middle;
    display: inline-block;
}
.chat-bubble.sent .chat-bubble-check {
    color: rgba(255, 255, 255, 0.9);
}
.chat-bubble.sent[data-is-read="1"] .chat-bubble-check {
    color: #fff;
}

/* ============ ВВОД ============ */
.chat-detail-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    align-items: flex-end;
}
.chat-input-field {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    box-sizing: border-box;
    line-height: 1.4;
}
.chat-input-field:focus {
    outline: none;
    border-color: #00AAFF;
}
.chat-send-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #00AAFF;
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}
.chat-send-btn:hover { background: #0088cc; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 768px) {
    .chat-detail-page {
        height: calc(100vh - 140px);
        margin: 0;
        border-radius: 0;
    }
    .chat-bubble { max-width: 85%; }
}