/**
 * Стили для чата в игре
 */

/* Контейнер чата */
.game-chat {
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 200px;
    transition: max-height 0.3s ease;
}

.game-chat.collapsed {
    max-height: 40px;
    overflow: hidden;
}

.game-chat.collapsed .chat-messages,
.game-chat.collapsed .chat-input-container {
    display: none;
}

/* Заголовок чата */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(25, 118, 210, 0.1);
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    font-size: 14px;
    color: #1976D2;
    border-bottom: 1px solid rgba(25, 118, 210, 0.2);
}

.chat-toggle-btn {
    background: transparent;
    border: none;
    color: #1976D2;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-toggle-btn:hover {
    background: rgba(25, 118, 210, 0.1);
}

.chat-toggle-btn:active {
    background: rgba(25, 118, 210, 0.2);
}

/* Сообщения чата */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    max-height: 120px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    word-wrap: break-word;
    max-width: 80%;
    animation: messageAppear 0.3s ease;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-message:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

/* ИСПРАВЛЕНИЕ УЛУЧШЕНИЯ #17: Анимация для новых сообщений */
.chat-message.new-message {
    animation: messageAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-message.own {
    align-self: flex-end;
    background: rgba(25, 118, 210, 0.15);
    color: #1565C0;
    border: 1px solid rgba(25, 118, 210, 0.3);
}

.chat-message.opponent {
    align-self: flex-start;
    background: rgba(158, 158, 158, 0.15);
    color: #424242;
    border: 1px solid rgba(158, 158, 158, 0.3);
}

.chat-message.emoji {
    font-size: 24px;
    padding: 8px 12px;
    text-align: center;
}

.chat-message .message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.chat-message .message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.chat-message.opponent .message-time {
    text-align: left;
}

.chat-message .message-status {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
    display: inline-block;
    transition: opacity 0.3s ease;
}

.chat-message .message-status.status-sending {
    animation: pulse 1.5s ease-in-out infinite;
}

.chat-message .message-status.status-sent {
    opacity: 0.8;
    color: #4CAF50;
}

.chat-message .message-status.status-failed {
    opacity: 1;
    color: #F44336;
    cursor: pointer;
}

.chat-message.sending {
    opacity: 0.8;
    animation: messageSending 0.5s ease;
}

.chat-message.failed {
    opacity: 0.7;
    border-color: rgba(244, 67, 54, 0.5);
    background-color: rgba(244, 67, 54, 0.05);
}

.chat-message.sent {
    opacity: 1;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes messageSending {
    0% {
        transform: translateY(5px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 0.8;
    }
}

/* Индикатор печати */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.typing-indicator .typing-dots {
    display: flex;
    gap: 3px;
}

.typing-indicator .typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #666;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-indicator .typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Контейнер ввода */
.chat-input-container {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(245, 245, 245, 0.5);
    border-radius: 0 0 12px 12px;
}

/* Эмодзи панель */
.emoji-picker {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    width: 100%;
}

.emoji-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(25, 118, 210, 0.3);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 0;
}

.emoji-btn:hover {
    background: rgba(25, 118, 210, 0.1);
    border-color: rgba(25, 118, 210, 0.5);
    transform: scale(1.1);
}

.emoji-btn:active {
    transform: scale(0.95);
}

/* Поле ввода */
.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(25, 118, 210, 0.3);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #1976D2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}

/* Кнопка отправки */
.chat-send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(25, 118, 210, 0.3);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 118, 210, 0.5);
}

