/* Шрифт Inter подключается неблокирующим <link> в layouts.blade.php.
   @import здесь блокировал отрисовку: браузер узнавал про шрифт только после загрузки этого файла. */
/* Чат-виджет LeadForms (замена Jivo). Самодостаточные стили, всё под .lf-chat. */
.lf-chat {
    --lf-accent: #8098F9;
    --lf-accent-dark: #6b82e8;
    --lf-blue: #2f6bed;
    --lf-grad: linear-gradient(135deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.11) 10%, rgba(0, 0, 0, 0.08) 20%, rgba(0, 0, 0, 0.05) 35%, rgba(0, 0, 0, 0.02) 50%, rgba(0, 0, 0, 0.01) 65%, rgba(0, 0, 0, 0) 80%, rgb(248, 250, 252) 100%);
    --lf-text: #1f2430;
    --lf-muted: #8a94a6;
    --lf-bg: #f5f6f8;
    --lf-white: #ffffff;
    --lf-border: #eceef2;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 99998;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--lf-text);
}
.lf-chat *, .lf-chat *::before, .lf-chat *::after { box-sizing: border-box; }
/* :where() держит нулевую специфичность у сброса, чтобы стили кнопок ниже (фон/цвет) не перебивались */
.lf-chat :where(button) { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
.lf-chat [hidden] { display: none !important; }

/* Кнопка-тумблер */
.lf-chat__launcher {
    position: relative;
    z-index: 2;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--lf-white);
    box-shadow: 0 8px 24px rgba(31, 36, 48, .16);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: transform .18s ease;
    animation: lfPulse 2.6s ease-out infinite;
}
.lf-chat__launcher:hover { transform: translateY(-2px); }
/* Лёгкое пульсирование с тенью фирменного зелёного (#4cc724) */
@keyframes lfPulse {
    0%   { box-shadow: 0 8px 24px rgba(31, 36, 48, .16), 0 0 0 0 rgba(76, 199, 36, .45); }
    70%  { box-shadow: 0 8px 24px rgba(31, 36, 48, .16), 0 0 0 16px rgba(76, 199, 36, 0); }
    100% { box-shadow: 0 8px 24px rgba(31, 36, 48, .16), 0 0 0 0 rgba(76, 199, 36, 0); }
}
.lf-chat.is-open .lf-chat__launcher { animation: none; box-shadow: 0 8px 24px rgba(31, 36, 48, .16); }
@media (prefers-reduced-motion: reduce) {
    .lf-chat__launcher { animation: none; }
}
.lf-chat__ic { width: 26px; height: 26px; color: var(--lf-text); transition: opacity .15s ease, transform .15s ease; }
.lf-chat__ic--close { position: absolute; opacity: 0; transform: scale(.6) rotate(-45deg); }
.lf-chat.is-open .lf-chat__ic--open { opacity: 0; transform: scale(.6); }
.lf-chat.is-open .lf-chat__ic--close { opacity: 1; transform: scale(1) rotate(0); }

.lf-chat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #ef4b6a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--lf-white);
}

/* Плашка-тизер — примыкает к кнопке справа, центр по высоте кнопки */
.lf-chat__teaser {
    position: absolute;
    right: 44px;            /* правый край заходит под кнопку */
    bottom: 30px;           /* центр кнопки (60/2) */
    width: 288px;
    padding: 13px 54px 13px 20px;  /* справа место под кнопку */
    white-space: nowrap;
    background: var(--lf-white);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(31, 36, 48, .16);
    opacity: 0;
    transform: translate(16px, 50%);
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
}
.lf-chat__teaser.is-shown {
    opacity: 1;
    transform: translate(0, 50%);
    pointer-events: auto;
}
.lf-chat__teaser-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.lf-chat__teaser-sub { font-size: 13px; color: var(--lf-muted); }
.lf-chat__teaser-close { display: none; }

/* Панель */
.lf-chat__panel {
    position: absolute;
    z-index: 4; /* выше кнопки-тумблера (2), чтобы на мобиле панель перекрывала её */
    right: 0;
    bottom: 74px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 100px);
    background: var(--lf-white);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(31, 36, 48, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: lfPanelIn .22s ease both;
    transition: width .3s ease, height .3s ease;
}
.lf-chat__panel.is-expanded { width: 600px; height: 800px; }
/* Переключение иконки развернуть/свернуть */
.lf-chat__hbtn .lf-ic-collapse { display: none; }
.lf-chat__panel.is-expanded #lfChatExpand .lf-ic-expand { display: none; }
.lf-chat__panel.is-expanded #lfChatExpand .lf-ic-collapse { display: block; }
@keyframes lfPanelIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Вкладки-виды */
.lf-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.lf-view[hidden] { display: none !important; }
/* Градиентный фон только на Главной — шапка становится частью фона */
.lf-view--home { background: var(--lf-grad); }
.lf-view:not([hidden]) { animation: lfViewIn .26s ease both; }
@keyframes lfViewIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Универсальная шапка (Главная/Помощь) */
.lf-vhead {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    flex-shrink: 0;
    background: transparent;
}
.lf-vhead--center { background: var(--lf-white); }
.lf-vhead__spacer { flex: 1; }
.lf-vhead--center { justify-content: center; position: relative; border-bottom: 1px solid var(--lf-border); }
.lf-vhead__title { font-size: 17px; font-weight: 700; }
.lf-vhead--center .lf-close { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

/* Главная */
.lf-home {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: transparent;
    padding: 8px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.lf-home__greeting { padding: 8px 4px 4px; }
.lf-home__hello { font-size: 24px; font-weight: 700; line-height: 1.25; }
.lf-home__sub { font-size: 18px; color: #4a5265; line-height: 1.35; margin-top: 4px; }
.lf-home__ask {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: var(--lf-white);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 2px 10px rgba(31, 36, 48, .06);
    transition: transform .12s ease, box-shadow .12s ease;
}
.lf-home__ask:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(31, 36, 48, .1); }
/* «Переливашка» — блик пробегает по карточке */
.lf-home__ask::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -30%;
    width: 22%;
    background: linear-gradient(100deg, transparent, rgba(138, 148, 166, .22), transparent);
    transform: skewX(-18deg);
    pointer-events: none;
    animation: lfShine 3.8s ease-in-out infinite;
}
@keyframes lfShine {
    0% { left: -30%; }
    55%, 100% { left: 120%; }
}
@media (prefers-reduced-motion: reduce) {
    .lf-home__ask::after, .lf-home__cta { animation: none; }
}
.lf-home__ask-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.lf-home__ask-title { font-size: 16px; font-weight: 700; }
.lf-home__ask-sub { font-size: 13px; color: var(--lf-muted); }
.lf-home__ask-icon { width: 22px; height: 22px; color: #1f2430; flex-shrink: 0; }
.lf-home__cta {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(100deg, #8b2fd6, #d61f9a 55%, #ff3d8b);
    background-size: 170% 170%;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(214, 31, 154, .32);
    animation: lfAiGrad 6s ease infinite;
    transition: filter .15s ease;
}
.lf-home__cta:hover { filter: brightness(1.06); }
.lf-home__cta-icon { width: 20px; height: 20px; }
@keyframes lfAiGrad {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.lf-home__socials { display: flex; gap: 10px; }
.lf-home__social {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--lf-white);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--lf-text);
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(31, 36, 48, .06);
    transition: transform .12s ease;
}
.lf-home__social:hover { transform: translateY(-1px); }
.lf-home__social-ic {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #1f2430;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.lf-home__social-ic svg { width: 19px; height: 19px; }

/* Помощь */
.lf-help {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--lf-bg);
    padding: 14px 16px 16px;
}
.lf-help__search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 14px;
    background: var(--lf-white);
    border: 1px solid var(--lf-border);
    border-radius: 12px;
    margin-bottom: 8px;
    position: sticky;
    top: 0;
}
.lf-help__chevron { width: 20px; height: 20px; color: #c4cbd8; flex-shrink: 0; }
.lf-help__search svg { width: 20px; height: 20px; color: var(--lf-muted); flex-shrink: 0; }
.lf-help__search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--lf-text);
}
.lf-help__search input::placeholder { color: var(--lf-muted); }
.lf-help__loading, .lf-help__empty { color: var(--lf-muted); font-size: 14px; padding: 12px 4px; text-align: center; }
.lf-help__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--lf-border);
    text-decoration: none;
    color: var(--lf-text);
}
.lf-help__item:last-child { border-bottom: none; }
.lf-help__item-body { flex: 1; min-width: 0; }
.lf-help__item-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.lf-help__item-snippet { font-size: 12px; color: var(--lf-muted); line-height: 1.35; margin-top: 3px; }
.lf-help__item-snippet mark { background: rgba(128, 152, 249, .22); color: inherit; border-radius: 3px; padding: 0 1px; }
.lf-help__item-chevron { width: 18px; height: 18px; color: var(--lf-muted); flex-shrink: 0; }

/* Нижняя навигация */
.lf-nav {
    flex-shrink: 0;
    display: flex;
    border-top: 1px solid var(--lf-border);
    background: var(--lf-white);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.lf-nav__item {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 4px;
    color: var(--lf-muted);
    font-size: 12px;
    font-weight: 600;
    transition: color .15s ease;
}
.lf-nav__item svg { width: 24px; height: 24px; }
.lf-nav__item.is-active { color: var(--lf-text); }
.lf-nav__badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 8px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ef4b6a;
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}

/* Шапка */
.lf-chat__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--lf-border);
    flex-shrink: 0;
    background: var(--lf-white);
}
.lf-chat__logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #1c2736;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.lf-chat__logo img { width: 22px; height: 22px; }
.lf-chat__titles { flex: 1; min-width: 0; }
.lf-chat__name { font-size: 16px; font-weight: 700; line-height: 1.2; }
.lf-chat__status { font-size: 13px; color: var(--lf-muted); line-height: 1.2; margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.lf-chat__dot { width: 7px; height: 7px; border-radius: 50%; background: #3ec46a; box-shadow: 0 0 0 3px rgba(62, 196, 106, .18); flex-shrink: 0; }
.lf-chat__back svg { width: 20px; height: 20px; }

/* Системная строка и индикатор набора */
.lf-sys { align-self: center; color: var(--lf-muted); font-size: 13px; font-style: italic; padding: 4px 0 2px; text-align: center; }
.lf-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--lf-white);
    border-radius: 16px;
    border-bottom-left-radius: 5px;
    padding: 13px 15px;
    box-shadow: 0 1px 2px rgba(31, 36, 48, .06);
}
.lf-typing i { width: 7px; height: 7px; border-radius: 50%; background: #c4cbd8; display: block; animation: lfDot 1.2s infinite ease-in-out; }
.lf-typing i:nth-child(2) { animation-delay: .16s; }
.lf-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes lfDot {
    0%, 60%, 100% { opacity: .4; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}
.lf-chat__hbtn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    color: var(--lf-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}
.lf-chat__hbtn:hover { background: var(--lf-bg); color: var(--lf-text); }
.lf-chat__hbtn svg { width: 20px; height: 20px; }

/* Тело */
.lf-chat__body {
    flex: 1;
    overflow-y: auto;
    background: var(--lf-bg);
    padding: 16px;
    position: relative;
}
.lf-chat__empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--lf-muted);
    font-size: 15px;
    padding: 24px;
}
.lf-chat__messages { display: flex; flex-direction: column; gap: 10px; }

.lf-msg { max-width: 80%; display: flex; flex-direction: column; }
.lf-msg--in { align-self: flex-start; }
.lf-msg--out { align-self: flex-end; }
.lf-msg__bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.lf-msg--in .lf-msg__bubble {
    background: var(--lf-white);
    color: var(--lf-text);
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(31, 36, 48, .08);
}
.lf-msg--out .lf-msg__bubble {
    background: var(--lf-blue);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 3px 10px rgba(47, 107, 237, .3);
}
.lf-msg__link { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.lf-msg--in .lf-msg__link { color: var(--lf-accent); }
.lf-msg__img {
    max-width: 220px;
    max-height: 260px;
    border-radius: 14px;
    display: block;
    cursor: zoom-in;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(31, 36, 48, .1);
}
.lf-msg--out .lf-msg__img { border-bottom-right-radius: 5px; }
.lf-msg--in .lf-msg__img { border-bottom-left-radius: 5px; }
.lf-msg__bubble + .lf-msg__img, .lf-msg__img + .lf-msg__bubble { margin-top: 4px; }
.lf-msg__time { font-size: 11px; color: var(--lf-muted); margin-top: 3px; padding: 0 4px; }
.lf-msg--out .lf-msg__time { text-align: right; }

/* Необязательная подсказка «оставьте контакты» — карточка внутри ленты */
.lf-prompt {
    align-self: stretch;
    background: var(--lf-white);
    border: 1px solid var(--lf-border);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(31, 36, 48, .06);
}
.lf-prompt__title { font-size: 15px; font-weight: 700; }
.lf-prompt__sub { font-size: 13px; color: var(--lf-muted); margin-top: -4px; }
.lf-prompt__field {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    border: 1px solid var(--lf-border);
    border-radius: 11px;
    font-size: 14px;
    color: var(--lf-text);
    background: var(--lf-bg);
    outline: none;
    transition: border-color .15s ease;
}
.lf-prompt__field:focus { border-color: var(--lf-accent); }
.lf-prompt__error { font-size: 13px; color: #ef4b6a; }
.lf-prompt__actions { display: flex; gap: 8px; margin-top: 2px; }
.lf-prompt__skip {
    flex: 0 0 auto;
    padding: 0 14px;
    height: 42px;
    border-radius: 11px;
    color: var(--lf-muted);
    font-size: 14px;
    font-weight: 600;
}
.lf-prompt__skip:hover { background: var(--lf-bg); }
.lf-prompt__submit {
    flex: 1;
    height: 42px;
    border-radius: 11px;
    background: var(--lf-blue);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(47, 107, 237, .3);
    transition: background .15s ease;
}
.lf-prompt__submit:hover { background: #2a60d8; }

/* Строка ввода — белая «плавающая» карточка на сером фоне */
.lf-chat__composer {
    flex-shrink: 0;
    padding: 10px 12px 12px;
    background: var(--lf-bg);
}
.lf-chat__composer-card {
    position: relative;
    background: var(--lf-white);
    border-radius: 20px;
    padding: 12px 14px 10px;
    box-shadow: 0 4px 18px rgba(31, 36, 48, .08);
    border: 1px solid var(--lf-border);
}
.lf-chat__preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
}
.lf-chat__preview img { max-width: 90px; max-height: 90px; border-radius: 10px; display: block; }
.lf-chat__preview-name {
    display: inline-block;
    max-width: 220px;
    padding: 8px 12px;
    background: var(--lf-bg);
    border-radius: 10px;
    font-size: 13px;
    color: var(--lf-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
.lf-chat__preview button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1f2430;
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}
.lf-chat__input {
    width: 100%;
    max-height: 120px;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.45;
    color: var(--lf-text);
    background: transparent;
    padding: 4px 2px;
}
.lf-chat__input::placeholder { color: var(--lf-muted); }
.lf-chat__composer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}
.lf-chat__tools { display: flex; gap: 4px; }
.lf-chat__tool {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    color: var(--lf-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}
.lf-chat__tool:hover { background: var(--lf-bg); color: var(--lf-text); }
.lf-chat__tool svg { width: 21px; height: 21px; }
.lf-chat__send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #1f2430;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, opacity .15s ease;
}
.lf-chat__send:hover { background: #000; }
.lf-chat__send svg { width: 22px; height: 22px; margin-left: -2px; }

/* Пикер эмодзи */
.lf-chat__emoji {
    position: absolute;
    left: 12px;
    bottom: calc(100% + 8px);
    width: 232px;
    max-height: 168px;
    overflow-y: auto;
    padding: 8px;
    background: var(--lf-white);
    border: 1px solid var(--lf-border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(31, 36, 48, .16);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 3;
}
.lf-chat__emoji button {
    height: 26px;
    font-size: 19px;
    line-height: 1;
    border-radius: 7px;
}
.lf-chat__emoji button:hover { background: var(--lf-bg); }

/* Мобайл — на весь экран */
@media (max-width: 480px) {
    /* Поднимаем кнопку выше, чтобы не перекрывать нижний виджет сайта */
    .lf-chat { bottom: 88px; }
    .lf-chat__panel,
    .lf-chat__panel.is-expanded {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;    /* сбрасываем десктопный bottom, иначе панель переопределяется по высоте */
        width: 100vw;
        height: 100vh;   /* фолбэк для старых браузеров */
        height: 100svh;  /* минимальная видимая высота — строка ввода всегда над панелью браузера */
        height: var(--lf-vh, 100svh); /* точная высота из JS (visualViewport), учитывает панели браузера и клавиатуру */
        max-height: 100vh;
        max-height: 100dvh; /* жёсткий кап: панель не выше видимой области, даже если --lf-vh устарел */
        border-radius: 0;
    }
    /* Отступ снизу под «безопасную зону» (айфон) */
    .lf-chat__composer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
    .lf-chat__teaser { width: 210px; }
}
