/* ===== L7Chat floating widget styles ===== */

/* --- Layout --- */
#l7chat-window {
    display: none;
    position: fixed;
    z-index: 999999;
    background: white;
    border-radius: 24px;
    overflow: hidden;
    flex-direction: column;
    box-shadow: 0 25px 70px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    transition: box-shadow 0.3s, border-color 0.3s;
    width: 600px;
    /* Высоту по контенту выставляет widget.js (репорт из iframe). До репорта —
       компактный дефолт, НЕ на весь экран (раньше было 97vh). */
    height: min(560px, 85vh);
    max-height: 85vh;
    min-height: 300px;
    min-width: 320px;
    max-width: 95vw;
    top: 2vh;
    right: 30px;
    bottom: auto;
    left: auto;
}
.l7chat-resize-handle {
    position: absolute;
    z-index: 10;
}
.l7chat-resize-handle--left   { left: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.l7chat-resize-handle--right  { right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.l7chat-resize-handle--top    { top: 0; left: 0; right: 0; height: 6px; cursor: ns-resize; }
.l7chat-resize-handle--bottom { bottom: 0; left: 0; right: 0; height: 6px; cursor: ns-resize; }
.l7chat-resize-handle--top-left     { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.l7chat-resize-handle--top-right    { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.l7chat-resize-handle--bottom-left  { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.l7chat-resize-handle--bottom-right { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }

#l7chat-window .l7w-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    /* Кнопки уехали вниз → шапке резерва по бокам не нужно. */
    padding: 18px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 11px;
    border-bottom: none;
    cursor: grab;
    user-select: none;
    min-height: 90px;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    position: relative;
}
#l7chat-window .l7w-header:active { cursor: grabbing; }

.l7w-header-spacer { display: none; }
.l7w-header-center { display: contents; }

.l7w-header-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    min-width: 0;
    text-align: center;
}

.l7w-header-title {
    font-weight: 800;
    font-size: 16px;
    line-height: 1.1;
    letter-spacing: 0.2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.22);
    white-space: nowrap;
    color: #fff;
}

.l7w-header-subtitle {
    font-size: 12px;
    line-height: 1.2;
    opacity: 0.78;
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
    margin-bottom: 4px;
}

.l7w-header-status {
    font-size: 12px;
    opacity: 0.95;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    padding: 5px 12px;
    border-radius: 16px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.25);
    font-weight: 500;
    letter-spacing: 0.2px;
    max-width: 100%;
    text-align: center;
}
.l7w-header-status > #l7chat-work-status {
    /* Полный текст без сокращений: «сейчас открыто · до закрытия осталось
       10 часов 33 минуты». Разрешаем перенос на 2 строки, никакого ellipsis. */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    display: inline-block;
    line-height: 1.25;
    max-width: 360px;
}
@media (max-width: 480px) {
    .l7w-header-status > #l7chat-work-status {
        max-width: 230px;
        font-size: 11.5px;
    }
}

/* ── Маркер «открыто/закрыто»: пульсирующий цветной кружок ──
   Цвет и тень-glow ставит JS (зелёный для open, красный для closed). */
.l7w-online-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,.25), 0 0 14px rgba(34,197,94,.65);
    animation: l7wDotPulse 2s ease-in-out infinite;
}
.l7w-header-status.is-closed .l7w-online-dot {
    animation: l7wDotPulseRed 2.4s ease-in-out infinite;
}
@keyframes l7wDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.18); opacity: .9; }
}
@keyframes l7wDotPulseRed {
    0%, 100% { transform: scale(1); opacity: .95; }
    50%      { transform: scale(1.1); opacity: .7; }
}

/* Разделитель «·» между частями статуса — крупный, мягкий, по вертикали
   центрирован, чуть полупрозрачный. */
.l7w-header-status .l7w-sep {
    display: inline-block;
    margin: 0 8px;
    font-weight: 800;
    color: rgba(255,255,255,.55);
    transform: translateY(-1px);
    letter-spacing: 0;
}

.l7w-header-sep { opacity: 0.6; }

/* Бейдж «Админ» — золотой пилюля под статусом онлайн.
   Виден только когда widget.js получил admin-cookie через /api/chatbot/admin-status. */
.l7w-admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 800;
    color: #92400e;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid rgba(245,158,11,.45);
    border-radius: 999px;
    letter-spacing: .03em;
    text-transform: uppercase;
    box-shadow: 0 2px 6px -2px rgba(245,158,11,.45);
    white-space: nowrap;
}
.l7w-admin-badge[hidden] { display: none !important; }
.l7w-admin-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border-radius: 50%;
    background: rgba(245,158,11,.18);
    color: #92400e !important;
    font-size: 11px;
    text-decoration: none !important;
    font-weight: 800;
    transition: background .12s, transform .08s;
}
.l7w-admin-logout:hover {
    background: rgba(220,38,38,.85);
    color: #fff !important;
    transform: scale(1.1);
}
html[data-theme="dark"] .l7w-admin-badge {
    background: linear-gradient(135deg, #78350f, #92400e);
    color: #fde68a;
    border-color: rgba(245,158,11,.55);
}
html[data-theme="dark"] .l7w-admin-logout {
    background: rgba(245,158,11,.25);
    color: #fde68a !important;
}

/* ── Кнопки управления — горизонтальная пилюля справа от заголовка
   «ИИ-помощник», на той же визуальной строке. Раньше был вертикальный
   столбик ниже шапки — теперь компактный inline-row. ── */
.l7w-header-actions {
    /* Кнопка «закрыть» перенесена в ряд с «Перезвоните/Сброс» (внутри iframe),
       поэтому в шапке её больше нет — заголовок и статус строго по центру. */
    display: none !important;
    position: absolute;
    top: 12px;         /* выровнено с первой строкой шапки */
    right: 10px;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 3px;
    background: var(--theme-card, #fff);
    border: 1px solid rgba(15,76,129,.18);
    border-radius: 999px;
    box-shadow: 0 6px 16px -6px rgba(15,23,42,.22), 0 2px 4px rgba(15,23,42,.06);
    z-index: 6;
}
.l7w-header-actions > button {
    color: #475569 !important;
}
.l7w-header-actions > button:hover { background: rgba(15,76,129,.08) !important; }
html[data-theme="dark"] .l7w-header-actions {
    background: rgba(30,41,59,.95);
    border-color: rgba(148,163,184,.22);
}
html[data-theme="dark"] .l7w-header-actions > button { color: #e2e8f0 !important; }
html[data-theme="dark"] .l7w-header-actions > button:hover { background: rgba(255,255,255,.08) !important; }
.l7w-header-actions > button {
    width: 28px; height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 140ms, transform 100ms, color 140ms;
}
.l7w-header-actions > button:hover { background: rgba(255,255,255,.22); }
.l7w-header-actions > button:active { transform: scale(.92); }
.l7w-header-actions .l7chat-svg-icon { width: 14px; height: 14px; }
#l7chat-close-btn {
    /* Кнопка живёт в пилюле .l7w-header-actions, у которой свой фон
       (светлый на light-теме, тёмный на dark) → собственные white-стили
       делали кнопку невидимой. Используем прозрачный фон + currentColor. */
    background: transparent;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: #475569;
    opacity: .85;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    padding: 0;
    font-size: 16px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    margin-left: 14px;
    margin-right: 6px;
}
/* Внутри pill-блока кнопки выглядят одинаково — переопределяем «крупные»
   стили #l7chat-close-btn / #l7chat-cache-btn. */
.l7w-header-actions > #l7chat-close-btn,
.l7w-header-actions > #l7chat-cache-btn {
    width: 30px !important; height: 30px !important;
    border: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.l7w-header-actions > #l7chat-close-btn:hover {
    background: rgba(220,38,38,.85) !important;
    transform: none !important;
}
.l7w-header-actions > #l7chat-cache-btn:hover,
.l7w-header-actions > #l7chat-theme-btn:hover {
    background: rgba(255,255,255,.22) !important;
    transform: none !important;
}
.l7w-header-actions .l7chat-svg-icon { width: 16px; height: 16px; }
#l7chat-close-btn:hover {
    background: rgba(124,58,237,.12);
    transform: scale(1.06) rotate(90deg);
    opacity: 1;
}
#l7chat-close-btn:active {
    transform: scale(0.94) rotate(90deg);
}
html[data-theme="dark"] #l7chat-close-btn {
    color: #e2e8f0;
}
html[data-theme="dark"] #l7chat-close-btn:hover {
    background: rgba(255,255,255,.12);
}
/* Mobile: гарантированно показываем кнопку (touch target ≥ 30px) */
@media (max-width: 768px) {
    #l7chat-close-btn {
        display: flex !important;
        width: 32px !important;
        height: 32px !important;
        color: #1e293b !important;
        opacity: 1 !important;
        background: rgba(255,255,255,.9) !important;
        border: 1.5px solid rgba(15,76,129,.25) !important;
        box-shadow: 0 4px 10px rgba(15,23,42,.15) !important;
    }
    html[data-theme="dark"] #l7chat-close-btn {
        color: #f1f5f9 !important;
        background: rgba(30,41,59,.95) !important;
        border-color: rgba(148,163,184,.4) !important;
    }
}

/* Кнопка «Очистить кэш и перезагрузить» в шапке виджета — слева от крестика */
#l7chat-cache-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    padding: 0;
    font-size: 13px;
    margin-left: 12px;
    margin-right: 0;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
#l7chat-cache-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(180deg);
    border-color: white;
}
#l7chat-cache-btn:active {
    transform: scale(0.95);
}
#l7chat-cache-btn[disabled] {
    opacity: 0.7;
    cursor: default;
}
/* SVG-иконки чата (inline, заменили FontAwesome). */
.l7chat-svg-icon { width: 16px; height: 16px; display: inline-block; vertical-align: middle; }
#l7chat-cache-btn.is-spinning .l7chat-svg-icon,
#l7chat-cache-btn .fa-spin {
    animation: l7w-cache-spin 0.8s linear infinite;
}
@keyframes l7w-cache-spin {
    to { transform: rotate(360deg); }
}

/* --- Loading indicator --- */
#l7chat-loading-indicator {
    display: none;
    position: absolute;
    top: 76px;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    z-index: 10000;
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid #eef2f6;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.l7w-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.l7w-loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.l7w-loading-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3498db;
    opacity: 0.6;
    animation: thinkingWave 1.8s infinite ease-in-out;
}
.l7w-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.l7w-loading-dot:nth-child(3) { animation-delay: 0.4s; }
.l7w-loading-dot:nth-child(4) { animation-delay: 0.6s; }
.l7w-loading-dot:nth-child(5) { animation-delay: 0.8s; }

.l7w-loading-text {
    font-size: 14px;
    color: #1e293b;
    font-weight: 600;
}

.l7w-loading-sub {
    font-size: 12px;
    color: #64748b;
}

/* --- Iframe body --- */
.l7w-iframe-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
    height: calc(100% - 76px);
    width: 100%;
    background: #ffffff;
    overflow: hidden;
}

#l7chat-iframe {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: white;
    flex: 1 1 auto;
    min-height: 0;
}
#l7chat-window.is-resizing #l7chat-iframe {
    pointer-events: none;
}

.l7w-bottom-bar {
    height: 4px;
    background: linear-gradient(90deg, #2c3e50, #3498db, #2c3e50);
    width: 100%;
    opacity: 0.8;
}

/* =====================================================
   FLOATING BUTTON - NEW DESIGN WITH ICON CAROUSEL
   ===================================================== */
#l7chat-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ee 100%);
    color: white;
    border: 4px solid white;
    cursor: pointer;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(52,152,219,0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    overflow: visible;
}

/* Clip icons inside the circle */
.l7chat-icon-carousel {
    overflow: hidden;
    border-radius: 50%;
}
#l7chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(52,152,219,0.6);
}
#l7chat-btn:active {
    transform: scale(0.95);
}

/* Icon carousel container */
.l7chat-icon-carousel {
    position: relative;
    width: 36px;
    height: 36px;
    z-index: 1;
}

.l7chat-icon-carousel .l7chat-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Fade-in: fast ease-out (appears quickly) */
.l7chat-icon-carousel .l7chat-icon.active {
    opacity: 1;
    transition: opacity 0.35s ease-out;
}

/* Fade-out: exponential decay (slow start, then drops fast) */
.l7chat-icon-carousel .l7chat-icon.fading-out {
    opacity: 0;
    transition: opacity 0.7s cubic-bezier(0.16, 0, 0.84, 0.02);
}

.l7chat-icon-carousel .l7chat-icon svg {
    width: 35px;
    height: 35px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.18));
}

.l7chat-icon-carousel .l7chat-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

/* ============================================
   Animation container
   ============================================ */
.l7chat-waves {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ── "Волны в эфире" (default) ── */
.l7chat-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(52,152,219,0.5);
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
    animation: radioWave 7.5s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}
.l7chat-wave:nth-child(2) { animation-delay: 2.5s; }
.l7chat-wave:nth-child(3) { animation-delay: 5s; }

html[data-theme="dark"] .l7chat-wave {
    border-color: rgba(96,185,255,0.6);
}

/* Hide waves when starfield is active */
#l7chat-btn.anim-starfield .l7chat-waves { display: none; }

/* ── "Звёздная пучина" ── */
.l7chat-starfield {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: -1;
}

/* Circular mask — hides stars behind the button face */
#l7chat-btn::after {
    content: '';
    position: absolute;
    inset: -4px;               /* cover border area too */
    border-radius: 50%;
    background: inherit;
    border: 4px solid white;
    z-index: 1;
}

/* Button circle above stars */
#l7chat-btn .l7chat-icon-carousel {
    position: relative;
    z-index: 2;
}

.l7chat-star {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(52,152,219,0.8);
    opacity: 0;
    animation: starBurst var(--star-duration, 3s) var(--star-delay, 0s) infinite ease-out;
}

html[data-theme="dark"] .l7chat-star {
    background: rgba(96,185,255,0.9);
}

@keyframes starBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.9;
    }
    15% {
        opacity: 0.8;
        transform: translate(
            calc(var(--star-dx) * 0.3),
            calc(var(--star-dy) * 0.3)
        ) scale(0.9);
    }
    70% {
        opacity: 0.3;
    }
    100% {
        transform: translate(var(--star-dx), var(--star-dy)) scale(0);
        opacity: 0;
    }
}

/* Hide starfield when waves is active (default) */
#l7chat-btn:not(.anim-starfield) .l7chat-starfield { display: none; }

/* ── "Ореол" — noise-displaced glowing halo ── */
.l7chat-halo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    height: 220px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: -1;
}

.l7chat-halo-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.l7chat-halo-ring {
    transform-origin: 100px 100px;
    animation:
        haloPulse 2.8s ease-in-out infinite,
        haloJitter 3.6s linear infinite;
    opacity: 0.85;
}

.l7chat-halo-ring--2 {
    animation:
        haloPulse 3.4s ease-in-out infinite reverse,
        haloSpin 7s linear infinite;
    opacity: 0.5;
    mix-blend-mode: screen;
}

@keyframes haloPulse {
    0%, 100% { opacity: 0.55; transform: scale(0.92); }
    50%      { opacity: 1;    transform: scale(1.08); }
}

@keyframes haloJitter {
    0%   { transform: rotate(0deg)   scale(1); }
    25%  { transform: rotate(3deg)   scale(1.03); }
    50%  { transform: rotate(-2deg)  scale(0.97); }
    75%  { transform: rotate(4deg)   scale(1.02); }
    100% { transform: rotate(0deg)   scale(1); }
}

@keyframes haloSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animate the noise seed by shifting baseFrequency */
.l7chat-halo-svg feDisplacementMap {
    transition: scale 0.5s ease;
}

/* Hide halo unless active */
#l7chat-btn:not(.anim-halo) .l7chat-halo { display: none; }

/* Hide waves & starfield when halo is active */
#l7chat-btn.anim-halo .l7chat-waves { display: none; }
#l7chat-btn.anim-halo .l7chat-starfield { display: none; }

/* No-animation mode: hide all effects */
#l7chat-btn.anim-none .l7chat-waves { display: none; }
#l7chat-btn.anim-none .l7chat-starfield { display: none; }
#l7chat-btn.anim-none .l7chat-halo { display: none; }
#l7chat-btn.anim-none .l7chat-icon-carousel * { animation: none !important; }

/* Dark theme: brighter halo */
html[data-theme="dark"] .l7chat-halo-ring {
    opacity: 1;
}

/* Activity & unread indicators */
#chat-activity-indicator {
    display: none;
    position: absolute;
    top: -3px;
    right: -3px;
    width: 22px;
    height: 22px;
    background: #ff6b6b;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 15px rgba(255,107,107,0.6);
    animation: pulseActivity 1.5s infinite;
}

#l7chat-unread-badge {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    border: 2px solid white;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(255,71,87,0.5);
}

/* --- Keyframes --- */
@keyframes pulseOnline {
    0%   { opacity: 1; transform: scale(1);   box-shadow: 0 0 15px #4ade80; }
    50%  { opacity: 0.8; transform: scale(1.3); box-shadow: 0 0 30px #4ade80; }
    100% { opacity: 1; transform: scale(1);   box-shadow: 0 0 15px #4ade80; }
}
@keyframes pulseActivity {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1);   opacity: 1; }
}
@keyframes thinkingWave {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.6; }
    30%           { transform: translateY(-12px); opacity: 1; }
}
@keyframes fadeOutDown {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(20px); visibility: hidden; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); visibility: visible; }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Radio wave animation - visible, 3 radii outward */
@keyframes radioWave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    60% {
        opacity: 0.25;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

/* --- Utility classes --- */
/* При прокрутке появляется кнопка «Наверх» (.scroll-top-button: width 52px,
   bottom 24px → её верхний край на ~76px). Чат-бот поднимается, чтобы не
   пересекаться с ней. Мобильное переопределение — внутри @media ниже. */
.l7chat-btn-raised { bottom: 92px !important; }
.fade-out { animation: fadeOutDown 0.3s ease forwards !important; }
.fade-in  { animation: fadeInUp 0.3s ease forwards !important; }
.hidden   { display: none !important; }
.visible  { display: flex !important; }

/* --- Mobile + tablet/landscape phone (iPhone 15 Pro Max landscape ≈ 932pt,
        iPad mini ≈ 768pt). Расширил правило до 1024px и (pointer: coarse),
        чтобы на любом touch-устройстве виджет занимал весь экран. --- */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1366px) {
    #l7chat-window {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        min-height: auto !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        resize: none !important;
    }
    #l7chat-window .l7w-header {
        /* Пилюля actions (theme/refresh/close) теперь скрыта (display:none) —
           кнопка закрыть переехала в ряд «Перезвоните/Сброс/Закрыть» внутри
           iframe. Поэтому резервировать 120px справа больше не нужно: даём
           симметричный padding, иначе заголовок и статус уезжают влево. */
        padding: 12px 16px !important;
        min-height: 68px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    #l7chat-window .l7w-header > .l7w-header-info {
        align-self: center !important;
        margin: 0 auto !important;
        text-align: center !important;
        align-items: center !important;
        max-width: 100% !important;
    }
    .l7w-header-spacer { width: 38px !important; }
    .l7w-header-center { gap: 10px !important; }
    .l7w-header-title  { font-size: 18px !important; text-align: center !important; }
    .l7w-header-status { font-size: 12px !important; padding: 4px 12px !important; }
    #l7chat-close-btn {
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
        margin-left: 12px !important;
        margin-right: 4px !important;
    }
    /* Кнопка «Очистить кэш» — обязательно показываем на мобиле */
    #l7chat-cache-btn {
        display: flex !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
        margin-left: 10px !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
    }
    /* Плавающая «пилюля» управления (theme/refresh/close) — на мобиле
       минимальный touch-target 44×44, иначе пользователь не может попасть
       пальцем. Визуально иконки те же 18px — увеличивается только hit-area
       и сам контейнер. Пилюлю чуть смещаем вниз и подсвечиваем. */
    /* Mobile: «пилюля» с тремя иконками сидит в правом верхнем углу шапки,
       на уровне строки «ИИ-помощник». Кнопки уменьшены ~30% (с 44 до 30 px),
       иконки с 22 до 15 px. Высота пилюли ~36px = высота строки заголовка. */
    .l7w-header-actions {
        top: 10px !important;
        right: 8px !important;
        gap: 3px !important;
        padding: 3px !important;
        background: rgba(255,255,255,.96) !important;
        box-shadow: 0 6px 16px -6px rgba(15,23,42,.28),
                    0 0 0 1px rgba(124,58,237,.16) !important;
    }
    .l7w-header-actions > button,
    .l7w-header-actions > #l7chat-close-btn,
    .l7w-header-actions > #l7chat-cache-btn,
    .l7w-header-actions > #l7chat-theme-btn {
        width: 30px !important;
        height: 30px !important;
    }
    .l7w-header-actions .l7chat-svg-icon {
        width: 15px !important;
        height: 15px !important;
    }
    /* Refresh-кнопку на мобиле подсвечиваем сильнее — её ищут чаще всего. */
    .l7w-header-actions > #l7chat-cache-btn {
        background: linear-gradient(135deg,#ede9fe 0%,#ddd6fe 100%) !important;
        color: #6d28d9 !important;
    }
    .l7w-header-actions > #l7chat-cache-btn:active {
        background: linear-gradient(135deg,#c4b5fd 0%,#a78bfa 100%) !important;
        color: #fff !important;
    }
    html[data-theme="dark"] .l7w-header-actions > #l7chat-cache-btn {
        background: linear-gradient(135deg,#4c1d95 0%,#5b21b6 100%) !important;
        color: #ede9fe !important;
    }
    /* На совсем узких — компактим заголовок чтобы кнопки точно влезли */
    .l7w-header-info { padding-right: 0 !important; }
    .l7w-header-title { font-size: 16px !important; }
    #l7chat-btn {
        width: 65px !important;
        height: 65px !important;
        bottom: 25px !important;
        right: 25px !important;
        border-width: 3px !important;
        z-index: 999999 !important;
        display: flex !important;
    }
    /* Мобильная «Наверх»: width/height 48px, bottom 16px → верхний край ≈ 64px.
       Поднимаем чат над ней с запасом. */
    #l7chat-btn.l7chat-btn-raised { bottom: 80px !important; }
    .l7chat-icon-carousel .l7chat-icon svg {
        width: 28px;
        height: 28px;
    }
    body.chat-open-mobile #l7chat-btn,
    #l7chat-btn.l7chat-btn-hidden {
        display: none !important;
    }
    #chat-activity-indicator {
        width: 18px !important;
        height: 18px !important;
        top: -2px !important;
        right: -2px !important;
        border-width: 2px !important;
    }
}
body.chat-open-mobile #l7chat-btn,
#l7chat-btn.l7chat-btn-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Закрытое время — приглушённая красно-серая launcher-кнопка чата.
   Класс ставится JS'ом из render_widget_html по результату /api/work-status. */
#l7chat-btn.is-work-closed {
    filter: grayscale(0.55) brightness(0.85);
    transition: filter .35s ease;
}
#l7chat-btn.is-work-closed::after {
    /* Маленький красный индикатор в правом-верхнем углу — намёк что мы сейчас не отвечаем. */
    content: "";
    position: absolute;
    top: 4px; right: 4px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(239,68,68,.4);
    z-index: 10;
}
#l7chat-btn.is-work-open {
    filter: none;
    transition: filter .35s ease;
}
