/* ========== ОНЛАЙН-ЧАТ ГБ №4 (кнопка + окно) ========== */
.gb4chat-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1400;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #f08c1f, #e0760a);
    color: #fff;
    font-size: 29px;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(240, 140, 31, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s;
    animation: gbcFabIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.8s both, gbcFabPulse 8s cubic-bezier(0.4, 0, 0.2, 1) 4s infinite;
}
.gb4chat-fab:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 14px 34px rgba(240, 140, 31, 0.55); }
@keyframes gbcFabIn { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: none; } }
/* Пульс-кольцо раз в 8 секунд — привлекает внимание к кнопке чата */
@keyframes gbcFabPulse {
    0%   { box-shadow: 0 10px 28px rgba(240, 140, 31, 0.45), 0 0 0 0 rgba(240, 140, 31, 0.55); }
    14%  { box-shadow: 0 10px 28px rgba(240, 140, 31, 0.45), 0 0 0 18px rgba(240, 140, 31, 0); }
    100% { box-shadow: 0 10px 28px rgba(240, 140, 31, 0.45), 0 0 0 0 rgba(240, 140, 31, 0); }
}

/* Всплывающая подсказка о чате возле кнопки */
.gb4chat-hint {
    position: fixed;
    right: 22px;
    bottom: 100px;
    z-index: 1420;
    max-width: 300px;
    background: #fff;
    border: 1.5px solid #ffd9a8;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 16px 44px rgba(8, 42, 66, 0.28), 0 0 0 4px rgba(240, 140, 31, 0.12);
    padding: 14px 34px 14px 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.94);
    transform-origin: bottom right;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.4s;
    cursor: pointer;
    animation: gbcHintFloat 2.6s ease-in-out infinite;
}
.gb4chat-hint.show { opacity: 1; visibility: visible; transform: none; }
@keyframes gbcHintFloat { 0%, 100% { margin-bottom: 0; } 50% { margin-bottom: 6px; } }
.gb4chat-hint b { display: block; font-size: 14px; color: #e0760a; margin-bottom: 4px; }
.gb4chat-hint span { display: block; font-size: 12.5px; color: #4a5c6b; line-height: 1.5; }
.gb4chat-hint .gbc-hint-x {
    position: absolute; top: 6px; right: 8px;
    width: 22px; height: 22px;
    border: none; border-radius: 50%;
    background: #f2f6f9; color: #7f8c8d;
    font-size: 14px; line-height: 1; cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.gb4chat-hint .gbc-hint-x:hover { background: #ffe3c2; color: #e0760a; }
/* Иконка чата всегда на кнопке — при открытии окна не исчезает */
.gb4chat-fab .gbc-fab-badge {
    position: absolute; top: -3px; right: -3px;
    min-width: 19px; height: 19px; border-radius: 10px;
    background: #e74c3c; color: #fff; font-size: 11px; font-weight: 800;
    display: none; align-items: center; justify-content: center;
    border: 2px solid #fff; padding: 0 5px;
}
.gb4chat-fab .gbc-fab-badge.show { display: flex; }
.gb4chat-fab .gbc-fab-ic { transition: transform 0.3s; }
.gb4chat-fab.open .gbc-fab-ic { transform: rotate(90deg); }

.gb4chat-window {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 1450;
    width: min(380px, calc(100vw - 28px));
    height: min(560px, calc(100vh - 120px));
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(8, 42, 66, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1), transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.32s,
        width 0.35s cubic-bezier(0.22, 1, 0.36, 1), height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        right 0.35s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.gb4chat-window.open {
    opacity: 1; visibility: visible; transform: none;
}
/* Развернутое окно — на всю страницу, с мягкими тенями по всем сторонам */
.gb4chat-window.gb4chat-expanded {
    right: 50%;
    bottom: 50%;
    transform: translate(50%, 50%) !important;
    width: min(96vw, 1400px);
    height: min(92vh, calc(100vh - 48px));
    border-radius: 26px;
    box-shadow:
        -30px 0 80px rgba(8, 42, 66, 0.22),
        30px 0 80px rgba(8, 42, 66, 0.22),
        0 -30px 80px rgba(8, 42, 66, 0.22),
        0 30px 80px rgba(8, 42, 66, 0.28),
        0 0 120px rgba(8, 42, 66, 0.14);
}
/* transform не конфликтует с состоянием «открыто»: центр держим всегда */
.gb4chat-window.gb4chat-expanded.open { opacity: 1; visibility: visible; transform: translate(50%, 50%); }
.gb4chat-window.gb4chat-expanded .gb4chat-msgs { padding: 22px 26px; }
.gb4chat-window.gb4chat-expanded .gbc-bubble { max-width: 62%; font-size: 14.5px; }

.gb4chat-head {
    background: linear-gradient(135deg, #0a5c8e, #064269);
    color: #fff;
    padding: 9px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}
.gb4chat-head .gbc-ava {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,0.16);
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; flex: none;
}
.gb4chat-head .gbc-tt { flex: 1; min-width: 0; }
.gb4chat-head b { display: block; font-size: 14px; }
.gb4chat-head small { display: flex; align-items: center; gap: 6px; font-size: 11px; opacity: 0.85; }
.gb4chat-head small .gbc-dot {
    width: 7px; height: 7px; border-radius: 50%; background: #6fd98a;
    animation: gbcPulse 2s ease-in-out infinite;
}
@keyframes gbcPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(111,217,138,0.6); } 50% { box-shadow: 0 0 0 5px rgba(111,217,138,0); } }
/* Точка «не в сети» — серая, без пульсации */
.gb4chat-head .gbc-dot.gbc-dot--off { background: #9aa7b1; animation: none; }
.gb4chat-head .gbc-dot.gbc-dot--off,
.gb4chat-head .gb4chat-offline .gbc-dot { box-shadow: none; }
/* Кнопки шапки чата: свернуть/развернуть */
.gb4chat-head .gbc-min,
.gb4chat-head .gbc-max {
    background: rgba(255,255,255,0.14); border: none; color: #fff;
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    font-size: 13px; transition: background 0.2s, transform 0.2s; flex: none;
    display: flex; align-items: center; justify-content: center;
}
.gb4chat-head .gbc-min:hover,
.gb4chat-head .gbc-max:hover { background: rgba(255,255,255,0.28); transform: scale(1.08); }
.gb4chat-head .gbc-max { font-size: 15px; }

.gb4chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f2f6f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.gbc-msg { display: flex; max-width: 100%; }
.gbc-msg--user { justify-content: flex-end; }
.gbc-msg--bot, .gbc-msg--operator { justify-content: flex-start; }
.gbc-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    animation: gbcMsgIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes gbcMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.gbc-msg--user .gbc-bubble {
    background: linear-gradient(135deg, #f08c1f, #e0760a);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.gbc-msg--bot .gbc-bubble {
    background: #fff;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(10,92,142,0.08);
}
.gbc-msg--operator .gbc-bubble {
    background: #e8f2fb;
    color: #12293c;
    border-bottom-left-radius: 6px;
}
.gbc-who { display: block; font-size: 11px; font-weight: 700; color: #0a5c8e; margin-bottom: 3px; }
.gbc-msg--user .gbc-who { color: rgba(255,255,255,0.85); }
.gbc-bubble a { color: #0a5c8e; font-weight: 600; }
.gbc-msg--user .gbc-bubble a { color: #ffe3c2; }
.gbc-bubble time { display: block; font-size: 10px; opacity: 0.6; margin-top: 4px; text-align: right; }

.gb4chat-quick {
    display: flex; gap: 5px; padding: 0 10px 8px;
    flex-wrap: nowrap; overflow-x: auto; flex: none; background: #f2f6f9;
    scrollbar-width: none; /* все шаблоны помещаются в строку — без прокрутки */
}
.gb4chat-quick::-webkit-scrollbar { display: none; }
.gbc-q {
    background: linear-gradient(135deg, #ffffff, #f4f9fd);
    border: 1.5px solid #d9e4ec; color: #0a5c8e;
    border-radius: 20px; padding: 6px 12px; font-size: 11.5px; font-weight: 700;
    cursor: pointer; transition: all 0.2s; font-family: inherit;
    white-space: nowrap; flex: none;
    box-shadow: 0 1px 3px rgba(10, 92, 142, 0.08);
    line-height: 1.35;
}
.gbc-q:hover {
    background: linear-gradient(135deg, #0a5c8e, #0d6ea8);
    border-color: #0a5c8e; color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(10, 92, 142, 0.3);
}
.gbc-q:active { transform: translateY(0); }

.gb4chat-input-row {
    flex: none;
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #fff;
    border-top: 1px solid #e8eef4;
}
.gb4chat-input-row input {
    flex: 1;
    border: 1.5px solid #d9e4ec;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.gb4chat-input-row input:focus { outline: none; border-color: #f08c1f; }
.gb4chat-input-row button {
    width: 42px; height: 42px; flex: none;
    border: none; border-radius: 50%;
    background: linear-gradient(135deg, #0a5c8e, #0d6ea8);
    color: #fff; font-size: 16px; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 10px rgba(10, 92, 142, 0.35);
    display: flex; align-items: center; justify-content: center;
    padding: 0 0 1px;
}
.gb4chat-input-row button:hover { transform: scale(1.08); box-shadow: 0 5px 16px rgba(10, 92, 142, 0.45); }
.gb4chat-input-row button:active { transform: scale(0.96); }

/* Статус доставки/прочтения сообщения пациента */
.gbc-status {
    display: block;
    font-size: 9.5px;
    opacity: 0.75;
    margin-top: 3px;
    text-align: right;
}
.gbc-status--read { opacity: 1; color: #bfe8cd; }
.gbc-msg--user .gbc-status--read { color: #ffe3c2; }

/* Мобильная версия окна чата */
@media (max-width: 768px) {
    .gb4chat-fab { right: 14px; bottom: 14px; width: 56px; height: 56px; font-size: 25px; }
    .gb4chat-window {
        right: 8px; bottom: 80px;
        width: calc(100vw - 16px);
        height: min(66vh, 520px);
        border-radius: 18px;
    }
    /* Развернутое окно на мобильном — вся страница, без щелей */
    .gb4chat-window.gb4chat-expanded {
        right: 50%; bottom: 50%;
        transform: translate(50%, 50%) !important;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
    .gb4chat-window.gb4chat-expanded.open { transform: translate(50%, 50%); }
    /* Кнопка «на весь экран» на мобильном скрыта (JS дублирует через hidden) */
    .gb4chat-head .gbc-max { display: none; }
    .gb4chat-hint { right: 14px; bottom: 84px; max-width: calc(100vw - 40px); }
}

/* Кнопка «наверх» на мобильном: ровно на уровне кнопки чата (та же нижняя линия) */
@media (max-width: 768px) {
    .scroll-top {
        right: 14px;
        bottom: 14px;
        width: 52px;
        height: 52px;
        font-size: 24px;
        transform: translateX(0) scale(0.4);
    }
    .scroll-top.visible { transform: none; }
    /* выезд остаётся из-под кнопки чата: слой ниже кнопки */
    .scroll-top { z-index: 998; }
}

/* ---------- Форма «Имя + Телефон» в чате ---------- */
.gbc-contact {
    margin: 8px 12px;
    padding: 12px;
    background: #f2f8fd;
    border: 1px solid #d5e8f7;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    animation: gbcContactIn 0.3s cubic-bezier(0.22,1,0.36,1);
}
@keyframes gbcContactIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.gbc-contact__title { font-weight: 700; font-size: 13px; color: #0a5c8e; }
.gbc-contact__hint { font-size: 11.5px; color: #6b7d8c; line-height: 1.45; }
.gbc-contact input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1.5px solid #cfe0ee;
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: #22333f;
    outline: none;
    transition: border-color 0.2s;
}
.gbc-contact input:focus { border-color: #0a5c8e; }
.gbc-contact__err { font-size: 11.5px; color: #c0392b; }
.gbc-contact__btns { display: flex; gap: 8px; }
.gbc-contact__send {
    flex: 1;
    padding: 9px 12px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #0a5c8e, #0d6ea8);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(10, 92, 142, 0.25);
    letter-spacing: 0.2px;
}
.gbc-contact__send:hover { box-shadow: 0 5px 14px rgba(10, 92, 142, 0.35); transform: translateY(-1px); }
.gbc-contact__send:active { transform: translateY(0); }
.gbc-contact__skip {
    padding: 9px 14px;
    border: 1.5px solid #cfe0ee;
    border-radius: 12px;
    background: #fff;
    color: #6b7d8c;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.gbc-contact__skip:hover { background: #f2f8fd; border-color: #9fc2dd; color: #0a5c8e; }
.gb4chat-offline .gbc-contact { background: #f6f7f9; border-color: #e2e6ea; }
