

/* ============ УЛУЧШЕННЫЕ СТИЛИ ЧАТОВ И ДИСПУТОВ ============ */

/* Модальное окно чата/диспута */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    display: none;
    z-index: 10000;
    animation: modalFadeIn 0.3s ease;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.chat-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes modalFadeIn {
    from { 
        opacity: 0; 
        backdrop-filter: blur(0px);
    }
    to { 
        opacity: 1; 
        backdrop-filter: blur(12px);
    }
}

.chat-modal .modal-content {
    width: 95%;
    max-width: 900px;
    height: 92vh;
    max-height: 850px;
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(110, 69, 226, 0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: translateY(30px) scale(0.98);
    animation: slideUpScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideUpScale {
    to { 
        transform: translateY(0) scale(1); 
    }
}

/* Контейнер чата */
.chat-view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

/* Шапка чата */
.chat-header {
    padding: 20px 24px;
    background: linear-gradient(90deg, 
        rgba(30, 30, 60, 0.98) 0%, 
        rgba(46, 16, 81, 0.98) 100%);
    border-bottom: 1px solid rgba(110, 69, 226, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.chat-partner-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.chat-partner-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 19px;
    box-shadow: 0 6px 20px rgba(110, 69, 226, 0.5);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-partner-avatar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: avatarShine 3s infinite;
}

@keyframes avatarShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.chat-partner-details {
    flex: 1;
    min-width: 0;
}

.chat-partner-name {
    font-weight: 700;
    font-size: 17px;
    color: #ffffff;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chat-partner-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.chat-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.chat-status-dot.open {
    background: linear-gradient(135deg, #28a745, #34ce57);
    box-shadow: 0 0 12px rgba(40, 167, 69, 0.5);
    animation: statusPulse 2s infinite;
}

.chat-status-dot.closed {
    background: linear-gradient(135deg, #dc3545, #e05666);
    box-shadow: 0 0 12px rgba(220, 53, 69, 0.5);
}

.chat-status-dot.priority {
    background: linear-gradient(135deg, #ffc107, #ffd54f);
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Блок закрытого диспута */
.dispute-resolution-info {
    background: linear-gradient(135deg, rgba(46, 16, 81, 0.9), rgba(94, 53, 177, 0.7));
    padding: 16px 20px;
    border-radius: 12px;
    margin: 16px 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: resolutionAppear 0.5s ease-out;
}

@keyframes resolutionAppear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resolution-text {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
}

.resolution-text i {
    font-size: 20px;
}

.resolution-text.buyer-won {
    color: #f44336;
}

.resolution-text.shop-won {
    color: #4caf50;
}

.chat-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.action-btn {
    padding: 11px 20px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.7s;
}

.action-btn:hover::before {
    left: 100%;
}

.close-chat-btn {
    background: linear-gradient(135deg, #dc3545, #e05666);
    color: white;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
}

.close-chat-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(220, 53, 69, 0.6);
}

.resolve-dispute-btn {
    background: linear-gradient(135deg, #28a745, #34ce57);
    color: white;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.reject-dispute-btn {
    background: linear-gradient(135deg, #ffc107, #ffd54f);
    color: #1a1a2e;
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
}

.resolve-dispute-btn:hover:not(:disabled),
.reject-dispute-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Контейнер сообщений - ИСПРАВЛЕНО ДЛЯ СКРОЛЛА */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: 
        radial-gradient(ellipse at top, rgba(22, 33, 62, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse at bottom, rgba(26, 26, 46, 0.4) 0%, transparent 70%),
        linear-gradient(180deg, rgba(10, 15, 35, 0.3) 0%, rgba(15, 20, 45, 0.2) 100%);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    height: 100%;
}

/* Фикс для скролла на iOS */
.chat-messages-container {
    overscroll-behavior: contain;
}

/* Скроллбар для контейнера сообщений */
.chat-messages-container::-webkit-scrollbar {
    width: 10px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    margin: 4px 0;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--primary), var(--secondary));
    border-radius: 6px;
    border: 2px solid rgba(26, 26, 46, 0.8);
    transition: all 0.3s;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(var(--secondary), var(--primary));
    border: 2px solid rgba(110, 69, 226, 0.5);
}

.chat-messages-container::-webkit-scrollbar-corner {
    background: transparent;
}

/* Сообщения */
.message {
    max-width: 78%;
    padding: 16px 20px;
    border-radius: 20px;
    position: relative;
    animation: messageAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    backdrop-filter: blur(5px);
    margin-bottom: 4px;
    min-width: 120px;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    align-self: flex-start;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.12), 
        rgba(255, 255, 255, 0.07));
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-bottom-left-radius: 6px;
    margin-right: auto;
}

.admin-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), #8a63e6);
    color: white;
    border-bottom-right-radius: 6px;
    border: 1px solid rgba(110, 69, 226, 0.5);
    margin-left: auto;
}

.message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}

.message-sender {
    font-weight: 700;
    opacity: 0.95;
    color: inherit;
}

.message-time {
    opacity: 0.75;
    font-size: 12px;
    font-weight: 500;
}

.user-message .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.admin-message .message-time {
    color: rgba(255, 255, 255, 0.9);
}

.message-content {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 10px;
}

.user-message .message-content {
    color: rgba(255, 255, 255, 0.98);
}

.admin-message .message-content {
    color: white;
}

/* Информация о диспуте */
.dispute-order-info {
    padding: 22px 24px;
    background: linear-gradient(135deg, 
        rgba(46, 16, 81, 0.85), 
        rgba(94, 53, 177, 0.65));
    border-bottom: 1px solid rgba(94, 53, 177, 0.4);
    backdrop-filter: blur(8px);
    animation: slideDown 0.4s ease-out;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.dispute-order-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.order-summary,
.product-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    padding: 14px;
    background: rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    overflow: hidden;
}

.summary-item:hover {
    background: rgba(255, 255, 255, 0.13);
    transform: translateY(-3px);
    border-color: rgba(110, 69, 226, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.summary-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.summary-value {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: rgba(0, 0, 0, 0.2);
}

.summary-value:hover {
    background: rgba(179, 136, 255, 0.2);
    padding-left: 12px;
}

.summary-value.copied {
    background: rgba(76, 175, 80, 0.25);
    color: #4caf50;
    animation: copiedPulse 0.6s ease;
}

@keyframes copiedPulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
}

/* Поле ввода сообщения */
.chat-input-container {
    padding: 22px 24px;
    background: rgba(30, 30, 60, 0.95);
    border-top: 1px solid rgba(110, 69, 226, 0.3);
    backdrop-filter: blur(15px);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(110, 69, 226, 0.5), transparent);
}

.chat-input-wrapper {
    display: flex;
    gap: 14px;
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid rgba(110, 69, 226, 0.35);
    border-radius: 16px;
    resize: none;
    min-height: 52px;
    max-height: 140px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.6;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.chat-input-wrapper textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

.chat-input-wrapper textarea::-webkit-scrollbar {
    width: 8px;
}

.chat-input-wrapper textarea::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.chat-input-wrapper textarea::-webkit-scrollbar-thumb {
    background: rgba(110, 69, 226, 0.6);
    border-radius: 4px;
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(110, 69, 226, 0.25);
}

.send-message-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(110, 69, 226, 0.4);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.send-message-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.send-message-btn:hover:not(:disabled)::after {
    opacity: 1;
}

.send-message-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 12px 30px rgba(110, 69, 226, 0.5);
}

.send-message-btn:active:not(:disabled) {
    transform: translateY(-1px) scale(1.05);
}

.send-message-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 4px 12px rgba(110, 69, 226, 0.2);
}

.send-message-btn i {
    font-size: 22px;
    position: relative;
    z-index: 1;
}

/* Индикатор прокрутки вниз */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 110px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    opacity: 0;
    transform: translateY(15px) scale(0.8);
    pointer-events: none;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-to-bottom-btn:hover {
    transform: translateY(-5px) scale(1.15);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.3);
}

.scroll-to-bottom-btn i {
    font-size: 20px;
    transition: transform 0.3s;
}

.scroll-to-bottom-btn:hover i {
    transform: translateY(2px);
}

/* Список чатов */
.chat-list-container {
    flex: 0 0 380px;
    background: rgba(26, 26, 46, 0.85);
    border-right: 1px solid rgba(110, 69, 226, 0.25);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(15px);
    position: relative;
    overflow: hidden;
}

.chat-list-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(110, 69, 226, 0.3), transparent);
}

.chat-search {
    padding: 22px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    background: rgba(30, 30, 60, 0.7);
}

.chat-search i {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 17px;
    z-index: 1;
}

.chat-search input {
    width: 100%;
    padding: 14px 20px 14px 50px;
    border: 2px solid rgba(110, 69, 226, 0.35);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.09);
    color: white;
    font-size: 15px;
    transition: all 0.3s ease;
    position: relative;
}

.chat-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(110, 69, 226, 0.25);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;

    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.chat-list::-webkit-scrollbar {
    width: 8px;
}

.chat-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(110, 69, 226, 0.5);
    border-radius: 4px;
    transition: background 0.3s;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: rgba(110, 69, 226, 0.7);
}

/* Элементы списка чатов */
.chat-item {
    display: flex;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    min-height: 80px;
    background: transparent;
}

.chat-item:hover {
    background: rgba(110, 69, 226, 0.12);
    padding-left: 26px;
}

.chat-item.active {
    background: linear-gradient(90deg, 
        rgba(110, 69, 226, 0.25) 0%, 
        rgba(136, 211, 206, 0.15) 100%);
    border-left: 5px solid var(--primary);
    padding-left: 22px;
}

.chat-item.unread {
    background: rgba(110, 69, 226, 0.1);
}

.chat-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(var(--primary), var(--secondary));
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    margin-right: 16px;
    flex-shrink: 0;
    box-shadow: 0 6px 18px rgba(110, 69, 226, 0.4);
    position: relative;
    overflow: hidden;
}

.chat-avatar::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: avatarRotate 4s linear infinite;
}

@keyframes avatarRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.chat-name {
    font-weight: 700;
    color: #ffffff;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-time {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
    font-weight: 500;
}

.chat-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.chat-last-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.chat-status-badge.open {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8; /* яркий голубой */
    border-color: #0ea5e9;
    font-weight: 500;
}

.chat-status-badge.closed {
    background: rgba(40, 167, 69, 0.25);
    color: #28a745;
    border-color: rgba(40, 167, 69, 0.3);
}

.chat-status-badge.buyer-win {
    background: rgba(220, 53, 69, 0.25);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.3);
}

.chat-status-badge.priority {
    background: rgba(255, 193, 7, 0.25);
    color: #ffc107;
    border-color: rgba(255, 193, 7, 0.3);
    animation: badgePriorityPulse 2s infinite;
}

@keyframes badgePriorityPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.3);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(255, 193, 7, 0);
    }
}

.chat-badge {
    position: absolute;
    top: 18px;
    right: 22px;
    background: linear-gradient(135deg, #dc3545, #e05666);
    color: white;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 10px;
    border-radius: 14px;
    min-width: 22px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
    animation: badgeBounce 2s infinite;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

@keyframes badgeBounce {
    0%, 100% { 
        transform: translateY(0) scale(1); 
    }
    50% { 
        transform: translateY(-3px) scale(1.1); 
    }
}

/* Состояния загрузки и пустые состояния */
.loading-chats {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    gap: 10px;
}

.loading-chats .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    animation: bounce 1.4s infinite ease-in-out;
    box-shadow: 0 6px 15px rgba(110, 69, 226, 0.4);
}

.loading-chats .dot:nth-child(1) { animation-delay: -0.32s; }
.loading-chats .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { 
        transform: scale(0);
        opacity: 0.3;
    } 
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 24px;
}

.empty-state i {
    font-size: 52px;
    margin-bottom: 18px;
    opacity: 0.2;
}

.empty-state p {
    font-size: 16px;
    line-height: 1.6;
    max-width: 300px;
}

.loading-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 40px;
}

.loading-messages .loader {
    width: 55px;
    height: 55px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    box-shadow: 0 0 20px rgba(110, 69, 226, 0.3);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 40px 24px;
}

.error-state i {
    font-size: 52px;
    color: #dc3545;
    opacity: 0.7;
}

/* Контейнер для чатов/диспутов */
.telegram-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 650px;
    background: rgba(26, 26, 46, 0.6);
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(110, 69, 226, 0.3);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    position: relative;
}

.telegram-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(110, 69, 226, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(136, 211, 206, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 17px;
    background: rgba(26, 26, 46, 0.4);
    font-weight: 500;
}

/* Кнопка закрытия модального окна */
.modal-close-btn {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    line-height: 1;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg) scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Индикатор нового сообщения */
.new-message-indicator {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #dc3545, #e05666);
    border-radius: 50%;
    animation: newMessagePulse 2s infinite;
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
}

@keyframes newMessagePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
        transform: scale(1);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
        transform: scale(1.2);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
        transform: scale(1);
    }
}

/* АДАПТИВНОСТЬ */
@media (max-width: 1200px) {
    .chat-modal .modal-content {
        max-width: 100%;
        height: 88vh;
    }
    
    .telegram-container {
        height: calc(100vh - 180px);
        min-height: 600px;
    }
    
    .chat-list-container {
        flex: 0 0 340px;
    }
}

@media (max-width: 992px) {
    .chat-list-container {
        flex: 0 0 320px;
    }
    
    .order-summary,
    .product-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .message {
        max-width: 82%;
    }
}

@media (max-width: 768px) {
    .telegram-container {
        flex-direction: column;
        height: calc(100vh - 140px);
        min-height: 500px;
        border-radius: 12px;
    }
    
    .chat-list-container {
        flex: 0 0 auto;
        height: 100%;
        min-height: 280px;
        border-right: none;
        border-bottom: 1px solid rgba(110, 69, 226, 0.3);
    }
    
    .chat-modal .modal-content {
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        margin: 0;
        animation: mobileSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }
    
    @keyframes mobileSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .chat-header {
        padding: 18px 20px;
    }
    
    .chat-partner-avatar {
        width: 44px;
        height: 44px;
        font-size: 17px;
    }
    
    .chat-partner-name {
        font-size: 16px;
    }
    
    .chat-actions {
        gap: 10px;
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .chat-messages-container {
        padding: 20px;
        gap: 16px;
    }
    
    .message {
        max-width: 86%;
        padding: 14px 18px;
        font-size: 14px;
    }
    
    .dispute-order-info {
        padding: 18px 20px;
    }
    
    .order-summary,
    .product-summary {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .summary-item {
        padding: 12px;
    }
    
    .chat-input-container {
        padding: 18px 20px;
    }
    
    .chat-input-wrapper textarea {
        padding: 14px 18px;
        min-height: 48px;
        font-size: 14px;
    }
    
    .send-message-btn {
        width: 48px;
        height: 48px;
    }
    
    .send-message-btn i {
        font-size: 20px;
    }
    
    .scroll-to-bottom-btn {
        bottom: 100px;
        right: 20px;
        width: 44px;
        height: 44px;
    }
    
    .modal-close-btn {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .dispute-resolution-info {
        margin: 14px 16px 0;
        padding: 14px 16px;
    }
}

@media (max-width: 576px) {
    .chat-modal .modal-content {
        height: 100vh;
    }
    
    .chat-partner-info {
        gap: 12px;
    }
    
    .chat-partner-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .chat-partner-name {
        font-size: 15px;
    }
    
    .action-btn span {
        display: none;
    }
    
    .action-btn .btn-icon {
        display: inline-block;
        font-size: 17px;
        margin: 0;
    }
    
    .action-btn {
        padding: 10px;
        min-width: 44px;
        justify-content: center;
    }
    
    .message {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .chat-badge {
        top: 42px;
        right: 1px;
        font-size: 11px;
        padding: 4px 8px;
        min-width: 20px;
    }
    
    .chat-item {
        padding: 16px 18px;
        min-height: 72px;
    }
    
    .chat-avatar {
        width: 42px;
        height: 42px;
        font-size: 16px;
        margin-right: 14px;
    }
    
    .chat-name {
        font-size: 14px;
    }
    
    .chat-last-message {
        font-size: 13px;
    }
    
    .chat-search {
        padding: 18px 20px;
    }
    
    .chat-search input {
        padding: 12px 16px 12px 46px;
        font-size: 14px;
    }
    
    .chat-search i {
        left: 36px;
        font-size: 16px;
    }
    
    .chat-status-badge {
        padding: 4px 10px;
        font-size: 11px;
    }
    
    .scroll-to-bottom-btn {
        bottom: 90px;
        right: 16px;
        width: 40px;
        height: 40px;
    }
    
    .scroll-to-bottom-btn i {
        font-size: 18px;
    }
}

@media (max-width: 375px) {
    .chat-header {
        padding: 16px;
    }
    
    .chat-partner-avatar {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
    
    .chat-partner-name {
        font-size: 14px;
    }
    
    .chat-actions {
        gap: 8px;
    }
    
    .action-btn {
        padding: 8px;
        min-width: 40px;
    }
    
    .chat-messages-container {
        padding: 16px;
        gap: 14px;
    }
    
    .message {
        max-width: 92%;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .message-header {
        font-size: 12px;
    }
    
    .message-content {
        font-size: 14px;
    }
    
    .chat-input-container {
        padding: 16px;
    }
    
    .chat-input-wrapper textarea {
        padding: 12px 16px;
        font-size: 13px;
        min-height: 44px;
    }
    
    .send-message-btn {
        width: 44px;
        height: 44px;
    }
    
    .send-message-btn i {
        font-size: 18px;
    }
    
    .modal-close-btn {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
    
    .dispute-order-info {
        padding: 16px;
    }
    
    .summary-value {
        font-size: 14px;
    }
}

/* Темная тема для textarea в фокусе на iOS */
@supports (-webkit-touch-callout: none) {
    .chat-input-wrapper textarea {
        background: rgba(255, 255, 255, 0.09);
    }
    
    .chat-input-wrapper textarea:focus {
        background: rgba(255, 255, 255, 0.14);
    }
    
    .chat-messages-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Оптимизация производительности для анимаций */
@media (prefers-reduced-motion: reduce) {
    .chat-modal,
    .chat-modal .modal-content,
    .message,
    .summary-item,
    .chat-item,
    .action-btn,
    .send-message-btn,
    .scroll-to-bottom-btn,
    .modal-close-btn {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .chat-partner-avatar::after,
    .chat-avatar::after,
    .action-btn::before,
    .summary-value::before,
    .send-message-btn::after {
        animation: none !important;
        display: none !important;
    }
}