/* ===== CHAT STYLES ===== */

/* Скелетоны */
@keyframes chatShimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 400px 100%;
    animation: chatShimmer 1.5s infinite;
    flex-shrink: 0;
}

.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 400px 100%;
    animation: chatShimmer 1.5s infinite;
}

.skeleton-line-name {
    width: 60%;
    height: 14px;
}

.skeleton-line-preview {
    width: 80%;
}

.chat-skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #f8f8f8;
}

/* Overlay */
.chat-overlay { 
    position: fixed !important; 
    top: 0 !important; 
    left: 0 !important; 
    right: 0 !important; 
    bottom: 0 !important; 
    background: rgba(0,0,0,0.5) !important; 
    z-index: 5000 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
}

.chat-popup { 
    width: 90vw !important; 
    max-width: 900px !important; 
    height: 80vh !important; 
    max-height: 700px !important; 
    background: #fff !important; 
    border-radius: 20px !important; 
    display: flex !important; 
    overflow: hidden !important; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important; 
    position: relative !important; 
}

/* Сайдбар */
.chat-sidebar { 
    width: 340px !important; 
    background: #fff !important; 
    border-right: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    flex-direction: column !important; 
    flex-shrink: 0 !important; 
}

.chat-sidebar-header { 
    padding: 16px 20px !important; 
    border-bottom: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: space-between !important; 
    flex-shrink: 0 !important;
}

.chat-title-text { 
    font-weight: 600 !important; 
    font-size: 16px !important; 
    color: #1a1a1a !important; 
}

.chat-header-actions { 
    display: flex !important; 
    align-items: center !important; 
    gap: 8px !important; 
}

.chat-icon-btn { 
    width: 36px !important; 
    height: 36px !important; 
    border-radius: 10px !important; 
    background: transparent !important; 
    border: none !important; 
    cursor: pointer !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    transition: background 0.15s !important; 
    color: #666 !important; 
}

.chat-icon-btn:hover { background: #f5f5f5 !important; }

/* Вкладки */
.chat-tabs-vertical { 
    display: flex !important; 
    padding: 8px !important; 
    gap: 4px !important; 
    border-bottom: 1px solid #f0f0f0 !important; 
    flex-shrink: 0 !important;
}

.chat-tab-vertical { 
    flex: 1 !important; 
    padding: 10px 4px !important; 
    border-radius: 10px !important; 
    border: none !important; 
    background: transparent !important; 
    cursor: pointer !important; 
    display: flex !important; 
    flex-direction: column !important; 
    align-items: center !important; 
    gap: 4px !important; 
    transition: all 0.2s !important; 
    font-family: inherit !important; 
    color: #666 !important; 
    position: relative !important; 
}

.chat-tab-vertical:hover { background: #f5f5f5 !important; }
.chat-tab-vertical.active { background: #fdf2f5 !important; color: #dd1847 !important; }
.chat-tab-vertical.active .chat-tab-icon svg { stroke: #dd1847 !important; }

.chat-tab-icon { 
    width: 40px !important; 
    height: 40px !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    border-radius: 10px !important; 
    background: #f8f8f8 !important; 
}

.chat-tab-vertical.active .chat-tab-icon { background: #fdf2f5 !important; }

.chat-tab-label { 
    font-size: 11px !important; 
    font-weight: 500 !important; 
    text-align: center !important; 
}

.chat-tab-badge { 
    position: absolute !important; 
    top: 2px !important; 
    right: 2px !important; 
    min-width: 16px !important; 
    height: 16px !important; 
    border-radius: 8px !important; 
    background: #dd1847 !important; 
    color: #fff !important; 
    font-size: 9px !important; 
    font-weight: 700 !important; 
    text-align: center !important; 
    line-height: 16px !important; 
    padding: 0 4px !important; 
}

/* Список чатов */
.chat-list { 
    flex: 1 !important; 
    overflow-y: auto !important; 
    -webkit-overflow-scrolling: touch !important; 
}

.chat-item { 
    display: flex !important; 
    align-items: center !important; 
    gap: 12px !important; 
    padding: 14px 16px !important; 
    cursor: pointer !important; 
    border-bottom: 1px solid #f8f8f8 !important; 
    transition: background 0.15s !important; 
}

.chat-item:hover { background: #fdf2f5 !important; }
.chat-item.active { background: #fdf2f5 !important; }

.chat-avatar { 
    width: 44px !important; 
    height: 44px !important; 
    border-radius: 50% !important; 
    background: #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-shrink: 0 !important; 
    font-weight: 600 !important; 
    color: #dd1847 !important; 
    font-size: 16px !important; 
    overflow: hidden !important; 
}

.chat-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; }

.chat-info { flex: 1 !important; min-width: 0 !important; }

.chat-name { 
    font-size: 14px !important; 
    font-weight: 600 !important; 
    color: #1a1a1a !important; 
    white-space: nowrap !important; 
    overflow: hidden !important; 
    text-overflow: ellipsis !important; 
}

.chat-preview { 
    font-size: 12px !important; 
    color: #888 !important; 
    white-space: nowrap !important; 
    overflow: hidden !important; 
    text-overflow: ellipsis !important; 
    margin-top: 2px !important; 
}

.chat-meta { text-align: right !important; flex-shrink: 0 !important; }
.chat-time { font-size: 11px !important; color: #aaa !important; }

.chat-unread { 
    font-size: 11px !important; 
    background: #dd1847 !important; 
    color: #fff !important; 
    border-radius: 10px !important; 
    padding: 2px 7px !important; 
    margin-top: 4px !important; 
    display: inline-block !important; 
    font-weight: 600 !important; 
}

/* Основная область */
.chat-main { 
    flex: 1 !important; 
    display: flex !important; 
    flex-direction: column !important; 
    background: #fff !important; 
}

.chat-empty-state { 
    flex: 1 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-direction: column !important; 
    gap: 8px !important; 
    color: #999 !important; 
}

.chat-empty-text { font-size: 16px !important; font-weight: 500 !important; color: #1a1a1a !important; }

.chat-empty-subtext { 
    font-size: 13px !important; 
    color: #aaa !important; 
    cursor: pointer !important; 
    transition: color 0.2s !important; 
}

.chat-empty-subtext:hover { color: #dd1847 !important; }

/* Активный чат */
.chat-active-header { 
    padding: 16px 20px !important; 
    border-bottom: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    gap: 12px !important; 
    flex-shrink: 0 !important;
}

.chat-back-btn { 
    width: 36px !important; 
    height: 36px !important; 
    border-radius: 10px !important; 
    background: transparent !important; 
    border: none !important; 
    cursor: pointer !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    color: #666 !important; 
    transition: background 0.15s !important; 
    flex-shrink: 0 !important; 
}

.chat-back-btn:hover { background: #f5f5f5 !important; }

.chat-active-avatar { 
    width: 36px !important; 
    height: 36px !important; 
    border-radius: 50% !important; 
    background: #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-shrink: 0 !important; 
    overflow: hidden !important; 
    font-weight: 600 !important; 
    font-size: 14px !important; 
    color: #dd1847 !important; 
}

.chat-active-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; }

.chat-active-info { flex: 1 !important; min-width: 0 !important; }

.chat-active-title { 
    font-weight: 600 !important; 
    font-size: 15px !important; 
    color: #1a1a1a !important; 
    white-space: nowrap !important; 
    overflow: hidden !important; 
    text-overflow: ellipsis !important; 
}

.chat-active-status { font-size: 11px !important; color: #4caf50 !important; }
.chat-active-status.offline { color: #999 !important; }

/* Сообщения */
.chat-messages { 
    flex: 1 !important; 
    overflow-y: auto !important; 
    padding: 20px !important; 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 12px !important; 
    background: #f9fafb !important; 
    -webkit-overflow-scrolling: touch !important; 
}

.message-date-divider { text-align: center !important; font-size: 12px !important; color: #999 !important; margin: 8px 0 !important; }

.message-wrapper { display: flex !important; gap: 10px !important; align-items: flex-end !important; }
.message-wrapper.mine { justify-content: flex-end !important; }
.message-wrapper.other { justify-content: flex-start !important; }

.message-avatar { 
    width: 32px !important; 
    height: 32px !important; 
    border-radius: 50% !important; 
    background: #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-shrink: 0 !important; 
    overflow: hidden !important; 
    font-weight: 600 !important; 
    font-size: 12px !important; 
    color: #dd1847 !important; 
}

.message-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; }

.message { 
    max-width: 65% !important; 
    padding: 10px 14px !important; 
    border-radius: 16px !important; 
    font-size: 14px !important; 
    line-height: 1.5 !important; 
    word-wrap: break-word !important; 
}

.message.mine { 
    background: linear-gradient(135deg, #dd1847, #c1163d) !important; 
    color: #fff !important; 
    border-bottom-right-radius: 4px !important; 
}

.message.other { 
    background: #fff !important; 
    color: #1a1a1a !important; 
    border-bottom-left-radius: 4px !important; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important; 
}

.message-sender { font-size: 11px !important; font-weight: 600 !important; margin-bottom: 2px !important; color: #dd1847 !important; }
.message-time { font-size: 10px !important; opacity: 0.7 !important; margin-top: 4px !important; }
.mine .message-time { text-align: right !important; }
.other .message-time { text-align: left !important; }
.message-system { text-align: center !important; font-size: 12px !important; color: #999 !important; padding: 4px 0 !important; }

/* Поле ввода */
.chat-input-area { 
    padding: 12px 20px !important; 
    border-top: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    gap: 8px !important; 
    background: #fff !important; 
    align-items: flex-end !important; 
    flex-shrink: 0 !important;
}

.chat-input { 
    flex: 1 !important; 
    padding: 10px 16px !important; 
    border: 1px solid #e0e0e0 !important; 
    border-radius: 24px !important; 
    outline: none !important; 
    font-size: 14px !important; 
    font-family: inherit !important; 
    resize: none !important; 
    max-height: 100px !important; 
    min-height: 20px !important; 
    line-height: 1.4 !important; 
}

.chat-input:focus { border-color: #dd1847 !important; }

.chat-send-btn { 
    width: 40px !important; 
    height: 40px !important; 
    border-radius: 50% !important; 
    background: linear-gradient(135deg, #dd1847, #c1163d) !important; 
    border: none !important; 
    color: #fff !important; 
    cursor: pointer !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-shrink: 0 !important; 
    transition: transform 0.15s !important; 
}

.chat-send-btn:hover { transform: scale(1.05) !important; }
.chat-send-btn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; transform: none !important; }

/* Модалка нового чата */
.chat-new-modal { 
    position: absolute !important; 
    top: 0 !important; 
    left: 0 !important; 
    right: 0 !important; 
    bottom: 0 !important; 
    z-index: 10 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
}

.chat-new-overlay { 
    position: absolute !important; 
    top: 0 !important; 
    left: 0 !important; 
    right: 0 !important; 
    bottom: 0 !important; 
    background: rgba(0,0,0,0.3) !important; 
}

.chat-new-content { 
    position: relative !important; 
    width: 90% !important; 
    max-width: 440px !important; 
    max-height: 80% !important; 
    background: #fff !important; 
    border-radius: 20px !important; 
    overflow: hidden !important; 
    display: flex !important; 
    flex-direction: column !important; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.3) !important; 
}

.chat-new-header { 
    padding: 16px 20px !important; 
    border-bottom: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: space-between !important; 
}

.chat-new-title { font-weight: 600 !important; font-size: 16px !important; }

.chat-new-header button {
    background: none !important;
    border: none !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    color: #999 !important;
    font-size: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s !important;
}

.chat-new-header button:hover { background: #f5f5f5 !important; }

.chat-new-search { padding: 12px 16px !important; position: relative !important; border-bottom: 1px solid #f0f0f0 !important; }

.chat-new-search svg { 
    position: absolute !important; 
    left: 28px !important; 
    top: 50% !important; 
    transform: translateY(-50%) !important; 
    pointer-events: none !important; 
}

.chat-new-search input { 
    width: 100% !important; 
    padding: 10px 14px 10px 36px !important; 
    border: 1px solid #e0e0e0 !important; 
    border-radius: 12px !important; 
    font-size: 14px !important; 
    outline: none !important; 
    font-family: inherit !important; 
    box-sizing: border-box !important;
}

.chat-new-search input:focus { border-color: #dd1847 !important; }

.chat-new-type-select { display: flex !important; padding: 8px 16px !important; gap: 8px !important; }

.chat-type-btn { 
    flex: 1 !important; 
    padding: 8px !important; 
    border: 1px solid #e0e0e0 !important; 
    border-radius: 10px !important; 
    background: #fff !important; 
    cursor: pointer !important; 
    font-size: 13px !important; 
    font-weight: 500 !important; 
    transition: all 0.15s !important; 
    font-family: inherit !important; 
    color: #666 !important; 
}

.chat-type-btn.active { border-color: #dd1847 !important; background: #fdf2f5 !important; color: #dd1847 !important; }

.chat-new-contacts { 
    flex: 1 !important; 
    overflow-y: auto !important; 
    max-height: 300px !important; 
    -webkit-overflow-scrolling: touch !important; 
}

.chat-contact-item { 
    display: flex !important; 
    align-items: center !important; 
    gap: 12px !important; 
    padding: 12px 16px !important; 
    cursor: pointer !important; 
    transition: background 0.15s !important; 
}

.chat-contact-item:hover { background: #f5f5f5 !important; }

.chat-contact-avatar { 
    width: 44px !important; 
    height: 44px !important; 
    border-radius: 50% !important; 
    background: #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex-shrink: 0 !important; 
    font-weight: 600 !important; 
    color: #dd1847 !important; 
    font-size: 16px !important; 
    overflow: hidden !important; 
}

.chat-contact-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; }

.chat-contact-info { flex: 1 !important; min-width: 0 !important; }
.chat-contact-name { font-size: 14px !important; font-weight: 600 !important; }
.chat-contact-phone { font-size: 12px !important; color: #888 !important; }

.chat-contact-check { 
    width: 24px !important; 
    height: 24px !important; 
    border-radius: 50% !important; 
    border: 2px solid #ddd !important; 
    flex-shrink: 0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    transition: all 0.15s !important; 
}

.chat-contact-item.selected .chat-contact-check { 
    background: #dd1847 !important; 
    border-color: #dd1847 !important; 
}

.chat-contact-item.selected .chat-contact-check::after { 
    content: '✓' !important; 
    color: #fff !important; 
    font-size: 13px !important; 
    font-weight: 700 !important; 
}

.chat-new-group-name { padding: 8px 16px !important; }

.chat-new-group-name input {
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    outline: none !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
}

.chat-new-group-name input:focus { border-color: #dd1847 !important; }

.chat-new-footer { 
    padding: 12px 16px !important; 
    border-top: 1px solid #f0f0f0 !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: space-between !important; 
}

.chat-selected-count { font-size: 13px !important; color: #666 !important; }
.chat-selected-count strong { color: #dd1847 !important; }

.chat-create-btn { 
    padding: 10px 24px !important; 
    background: linear-gradient(135deg, #dd1847, #c1163d) !important; 
    color: #fff !important; 
    border: none !important; 
    border-radius: 12px !important; 
    font-size: 14px !important; 
    font-weight: 600 !important; 
    cursor: pointer !important; 
    transition: opacity 0.15s !important; 
    font-family: inherit !important; 
}

.chat-create-btn:disabled { opacity: 0.5 !important; cursor: not-allowed !important; }

/* Адаптив */
@media (max-width: 767px) {
    .chat-popup { 
        width: 100vw !important; 
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important; 
        flex-direction: column !important; 
    }
    
    .chat-sidebar { width: 100% !important; height: 100% !important; }
    
    .chat-main { 
        display: none !important; 
        position: absolute !important; 
        top: 0 !important; 
        left: 0 !important; 
        right: 0 !important; 
        bottom: 0 !important; 
        z-index: 5 !important; 
    }
    
    .chat-popup.show-chat .chat-sidebar { display: none !important; }
    .chat-popup.show-chat .chat-main { display: flex !important; }
    
    .chat-sidebar-header {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
    }
    
    .chat-active-header {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
    }
    
    .chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
    
    .chat-input { font-size: 16px !important; }
    .chat-new-search input { font-size: 16px !important; }
    .chat-tabs-vertical { padding: 6px !important; gap: 2px !important; }
    .chat-tab-vertical { padding: 8px 2px !important; }
    .chat-tab-label { font-size: 10px !important; }
    .chat-new-content { width: 95% !important; max-height: 90% !important; }
    .chat-messages { padding: 16px !important; }
    .message { max-width: 80% !important; }
    .message-avatar { width: 28px !important; height: 28px !important; font-size: 10px !important; }
}