/* Публичный чат - твои сообщения справа, все остальные слева */

/* Контейнер сообщений */
#publicChatMessages {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px;
}

/* Красивый золотой скролл */
#publicChatMessages::-webkit-scrollbar {
    width: 6px;
}

#publicChatMessages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

#publicChatMessages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #DCC07F 0%, #b8975f 100%);
    border-radius: 10px;
}

#publicChatMessages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #e6d5a0 0%, #DCC07F 100%);
}

/* Пустое состояние */
.chat-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 60px 20px;
    font-size: 14px;
}

/* Сообщение - базовый контейнер */
.public-chat-message {
    display: flex !important;
    flex-direction: column !important;
    max-width: 70% !important;
    animation: messageFadeIn 0.3s ease;
    clear: both;
}

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

/* МОИ сообщения - СПРАВА */
.public-chat-message.my-message {
    align-self: flex-end !important;
    margin-left: auto !important;
}

.public-chat-message.my-message .message-header {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    justify-content: flex-end !important;
}

.public-chat-message.my-message .message-text {
    background: rgba(220, 192, 127, 0.15) !important;
    border: none !important;
    padding: 10px 14px;
    border-radius: 16px 16px 4px 16px !important;
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ВСЕ ОСТАЛЬНЫЕ сообщения (включая мага и других пользователей) - СЛЕВА */
.public-chat-message.other-message {
    align-self: flex-start !important;
    margin-right: auto !important;
}

.public-chat-message.other-message .message-header {
    display: flex !important;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    justify-content: flex-start !important;
}

.public-chat-message.other-message .message-text {
    background: rgba(60, 60, 60, 0.35) !important;
    border: none !important;
    padding: 10px 14px;
    border-radius: 16px 16px 16px 4px !important;
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Сообщения от мага - немного другой цвет */
.public-chat-message.admin-message .message-text {
    background: rgba(80, 70, 60, 0.4) !important;
}

/* Заголовок сообщения */
.message-header {
    font-size: 11px;
    padding: 0 4px;
}

.message-author {
    font-weight: 600;
    color: #DCC07F;
    font-size: 12px;
}

.message-author.admin {
    color: #ffaa99;
}

.message-badge {
    background: rgba(255, 170, 153, 0.25);
    color: #ffaa99;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-time {
    color: rgba(255, 255, 255, 0.35);
    font-size: 10px;
    margin-left: auto;
}

/* Ответ на сообщение */
.message-reply-preview {
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid #DCC07F;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.3;
}

.public-chat-message.admin-message .message-reply-preview {
    border-left-color: #ffaa99;
}

.message-reply-preview strong {
    color: #DCC07F;
    font-size: 10px;
    font-weight: 700;
    display: block;
    margin-bottom: 3px;
}

.public-chat-message.admin-message .message-reply-preview strong {
    color: #ffaa99;
}

/* Действия с сообщением */
.message-actions {
    margin-top: 6px;
    padding: 0 4px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.public-chat-message:hover .message-actions {
    opacity: 1;
}

.message-reply-btn {
    background: transparent;
    border: 1px solid rgba(220, 192, 127, 0.3);
    color: rgba(220, 192, 127, 0.7);
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.message-reply-btn:hover {
    background: rgba(220, 192, 127, 0.1);
    border-color: #DCC07F;
    color: #DCC07F;
}

/* Блок ответа при отправке */
.reply-preview-block {
    display: none;
}

.reply-preview-block.active {
    display: block !important;
}

.reply-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.reply-preview-header strong {
    color: #DCC07F;
    font-size: 12px;
}

.cancel-reply-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.cancel-reply-btn:hover {
    color: #ff6b6b;
}

.reply-preview-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

/* Форма отправки */
.chat-send-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#publicChatName,
#publicChatMessage {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(220, 192, 127, 0.25);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
}

#publicChatMessage {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
    line-height: 1.5;
}

#publicChatName:focus,
#publicChatMessage:focus {
    outline: none;
    border-color: #DCC07F;
    background: rgba(0, 0, 0, 0.4);
}

#publicChatName::placeholder,
#publicChatMessage::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.public-chat-btn {
    padding: 12px 28px;
    background: transparent;
    border: 2px solid #DCC07F;
    border-radius: 40px;
    color: #DCC07F;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.public-chat-btn:hover {
    background: rgba(220, 192, 127, 0.15);
    border-color: #e6d5a0;
    color: #e6d5a0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 192, 127, 0.2);
}

.public-chat-btn:active {
    transform: scale(0.98);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .public-chat-message {
        max-width: 80% !important;
    }
    
    #publicChatMessage {
        min-height: 60px;
    }
    
    .message-text {
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    .public-chat-message {
        max-width: 85% !important;
    }
    
    .message-header {
        font-size: 10px;
    }
    
    .message-text {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }
    
    .message-actions {
        opacity: 1;
    }
    
    .message-badge {
        font-size: 8px;
        padding: 2px 6px;
    }
}
