/* Чат система - стили (Telegram-inspired) */

:root {
    --chat-bg: #0e1621;
    --chat-sidebar-bg: #17212b;
    --chat-item-hover: #1e2d3d;
    --chat-bubble-out: rgba(138, 180, 248, 0.3);
    --chat-bubble-in: rgba(255, 255, 255, 0.08);
    --chat-text-out: #ffffff;
    --chat-text-in: #e8eaed;
    --chat-border: rgba(255, 255, 255, 0.08);
    --chat-accent: #8ab4f8;
}

/* Предотвращаем overscroll на странице чата */
body {
    overscroll-behavior-y: none;
    overflow: hidden;
}

html {
    overscroll-behavior-y: none;
}

.chat-container {
    display: flex;
    height: calc(100vh - 64px);
    margin-top: 64px;
    background: var(--chat-bg);
    overflow: hidden;
    position: relative;
}

/* ====== ЛЕВАЯ ПАНЕЛЬ: СПИСОК ЧАТОВ ====== */

.chat-sidebar {
    width: 340px;
    background: var(--chat-sidebar-bg);
    border-right: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    flex-shrink: 0;
}

/* Мобильная адаптация sidebar */
@media (max-width: 768px) {
    .chat-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 100%;
        max-width: 85vw;
        transform: translateX(-100%);
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
    }
    
    .chat-sidebar.open {
        transform: translateX(0);
    }
    
    .chat-container::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 9;
    }
    
    .chat-sidebar.open ~ .chat-container::before {
        opacity: 1;
        pointer-events: all;
    }
}

.chat-sidebar-header {
    padding: 16px 16px;
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--chat-sidebar-bg);
}

.chat-sidebar-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--chat-text-out);
    margin: 0;
    letter-spacing: -0.3px;
}

.chat-new-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-new-btn:hover {
    background: #9bc5ff;
    transform: scale(1.08);
}

.chat-new-btn:active {
    transform: scale(0.95);
}

.chat-new-btn svg {
    width: 20px;
    height: 20px;
}

.chat-search {
    padding: 12px 16px;
    background: var(--chat-sidebar-bg);
}

.chat-search input {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 22px;
    color: var(--chat-text-out);
    font-size: 16px;
    transition: all 0.2s ease;
}

.chat-search input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-search input:focus {
    outline: none;
    border-color: var(--chat-accent);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.15);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-list-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--chat-border);
    transition: all 0.15s ease;
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
}

.chat-list-item:hover {
    background: var(--chat-item-hover);
}

.chat-list-item.active {
    background: rgba(138, 180, 248, 0.12);
}

.chat-list-item.unread {
    background: rgba(138, 180, 248, 0.05);
}

.chat-item-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #5a8fd8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    position: relative;
}

.chat-item-avatar svg {
    width: 28px;
    height: 28px;
    color: white;
}

.chat-item-avatar.online::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #4cd964;
    border-radius: 50%;
    border: 3px solid var(--chat-sidebar-bg);
    bottom: 2px;
    right: 0;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item-name {
    font-weight: 500;
    color: var(--chat-text-out);
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.chat-item-time {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    margin-left: 12px;
}

.chat-list-item.unread .chat-item-time {
    color: var(--chat-accent);
    font-weight: 500;
}

.chat-item-preview {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-item-preview.unread {
    color: var(--chat-text-in);
    font-weight: 400;
}

.chat-unread-badge {
    min-width: 22px;
    height: 22px;
    background: var(--chat-accent);
    color: #0e1621;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 7px;
    box-shadow: 0 2px 6px rgba(138, 180, 248, 0.3);
}

/* ====== ПРАВАЯ ПАНЕЛЬ: ОКНО ЧАТА ====== */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 40px;
}

.chat-empty-state svg {
    opacity: 0.2 !important;
}

.chat-empty-state h3 {
    font-size: 22px;
    color: var(--chat-text-out);
    margin-bottom: 8px;
    font-weight: 500;
}

.chat-empty-state p {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.4);
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    background: var(--chat-sidebar-bg);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-back-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--chat-text-out);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-back-btn:hover {
    background: var(--chat-item-hover);
}

.chat-back-btn:active {
    transform: scale(0.95);
}

.chat-back-btn svg {
    width: 22px;
    height: 22px;
}

@media (max-width: 768px) {
    .chat-back-btn {
        display: flex;
    }
}

.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #5a8fd8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    flex-shrink: 0;
}

.chat-header-avatar svg {
    width: 22px;
    height: 22px;
    color: white;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--chat-text-out);
    margin: 0 0 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.chat-header-status {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.chat-header-status.online {
    color: var(--chat-accent);
}

.chat-header-actions {
    display: flex;
    gap: 4px;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Панель поиска в чате */
.chat-search-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--chat-border);
    animation: slideDown 0.2s ease;
}

.chat-search-input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-search-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--chat-accent);
}

.chat-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-search-navigation {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-search-results {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    min-width: 40px;
    text-align: center;
}

.chat-search-nav-btn,
.chat-search-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-search-nav-btn:hover,
.chat-search-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.chat-search-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-search-nav-btn svg,
.chat-search-close-btn svg {
    width: 18px;
    height: 18px;
}

.chat-message.search-highlight {
    background: rgba(138, 180, 248, 0.2);
}

/* ====== ОБЛАСТЬ СООБЩЕНИЙ ====== */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    scroll-behavior: smooth;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    position: relative;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}

@media (max-width: 768px) {
    .chat-messages {
        padding: 12px 8px;
    }
}

.chat-messages-loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 40px;
}

.chat-date-divider {
    text-align: center;
    margin: 16px 0;
    position: sticky;
    top: 8px;
    z-index: 1;
}

.chat-date-divider span {
    background: rgba(23, 33, 43, 0.9);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--chat-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.own {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-message:not(.own) {
    align-self: flex-start;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .chat-message {
        max-width: 80%;
    }
}

.chat-message-avatar {
    display: none;
}

.chat-message-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.chat-message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 0 12px;
    margin-bottom: 2px;
}

.chat-message.own .chat-message-header {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.chat-message-sender {
    font-size: 13px;
    font-weight: 500;
    color: var(--chat-accent);
}

.chat-message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    position: absolute;
    bottom: 6px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Галочки прочитанности (как в Telegram) */
.chat-message-checkmarks {
    display: inline-flex;
    align-items: center;
    margin-left: 3px;
}

.chat-message-checkmark {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.45);
}

.chat-message.own.read .chat-message-checkmark {
    color: var(--chat-accent);
}

/* Двойная галочка (прочитано) */
.chat-message-checkmarks.read {
    position: relative;
}

.chat-message-checkmarks.read .chat-message-checkmark:first-child {
    margin-right: -8px;
}

.chat-message.own .chat-message-time {
    color: rgba(255, 255, 255, 0.6);
}

.chat-message-bubble {
    background: rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 12px 22px 12px;
    border-radius: 12px 12px 12px 2px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    display: inline-block;
    max-width: 100%;
}

.chat-message.own .chat-message-bubble {
    background: rgba(138, 180, 248, 0.2) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(138, 180, 248, 0.15) !important;
    border-radius: 12px 12px 2px 12px;
    box-shadow: 0 1px 2px rgba(138, 180, 248, 0.2);
}

.chat-message-text {
    font-size: 15px;
    line-height: 1.5;
    color: var(--chat-text-in) !important;
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 50px;
}

.chat-message.own .chat-message-text {
    color: var(--chat-text-out) !important;
}

/* Цитата внутри сообщения */
.chat-message-reply {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--chat-accent);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chat-message-reply:hover {
    background: rgba(0, 0, 0, 0.3);
}

.chat-message-reply-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-accent);
    margin-bottom: 2px;
}

.chat-message-reply-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-message-text a {
    color: var(--chat-accent);
    text-decoration: none;
    border-bottom: 1px solid var(--chat-accent);
}

.chat-message.own .chat-message-text a {
    color: #ffffff !important;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.chat-message-text a:hover {
    opacity: 0.8;
}

/* Изображения в сообщениях */
.chat-message-image {
    max-width: 300px;
    max-height: 400px;
    width: 100%;
    height: auto;
    cursor: pointer;
    display: block;
    object-fit: contain;
}

/* Адаптив для мобильных */
@media (max-width: 768px) {
    .chat-message-image {
        max-width: 250px;
        max-height: 350px;
    }
    
    .chat-message {
        max-width: 80% !important;
    }
    
    .chat-message-bubble {
        max-width: 100%;
    }
}

.chat-message-bubble.photo-message {
    padding: 0 !important;
    overflow: hidden;
    border-radius: 16px;
}

.chat-message-bubble.photo-message .chat-message-image {
    margin: 0;
    border-radius: 16px;
    display: block;
}

/* Файлы в сообщениях */
.chat-message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 320px;
}

@media (max-width: 768px) {
    .chat-message-file {
        max-width: 70vw;
    }
}

.chat-message-file:hover {
    opacity: 0.85;
}

.chat-message-file-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 12px;
}

.chat-message.own .chat-message-file-icon {
    background: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.chat-message-file-info {
    flex: 1;
}

.chat-message-file-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a !important;
    margin-bottom: 2px;
    word-break: break-word;
}

.chat-message.own .chat-message-file-name {
    color: #ffffff !important;
}

.chat-message-file-size {
    font-size: 12px;
    color: #666 !important;
}

.chat-message.own .chat-message-file-size {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Голосовые сообщения */
.chat-message-voice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    min-width: 200px;
}

.chat-voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.chat-voice-play-btn:hover {
    background: white;
    transform: scale(1.05);
}

.chat-voice-play-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 2px;
}

.chat-message.own .chat-voice-play-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.chat-message.own .chat-voice-play-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-voice-waveform {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-voice-bar {
    width: 3px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: all 0.1s ease;
}

.chat-message.own .chat-voice-bar {
    background: rgba(255, 255, 255, 0.6);
}

.chat-voice-duration {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-message.own .chat-voice-duration {
    color: rgba(255, 255, 255, 0.8);
}

/* Шаринг лота */
.chat-message-lot-share {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 300px;
    overflow: hidden;
}

.chat-message-lot-share:hover {
    border-color: var(--chat-accent);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
}

.chat-lot-share-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.chat-lot-share-price {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
    padding: 12px 12px 0 12px;
}

.chat-lot-share-title {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 8px;
    padding: 0 12px;
    line-height: 1.4;
}

.chat-lot-share-link {
    font-size: 13px;
    color: var(--chat-accent);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px 12px 12px;
    font-weight: 500;
}

.chat-lot-share-link svg {
    width: 16px;
    height: 16px;
}

.chat-message-bubble.lot-message {
    padding: 0 !important;
    overflow: hidden;
    border-radius: 16px;
    max-width: 300px;
}

/* ====== ИНДИКАТОР ПЕЧАТИ ====== */

.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--chat-sidebar-bg);
    animation: slideDown 0.2s ease;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--chat-accent);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ====== ПАНЕЛЬ ВВОДА ====== */

.chat-input-panel {
    padding: 12px 16px;
    background: var(--chat-sidebar-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* Превью ответа */
.chat-reply-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(138, 180, 248, 0.08);
    border-left: 3px solid var(--chat-accent);
    border-radius: 8px;
    margin-bottom: 8px;
    animation: slideDown 0.2s ease;
}

.reply-preview-line {
    width: 3px;
    height: 100%;
    background: var(--chat-accent);
    border-radius: 2px;
    position: absolute;
    left: 0;
    top: 0;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
}

.reply-preview-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-accent);
    margin-bottom: 2px;
}

.reply-preview-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.reply-preview-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== КОНТЕКСТНОЕ МЕНЮ ====== */

.message-context-menu {
    position: fixed;
    background: rgba(30, 34, 42, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 6px;
    z-index: 10000;
    min-width: 180px;
    animation: contextMenuAppear 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 500;
}

.context-menu-item svg {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

.context-menu-item:hover {
    background: rgba(138, 180, 248, 0.15);
    color: #ffffff;
}

.context-menu-item:hover svg {
    color: var(--chat-accent);
}

.context-menu-item-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ff6b6b;
}

.context-menu-item-danger:hover svg {
    color: #ff6b6b;
}

@keyframes contextMenuAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* ====== УПРАВЛЕНИЕ УЧАСТНИКАМИ ====== */

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8ab4f8 0%, #4a90e2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.participant-info {
    flex: 1;
    min-width: 0;
}

.participant-name {
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2px;
}

.participant-status {
    font-size: 13px;
    color: var(--chat-accent);
}

/* ====== РЕАКЦИИ ====== */

.reaction-picker {
    position: fixed;
    background: rgba(30, 34, 42, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 40px;
    padding: 8px;
    display: flex;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    animation: reactionPickerAppear 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reaction-emoji {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reaction-emoji:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

.reaction-emoji:active {
    transform: scale(0.9);
}

.chat-message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.chat-reaction {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(138, 180, 248, 0.15);
    border: 1px solid rgba(138, 180, 248, 0.25);
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-reaction:hover {
    background: rgba(138, 180, 248, 0.25);
    transform: scale(1.05);
}

.chat-reaction.own {
    background: rgba(138, 180, 248, 0.3);
    border-color: var(--chat-accent);
}

.chat-reaction-emoji {
    font-size: 16px;
}

.chat-reaction-count {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

@keyframes reactionPickerAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 768px) {
    .chat-input-panel {
        padding: 10px 12px;
    }
}

.chat-attachment-preview {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.chat-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.chat-preview-thumb {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-primary);
}

.chat-preview-info {
    flex: 1;
}

.chat-preview-name {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chat-preview-size {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-preview-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--error);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-preview-remove:hover {
    opacity: 0.8;
}

.chat-input-container {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 6px 8px;
    border: 1px solid var(--chat-border);
    transition: all 0.2s ease;
}

.chat-input-container:focus-within {
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.12);
}

.chat-attach-btn,
.chat-voice-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-attach-btn:hover,
.chat-voice-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-accent);
    transform: scale(1.1);
}

.chat-attach-btn:active,
.chat-voice-btn:active {
    transform: scale(0.92);
}

.chat-attach-btn svg,
.chat-voice-btn svg {
    width: 24px;
    height: 24px;
}

.chat-voice-btn.recording {
    background: #ff3b30;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    min-height: 24px;
    max-height: 150px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--chat-text-out);
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    resize: none;
    overflow-y: auto;
    transition: all 0.15s ease;
    line-height: 1.5;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--chat-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    color: #9bc5ff;
    background: rgba(138, 180, 248, 0.1);
    transform: scale(1.12);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.chat-send-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    transform: none;
    color: rgba(138, 180, 248, 0.25);
}

.chat-send-btn svg {
    width: 26px;
    height: 26px;
}

/* ====== МОДАЛКИ (Telegram-style) ====== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7) !important;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999 !important;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--chat-sidebar-bg);
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
    animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100000;
    border: 1px solid var(--chat-border);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.9) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--chat-border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--chat-text-out);
    margin: 0;
    letter-spacing: -0.2px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 28px;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text-out);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    max-height: calc(85vh - 160px);
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--chat-border);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--chat-text-out);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 10px;
    color: var(--chat-text-out);
    font-size: 15px;
    transition: all 0.15s ease;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-control:focus {
    outline: none;
    border-color: var(--chat-accent);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.15);
}

.btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--chat-accent);
    color: #0e1621;
    font-weight: 600;
}

.btn-primary:hover {
    background: #9bc5ff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text-out);
    border: 1px solid var(--chat-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: #ff3b30;
    color: white;
    font-weight: 500;
}

.btn-danger:hover {
    background: #ff5449;
}

.participants-list {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--chat-accent);
}

.participant-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--chat-accent);
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #5a8fd8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.participant-avatar svg {
    width: 22px;
    height: 22px;
    color: white;
}

.participant-info {
    flex: 1;
    min-width: 0;
}

.participant-name {
    font-size: 15px;
    font-weight: 400;
    color: var(--chat-text-out);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-role {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* ====== АДАПТИВНОСТЬ (уже определена в отдельных блоках выше) ====== */

/* Стили для модалки шаринга лотов */
.share-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.share-chat-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.share-chat-item:last-child {
    margin-bottom: 0;
}

/* Индикатор печати */
.chat-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border);
    width: fit-content;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Панель записи голосового сообщения */
.chat-voice-recording-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--chat-accent);
    animation: slideDown 0.2s ease;
}

.voice-cancel-btn,
.voice-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.voice-cancel-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.voice-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.05);
}

.voice-cancel-btn svg {
    width: 24px;
    height: 24px;
}

.voice-send-btn {
    background: var(--chat-accent);
    color: white;
}

.voice-send-btn:hover {
    background: #5a8fd8;
    transform: scale(1.05);
}

.voice-send-btn svg {
    width: 24px;
    height: 24px;
}

.voice-recording-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.voice-recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    animation: voiceRecordingPulse 1.5s infinite;
}

@keyframes voiceRecordingPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.voice-recording-time {
    font-size: 20px;
    font-weight: 500;
    color: var(--chat-text-out);
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
}
