/* Основные стили чата */

.chat_footer_send {
    display: flex;
    gap: 10px;
}
.chat_footer_send > form {
    width: 100%;
}
.block-chat-my {
    display: flex;
    gap: 15px;
    background-color: var(--card-color);
    margin-bottom: 30px;
    padding: 15px;
    border-radius: 6px;
    align-items: center;
    position: relative;
}
.block-chat-my h5 {
    display: grid;
    gap: 5px;
}
.block-chat-my .block-chat-ava-my {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    opacity: .6;
    transition: .5s;
    object-fit: cover;
}
.block-chat-my .block-chat-ava-my:hover {
    opacity: 1;
}
.block-chat-my h5 div {
    font-size: 8px;
    color: var(--text-custom);
}
#chat_main_content {
    display: flex;
    width: 100%;
    gap: 10px;
    padding: 0 5px 0 0;
    margin: 0 0 15px 0;
    height: 413px;
    overflow: auto;
    flex-direction: column;
}
#chat_main_content::-webkit-scrollbar {
    height: 2px;
    width: 2px;
}
.chat_footer_send > button {
    cursor: pointer;
    height: 40px;
    border-radius: 6px;
    width: 40px;
    transition: .5s;
    background-color: var(--input-form);
}
.chat_footer_send > button > svg {
    transition: .5s;
    fill: var(--text-custom);
    width: 15px;
    height: 15px;
}
.chat_footer_send > button:hover {
    color: var(--span);
}
.chat_footer_send > button:hover svg {
    fill: var(--span);
}
#chat_send_message > textarea {
    outline: 0;
    resize: none;
    float: left;
    min-height: 40px;
    max-height: 100px;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 6px;
    line-height: 1.5;
    padding: 9px 50px 9px 15px;
    word-wrap: break-word;
    -webkit-box-sizing: border-box;
    background-color: var(--input-form);
    box-sizing: border-box;
    border: 0;
    color: var(--text-custom);
    overflow-wrap: break-word;
}
[contentEditable=true]:empty:not(:focus):before {
    content: attr(data-text);
    color: var(--text-custom);
}
div:empty:before {
    content: attr(data-text);
    color: var(--text-custom);
}
.chat_message {
    display: flex;
    justify-content: flex-start;
    position: relative;
    border: .5px solid rgb(255 255 255 / 10%);
    border-radius: 8px;
}
.chat_message_my {
    display: flex;
    justify-content: flex-end;
    position: relative;
    border: .5px solid rgb(255 255 255 / 10%);
    border-radius: 8px;
}
.chat_message .padding, .chat_message_my .padding {
    z-index: 3;
    padding: 10px;
    width: 100%;
    border-radius: 4px;
    background: var(--card);
    position: relative;
}
.chat_message div > a >  img, .chat_message_my div > a > img {
    width: 25px;
    height: 25px;
    cursor: pointer;
    border-radius: 6px;
    opacity: .6;
    transition: .5s;
    object-fit: cover;
}
.chat_message div > a > img {
    float: left;
}
.chat_message_my div > a > img  {
    float: right;
}
.chat_message div > a > img:hover, .chat_message_my div > a > img:hover {
    opacity: 1;
}
.chat_message .chat_info, .chat_message_my .chat_info {
    display: flex;
    gap: 10px;
    height: 25px;
    justify-content: space-between;
    align-items: center;
}
.chat_message div > .chat_message_content {
    font-size: 12px;
    min-width: 150px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    color: var(--text-custom);
}
.chat_message_my div > .chat_message_content {
    font-size: 12px;
    min-width: 150px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    color: var(--text-custom);
}
.chat_message a:hover, .chat_message_my a:hover {
    color: var(--span-color);
}
.chat_role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-custom) !important;
}
.chat_nickname {
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    color: var(--default-text-color);
    transition: .5s;
    white-space: nowrap;
}
.chat_nickname:hover {
    color: var(--span-color);
}
.chat_message_block_info > stats {
    font-size: 8px;
    opacity: .1;
}
.reload-mess {
    display: flex;
    height: 100%;
    color: green;
    align-items: center;
    justify-content: center; 
}
.chat_no_msg {
    display: flex;
    height: 100%;
    color: red;
    align-items: center;
    justify-content: center;
}
.loader-50px {
    width: 50px;
    height: 50px;
    border: 5px solid;
    border-color: var(--span) transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation-loader 1s linear infinite;
}
@keyframes rotation-loader {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
.chat_message_block_info {
    display: flex;
    justify-content: space-between;
}
.chat_flex {
    display: flex;
    gap: 8px;
}
.chat_nickdate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.chat_nickdate .chat_nickname_wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat_nickdate .chat_date {
    font-size: 10px;
    opacity: .3;
    color: var(--text-default);
}
.chat_nicktext {
    display: grid;
    gap: 5px;
    width: 100%;
}
.chat_info .del_chat {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-2);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    padding: 3px;
    cursor: pointer;
    transition: .5s;
}
.chat_info .del_chat svg {
    width: 10px;
    height: 10px;
    fill: var(--text-custom);
    transition: .5s;
}
.chat_info .del_chat:hover svg {
    fill: var(--red);
}
/* Эффект блюра и иконка удаления по центру при наведении (только для админки) */
.chat_message .del_chat,
.chat_message_my .del_chat {
    display: none !important;
}
.chat_message:hover .del_chat,
.chat_message_my:hover .del_chat {
    display: flex !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--button-2);
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}
.chat_message:hover .del_chat svg,
.chat_message_my:hover .del_chat svg {
    width: 16px;
    height: 16px;
    fill: var(--text-custom);
}
.chat_message:hover .del_chat:hover svg {
    fill: var(--red);
}
/* Блюр всего содержимого сообщения при наведении только для админов (есть кнопка удаления) */
.chat_message.has-delete:hover .padding,
.chat_message_my.has-delete:hover .padding {
    filter: blur(2px);
    transition: filter 0.3s ease;
}
.chat_info stats {
    font-size: 10px;
    opacity: .3;
}
.chat-role-player svg {
    width: 12px;
    height: 12px;
}
.time_sec_msg {
    color: var(--text-default);
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    #chat_main_content {
        height: 300px;
    }
    .chat_footer_send {
        flex-wrap: wrap;
        padding-bottom: 20px;
    }
    .chat_footer_send > button {
        width: 36px;
        height: 36px;
        position: relative;
        z-index: 10001;
    }
    .chat_footer_send {
        flex-wrap: wrap;
        padding-bottom: 30px;
        position: relative;
        z-index: 10001;
    }
    .chat_message div > .chat_message_content,
    .chat_message_my div > .chat_message_content {
        font-size: 11px;
    }
    .chat_nickname {
        font-size: 12px;
    }
}

/* ==================== НОВЫЙ ДИЗАЙН ЧАТ-ВИДЖЕТА ==================== */
/* Основной контейнер чата - фиксирован в правом нижнем углу */
.chat-sidebar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease, height 0.3s ease, border-radius 0.3s ease, background 0.1s ease 0.2s, border 0.1s ease 0.2s, box-shadow 0.1s ease 0.2s;
    transform: translateY(0);
    opacity: 1;
}

/* Свернутое состояние - только круглая кнопка */
.chat-sidebar--collapsed {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: visible;
    background: var(--span);
    border: none;
    box-shadow: 0 4px 20px rgba(74, 222, 128, 0.4);
}

.chat-sidebar--collapsed .chat-sidebar__header,
.chat-sidebar--collapsed .chat-sidebar__content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Круглая кнопка чата */
.chat-sidebar__collapsed-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--span);
    cursor: pointer;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.1s ease 0.3s;
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel:hover::before {
    opacity: 1;
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel:hover {
    background: var(--span-color);
    box-shadow: 0 6px 25px rgba(74, 222, 128, 0.6);
    transform: scale(1.05);
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel svg {
    width: 28px;
    height: 28px;
    fill: white;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel:hover svg {
    transform: scale(1.1);
}

/* Заголовок чата */
.chat-sidebar__header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card);
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.chat-sidebar__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--default-text-color);
}

/* Контент чата */
.chat-sidebar__content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: var(--card);
    gap: 15px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Адаптация существующих стилей под новый виджет */

.chat-sidebar #chat_main_content {
    flex: 1;
    height: auto;
    max-height: none;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-sidebar .chat_footer_send {
    margin-top: auto;
}

/* Улучшенные стили для содержимого чата */

.chat_message, .chat_message_my {
    border: none;
    border-radius: 12px;
    padding: 12px;
    background: var(--card-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat_message:hover, .chat_message_my:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat_message .padding, .chat_message_my .padding {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.chat_message .chat_info, .chat_message_my .chat_info {
    height: auto;
    margin-bottom: 8px;
}

.chat_message div > .chat_message_content,
.chat_message_my div > .chat_message_content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-custom);
    min-width: auto;
}

.chat_nickname {
    font-size: 14px;
    font-weight: 700;
}

.chat_role {
    font-size: 11px;
    opacity: 0.8;
}

.block-chat-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.block-chat-online {
    margin-top: 15px;
    display: none;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.chat_footer_send {
    gap: 12px;
    align-items: center;
}

#chat_send_message > textarea {
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 14px;
    background: var(--input-form);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s;
}

#chat_send_message > textarea:focus {
    border-color: var(--span);
    outline: none;
}

.chat_footer_send > button {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--span);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

.chat_footer_send > button:hover {
    background: var(--span-color);
}

.chat_footer_send > button > svg {
    fill: white;
    width: 20px;
    height: 20px;
}

/* Скрываем ненужные элементы */
.chat_background {
    display: none;
}

/* Кнопка открытия чата вне панели (плавающая) - уже не нужна, т.к. есть collapsed панель */
.chat-open-floating {
    display: none;
}


/* Уменьшение аватарок в сообщениях */
.chat_message div > a > img,
.chat_message_my div > a > img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

/* Стили для смайликов */
.chat_menu_smile {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 0;
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    width: 250px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chat_menu_smile.active {
    display: flex;
}

.chat_menu_smile a {
    display: inline-block;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: background 0.2s, transform 0.2s;
}

.chat_menu_smile a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.chat_smile_btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--input-form);
    transition: background 0.3s;
}

.chat_smile_btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat_smile_btn svg {
    fill: var(--text-custom);
    width: 20px;
    height: 20px;
}


/* Стили для кнопки уведомлений - стильный колокольчик */
.chat-notifications-toggle {
    background: none;
    border: none;
    color: #4ade80; /* зелёный по умолчанию (уведомления включены) */
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: color 0.3s, opacity 0.2s;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.chat-notifications-toggle:hover {
    opacity: 0.8;
}

.chat-notifications-icon {
    fill: currentColor;
    transition: fill 0.2s;
}

/* Цвет кнопки при выключенных уведомлениях */
.chat-notifications-toggle.notifications-off {
    color: #ef4444;
}

.chat-notifications-toggle.notifications-off:hover .chat-notifications-icon {
    opacity: 0.9;
}

/* Управление видимостью иконок */
.chat-notifications-toggle .chat-notifications-on {
    display: inline-block;
}
.chat-notifications-toggle .chat-notifications-off {
    display: none;
}
.chat-notifications-toggle.notifications-off .chat-notifications-on {
    display: none;
}
.chat-notifications-toggle.notifications-off .chat-notifications-off {
    display: inline-block;
}


/* Кнопка сворачивания/разворачивания чата */
.chat-sidebar__toggle {
    background: none;
    border: none;
    color: var(--text-custom);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
    margin-left: auto;
}

.chat-sidebar__toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .chat-sidebar {
        width: calc(100% - 40px);
        height: 55vh;
        bottom: 80px;
        right: 20px;
        left: 20px;
        margin: 0 auto;
        z-index: 10000;
    }
    
    .chat-sidebar--collapsed {
        width: 60px;
        height: 60px;
        right: 20px;
        bottom: 80px;
        left: auto;
    }
    
    
    #chat_main_content {
        height: 300px;
    }
    
    .chat_footer_send {
        position: relative;
        z-index: 10002;
        padding-bottom: 20px;
    }
    .chat_footer_send > button {
        z-index: 10003;
    }
    .chat_smile_btn {
        position: relative;
        z-index: 10002;
    }
}

/* Анимация появления круглешка чата */
@keyframes chatCircleEntrance {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    70% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes chatCirclePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(74, 222, 128, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

.chat-sidebar--collapsed .chat-sidebar__collapsed-panel {
    animation:
        chatCircleEntrance 0.6s ease-out,
        chatCirclePulse 2s ease-in-out 0.6s infinite;
}

/* Анимация появления чата */
@keyframes chatSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-sidebar:not(.chat-sidebar--collapsed) {
    animation: chatSlideUp 0.3s ease;
}
