/* ==========================================================================
   SUPPORT CHAT - OPTIMIZED FOR DELTA THEME (OSCLASS 8.3.1)
   ========================================================================== */

/* Полный сброс для предотвращения искажения размеров элементов темы */
#sc-global-wrapper,
#sc-global-wrapper *,
#sc-global-wrapper *::before,
#sc-global-wrapper *::after {
    box-sizing: border-box;
}

/* Глобальная обертка чата для изоляции слоев */
#sc-global-wrapper {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999998 !important;
    font-family: Arial, sans-serif;
    pointer-events: none; /* Чтобы обертка не блокировала клики по сайту */
}

/* КНОПКА ОТКРЫТИЯ ЧАТА (Приподнята на 70px) */
#sc-open {
    position: fixed;
    bottom: 70px;
    right: 20px;
    background: #2d7ef7;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    cursor: pointer;
    z-index: 999999 !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.3px;
    transition: background 0.2s ease, transform 0.2s ease;
    pointer-events: auto; /* Возвращаем кликабельность кнопке */
}

#sc-open:hover {
    background: #1a6be3;
    transform: translateY(-2px);
}

#sc-open:active {
    transform: translateY(0);
}

/* ОСНОВНОЕ ОКНО ЧАТА */
#sc-box {
    position: fixed;
    bottom: 135px; /* Смещено выше кнопки, чтобы не перекрывать её */
    right: 20px;
    width: 340px;
    height: 460px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 160px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    display: none; /* Управляется через JS или класс .active */
    flex-direction: column;
    z-index: 999999 !important;
    pointer-events: auto; /* Возвращаем кликабельность окну */
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Состояние при открытом чате */
#sc-box.active {
    display: flex !important;
}

/* ШАПКА ОКНА ЧАТА */
#sc-header {
    padding: 14px 16px;
    background: #2d7ef7;
    color: #fff;
    font-weight: bold;
    font-size: 15px;
    letter-spacing: 0.4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* ФОРМА АВТОРИЗАЦИИ / СТАРТА */
#sc-start {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    background: #fff;
}

#sc-start .sc-title {
    font-weight: bold;
    margin-bottom: 16px;
    font-size: 15px;
    color: #333;
    line-height: 1.4;
}

#sc-start label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

#sc-start label span {
    color: #ea4335;
    margin-left: 2px;
}

#sc-start input,
#sc-start textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #fcfcfc;
    transition: border-color 0.15s ease, background 0.15s ease;
}

#sc-start input:focus,
#sc-start textarea:focus {
    border-color: #2d7ef7;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(45, 126, 247, 0.15);
}

#sc-start textarea {
    resize: none;
    height: 90px;
}

#sc-start button {
    width: 100%;
    padding: 12px;
    background: #2d7ef7;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    margin-top: 6px;
    transition: background 0.2s ease;
}

#sc-start button:hover {
    background: #1a6be3;
}

/* ОБЛАСТЬ ЧАТА С СООБЩЕНИЯМИ */
#sc-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f4f6f9;
}

/* СПИСОК СООБЩЕНИЙ */
#sc-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f4f6f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ПУЗЫРИ СООБЩЕНИЙ */
#sc-messages div {
    background: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-break: break-word;
    align-self: flex-start; /* По умолчанию сообщения слева (поддержка) */
    border-bottom-left-radius: 4px;
}

/* Стилизация сообщений от самого пользователя, если применимо */
#sc-messages div.user-msg {
    background: #d2e3fc;
    color: #124116;
    align-self: flex-end;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

/* ФОРМА ОТПРАВКИ СООБЩЕНИЯ В ЧАТЕ */
#sc-form {
    display: flex;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e8ebed;
    gap: 8px;
    align-items: center;
}

#sc-form textarea {
    flex: 1;
    height: 40px;
    padding: 10px 12px;
    border: 1px solid #ccd0d5;
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    line-height: 18px;
    color: #333;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

#sc-form textarea:focus {
    border-color: #2d7ef7;
}

#sc-form button {
    background: #2d7ef7;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    height: 40px;
    transition: background 0.15s ease, transform 0.1s ease;
}

#sc-form button:hover {
    background: #1a6be3;
}

#sc-form button:active {
    transform: scale(0.96);
}

/* Адаптивность под мелкие мобильные экраны темы Delta */
@media screen and (max-width: 480px) {
    #sc-open {
        bottom: 65px;
        right: 15px;
        padding: 10px 18px;
        font-size: 13px;
    }
    
    #sc-box {
        bottom: 125px;
        right: 15px;
        width: calc(100vw - 30px);
        height: 400px;
    }
	
/* ==========================================
   НОВЫЕ СООБЩЕНИЯ USER / ADMIN
========================================== */

.admin-msg{
    background:#ffffff;
    color:#333;
    align-self:flex-start;
    border-bottom-left-radius:4px;
    border:1px solid #dcdcdc;
}

.user-msg{
    background:#d2e3fc;
    color:#222;
    align-self:flex-end;
    border-bottom-right-radius:4px;
}

.sc-text{
    font-size:14px;
    line-height:1.4;
    word-break:break-word;
}

.sc-time{
    margin-top:5px;
    font-size:11px;
    color:#888;
    text-align:right;
}

/* полоска прокрутки */

#sc-messages::-webkit-scrollbar{
    width:8px;
}

#sc-messages::-webkit-scrollbar-track{
    background:#f1f1f1;
}

#sc-messages::-webkit-scrollbar-thumb{
    background:#c1c1c1;
    border-radius:10px;
}

#sc-messages::-webkit-scrollbar-thumb:hover{
    background:#999;
}
}