/* ============================================================
   🔵 КНОПКА ОТКРЫТИЯ ЧАТА
============================================================ */
#cw-open-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 62px;
    height: 62px;
    background: #ff7a00;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 999999;
    transition: 0.25s ease;
}

#cw-open-btn:hover {
    transform: scale(1.07);
}

#cw-open-btn svg {
    width: 28px;
    height: 28px;
}

#cw-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    background: #ff2b2b;
    border-radius: 50%;
    display: none;
    box-shadow: 0 0 6px rgba(0,0,0,0.35);
}


/* ============================================================
   🟦 КОНТЕЙНЕР ЧАТА
============================================================ */
#cw-chat-box {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 330px;
    height: 480px;
    background: #ffffff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    z-index: 999999;
    animation: cwFadeIn 0.25s ease;
}

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


/* ============================================================
   🟧 HEADER
============================================================ */
#cw-header {
    background: linear-gradient(135deg, #ff7e00, #ff5500);
    padding: 14px;
    color: #fff;
    font-size: 17px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

#cw-close {
    cursor: pointer;
    font-size: 22px;
}

#cw-close:hover {
    transform: scale(1.15);
}


/* ============================================================
   💬 ОКНО СООБЩЕНИЙ
============================================================ */
#cw-chat-window {
    flex: 1;
    padding: 14px;
    background: #f7f7f7;
    overflow-y: auto;
}

#cw-chat-window::-webkit-scrollbar {
    width: 6px;
}

#cw-chat-window::-webkit-scrollbar-thumb {
    background: #c6c6c6;
    border-radius: 3px;
}


/* ============================================================
   💭 СООБЩЕНИЯ
============================================================ */
.cw-msg {
    margin: 10px 0;
    max-width: fit-content;
}

.cw-user {
    margin-left: auto;
}

.cw-user .cw-bubble {
    background: #c9ffcf;
    padding: 10px 16px;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.10);
}

.cw-op {
    margin-right: auto;
}

.cw-op .cw-bubble {
    background: #ececec;
    padding: 10px 16px;
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.10);
}

/* ============================================================
   📎 ФАЙЛЫ В ЧАТЕ (нормальный вид)
============================================================ */

#cw-chat-window .cw-bubble.cw-file{
    padding: 10px 14px;
}

#cw-chat-window .cw-bubble.cw-file a{
    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: #1f6feb;
    text-decoration: none;
    font-weight: 600;

    background: transparent;
    border: none;
    padding: 0;

    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

#cw-chat-window .cw-bubble.cw-file a:hover{
    text-decoration: underline;
}

#cw-chat-window .cw-bubble.cw-file a:visited{
    color: #1f6feb;
}

/* ============================================================
   ⚠️ СИСТЕМНЫЕ
============================================================ */
.cw-system {
    width: 100%;
    display: block;
}

.cw-system .cw-bubble {
    background: #ffe5ba;
    color: #8a5a00;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    max-width: 80%;
    margin: 8px auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
    border-left: 3px solid #ff9000;
}


/* ============================================================
   ⌨️ ПАНЕЛЬ ВВОДА — ВЫРОВНЕНА НА ОДИН УРОВЕНЬ
============================================================ */

/* ВАЖНО: сбрасываем влияние темы на input/button внутри панели */
#cw-input-box,
#cw-input-box * {
    box-sizing: border-box;
}

#cw-input-box input,
#cw-input-box button {
    margin: 0 !important;
}

/* Панель */
#cw-input-box {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #ddd;
    background: #fff;
}

/* Обёртка под input + скрепку */
.cw-input-wrapper {
    position: relative;
    flex: 1;
    height: 40px;
}

/* Поле ввода */
#cw-input {
    width: 100%;
    height: 40px !important;

    padding: 0 44px 0 12px;
    border-radius: 10px;
    border: 1px solid #bbb;

    font-size: 14px;
    line-height: 40px;
    background: #fff;
}

/* Скрепка внутри */
#cw-file-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);

    width: 22px;
    height: 22px;

    border: none;
    background: transparent;

    font-size: 18px;
    line-height: 1;
    color: #8a8a8a;

    cursor: pointer;
    padding: 0;
}

/* Кнопка отправки */
#cw-send {
    width: 46px !important;
    min-width: 46px !important;
    height: 40px !important;

    padding: 0 !important;
    border: 1px solid transparent !important;

    border-radius: 8px;
    background: #ff9800;
    color: #fff;

    font-size: 18px;
    line-height: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;

    transition: 0.2s ease;
}

#cw-send:hover {
    background: #ff6a00;
    transform: scale(1.05);
    border-color: transparent;
}


/* ============================================================
   🆕 НОВЫЙ ДИАЛОГ
============================================================ */
#cw-new-dialog-btn {
    padding: 10px;
    text-align: center;
    background: #f2f2f2;
    border-top: 1px solid #ddd;
    cursor: pointer;
}

#cw-new-dialog-btn:hover {
    background: #e4e4e4;
}

#cw-new-dialog-btn.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}


/* ============================================================
   🔤 ШРИФТ ROBOTO ДЛЯ ЧАТА
============================================================ */
#cw-chat-box,
#cw-chat-box * {
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
}


/* ============================================================
   🖼 УВЕЛИЧЕНИЕ КАРТИНОК ОПЕРАТОРА (LIGHTBOX)
   ✅ картинка по центру
   ✅ X в правом верхнем углу картинки
============================================================ */

#cw-img-modal{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1000000;
    display: none;
    padding: 16px;
}

/* слой, который центрирует */
#cw-img-modal .cw-img-modal-inner{
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;   /* ✅ вертикально центр */
    justify-content: center; /* ✅ горизонтально центр */
}

/* обёртка по размеру картинки — тут якорим X */
#cw-img-modal .cw-img-modal-wrap{
    position: relative;
    width: fit-content;
    height: fit-content;
    max-width: min(900px, 96vw);
    max-height: 90vh;
}

/* сама картинка */
#cw-img-modal .cw-img-modal-img{
    max-width: min(900px, 96vw);
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.45);
    background: #fff;
    display: block;
}

/* X в углу картинки */
#cw-img-modal .cw-img-modal-close{
    position: absolute;
    top: 10px;
    right: 10px;

    width: 38px;
    height: 38px;

    border: none;
    border-radius: 999px;

    background: rgba(255,255,255,0.92);
    color: #000;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 2;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

#cw-img-modal .cw-img-modal-close:hover{
    transform: scale(1.06);
}

#cw-chat-window .cw-op img { cursor: zoom-in; }

/* ============================================================
   📱 АДАПТИВ
============================================================ */
@media (max-width: 480px) {
    #cw-chat-box {
        width: 100%;
        height: 80%;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
}