/* ИИ-чат (Spotlight) — overlay поверх каталога. Структура по референсу:
   левый рейл 64px + drawer + основная область (пусто / тред / список чатов). */

.ai-overlay {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #eef2f8 100%);
    display: none;
}

.ai-overlay.is-open {
    display: block;
}

.ai-shell {
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Шапка сайта внутри оверлея — на общем фоне, без своей заливки */
.ai-header {
    position: relative;
    flex: 0 0 auto;
    height: var(--header-height);
    background: transparent;
    box-shadow: none;
    z-index: 30;
}

/* В полноэкранном оверлее шапка тянется на всю ширину, а не по контейнеру 1200px */
.ai-header .container {
    max-width: none;
    padding-left: 24px;
    padding-right: 24px;
}

/* Рейл + drawer + контент под шапкой */
.ai-body {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
}

/* --- Левый рейл --- */
.ai-rail {
    flex: 0 0 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 10px;
    z-index: 20;
}

.ai-rail__logo {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    border: 1px solid #e6eaf0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(13, 30, 59, .10);
    cursor: pointer;
    padding: 7px;
}

.ai-rail__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-rail__btn {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    border: none;
    background: transparent;
    color: #5b6472;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.ai-rail__btn:hover {
    background: rgba(13, 30, 59, .06);
}

.ai-rail__btn.is-active {
    background: #eaf3ff;
    color: #0074FE;
}

/* --- Drawer --- */
.ai-drawer__scrim {
    position: fixed;
    inset: 0;
    background: rgba(13, 30, 59, .35);
    z-index: 35;
}

.ai-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    background: #fff;
    box-shadow: 2px 0 30px rgba(13, 30, 59, .16);
    z-index: 40;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    animation: aiSlideIn .28s cubic-bezier(.4, 0, .2, 1);
}

.ai-drawer__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 16px;
}

.ai-drawer__logo {
    height: 34px;
    object-fit: contain;
}

.ai-drawer__collapse {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f4f6fa;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-drawer__collapse:hover {
    background: #e9edf3;
}

.ai-drawer__act {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 14.5px;
    font-weight: 500;
    font-family: inherit;
    color: #0D1E3B;
    cursor: pointer;
}

.ai-drawer__act:hover {
    background: #f2f5f9;
}

.ai-drawer__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #b6bcc6;
    margin: 16px 12px 8px;
}

.ai-drawer__list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ai-drawer__chat {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #0D1E3B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.ai-drawer__chat:hover {
    background: #f2f5f9;
}

.ai-drawer__chat.is-active {
    background: #eaf3ff;
    color: #0074FE;
}

.ai-drawer__empty {
    font-size: 13px;
    color: #9ca3af;
    padding: 8px 12px;
    margin: 0;
}

/* --- Основная область --- */
.ai-main__area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Пустой экран (герой) */
.ai-hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.ai-hero__box {
    position: relative;
    width: 100%;
    max-width: 680px;
    animation: aiFadeUp .5s both;
}

.ai-hero__star {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    pointer-events: none;
}

.ai-hero__input {
    width: 100%;
    height: 64px;
    border: 1px solid #e3e7ee;
    border-radius: 999px;
    background: #fff;
    padding: 0 66px 0 54px;
    font-size: 17px;
    font-family: inherit;
    color: #0D1E3B;
    outline: none;
    box-shadow: 0 16px 38px rgba(13, 30, 59, .12);
    transition: box-shadow .15s ease, border-color .15s ease;
}

/* placeholder-заглушка "." невидима — печатаем через ghost */
.ai-hero__input::placeholder {
    color: transparent;
}

.ai-hero__input:focus {
    border-color: #0074FE;
    box-shadow: 0 0 0 4px rgba(0, 116, 254, .12), 0 16px 38px rgba(13, 30, 59, .12);
}

.ai-ghost {
    position: absolute;
    left: 54px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 17px;
    color: #9ca3af;
    pointer-events: none;
    white-space: nowrap;
}

.ai-cursor {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    background: #0074FE;
    vertical-align: -2px;
    margin-left: 1px;
    animation: aiBlink 1.05s steps(1) infinite;
}

.ai-hero__send {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: #0074FE;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 116, 254, .4);
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.ai-hero__send:hover {
    background: #0A61D6;
    transform: scale(1.05);
}

/* --- Активный тред --- */
.ai-thread {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 8px;
}

.ai-thread__inner {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.ai-msg {
    animation: aiFadeUp .4s both;
}

.ai-msg__qrow {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.ai-msg__q {
    background: #eef1f5;
    color: #0D1E3B;
    font-size: 15.5px;
    line-height: 1.5;
    border-radius: 20px 20px 4px 20px;
    padding: 12px 18px;
    max-width: 78%;
}

.ai-msg__ans {
    padding: 0 2px;
}

.ai-msg__head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 12px;
}

.ai-msg__ava {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(13, 30, 59, .14);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
}

.ai-msg__ava img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-msg__name {
    font-size: 13px;
    font-weight: 700;
    color: #0D1E3B;
}

.ai-msg__reply {
    margin: 0;
    font-size: 16px;
    line-height: 1.7;
    color: #1f2937;
}

/* Внутренности ответа — результат renderMarkdown: абзацы, списки, выделение.
   Во время стрима тут ещё сырой текст одной строкой, поэтому сам блок
   сохраняет типографику, а вложенные теги только добавляют ритм. */
.ai-msg__reply > p {
    margin: 0 0 10px;
}

.ai-msg__reply > p:last-child {
    margin-bottom: 0;
}

.ai-msg__reply ul,
.ai-msg__reply ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.ai-msg__reply ul:last-child,
.ai-msg__reply ol:last-child {
    margin-bottom: 0;
}

.ai-msg__reply li {
    margin-bottom: 4px;
}

.ai-msg__reply strong {
    font-weight: 600;
}

.ai-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
}

.ai-dots span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #0074FE;
    animation: aiDot 1.2s infinite;
}

.ai-dots span:nth-child(2) { animation-delay: .2s; }
.ai-dots span:nth-child(3) { animation-delay: .4s; }

/* Карточки авто в ответе */
.ai-cars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.ai-carcard {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 190px;
    background: #fff;
    border: 1px solid #eef1f5;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .2s ease;
    animation: aiPop .35s both;
}

.ai-carcard:hover {
    box-shadow: 0 8px 22px rgba(13, 30, 59, .12);
}

.ai-carcard__photo {
    background: #eef1f4;
    min-height: 150px;
}

.ai-carcard__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-carcard__mid {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
}

.ai-carcard__name {
    font-size: 17px;
    font-weight: 700;
    color: #0D1E3B;
    margin: 0;
}

.ai-carcard__sub {
    font-size: 13px;
    color: #9ca3af;
    margin: 2px 0 0;
}

.ai-carcard__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    margin-top: auto;
    padding-top: 14px;
}

.ai-carcard__k {
    display: block;
    font-size: 10.5px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #b6bcc6;
}

.ai-carcard__v {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: #0D1E3B;
    margin-top: 2px;
}

.ai-carcard__side {
    border-left: 1px solid #f0f1f3;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
}

.ai-carcard__price {
    font-size: 20px;
    font-weight: 900;
    color: #0D1E3B;
    margin: 0;
}

.ai-carcard__delivery {
    font-size: 12px;
    font-weight: 500;
    color: #8b95a5;
    margin: 5px 0 0;
}

.ai-carcard__open {
    font-size: 12px;
    font-weight: 500;
    color: #0074FE;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Нижняя строка ввода в треде */
.ai-inputbar {
    border-top: none;
    background: transparent;
    padding: 16px 20px 22px;
}

.ai-inputbar__inner {
    max-width: 720px;
    margin: 0 auto;
    position: relative;
}

.ai-inputbar__input {
    width: 100%;
    height: 56px;
    border: 1px solid #e3e7ee;
    border-radius: 999px;
    background: #f7f9fc;
    padding: 0 62px 0 22px;
    font-size: 16px;
    font-family: inherit;
    color: #0D1E3B;
    outline: none;
    transition: border-color .15s ease, background .15s ease;
}

.ai-inputbar__input:focus {
    border-color: #0074FE;
    background: #fff;
}

.ai-inputbar__send {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: #e6eaf0;
    color: #9ca3af;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.ai-inputbar__send.is-active {
    background: #0074FE;
    color: #fff;
}

/* --- Страница списка чатов --- */
.ai-cl {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 60px;
}

.ai-cl__back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e6eaf0;
    border-radius: 11px;
    padding: 0 16px;
    height: 42px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #0D1E3B;
    box-shadow: 0 1px 3px rgba(13, 30, 59, .06);
    margin-bottom: 24px;
    cursor: pointer;
}

.ai-cl__back:hover {
    background: #f4f6fa;
}

.ai-cl__search {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
}

.ai-cl__search-ic {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    pointer-events: none;
}

.ai-cl__search-input {
    width: 100%;
    height: 56px;
    border: 1px solid #e3e7ee;
    border-radius: 999px;
    background: #fff;
    padding: 0 22px 0 52px;
    font-size: 16px;
    font-family: inherit;
    color: #0D1E3B;
    outline: none;
    box-shadow: 0 6px 20px rgba(13, 30, 59, .06);
}

.ai-cl__search-input:focus {
    border-color: #0074FE;
}

.ai-cl__label {
    max-width: 640px;
    margin: 28px auto 6px;
    font-size: 13px;
    font-weight: 500;
    color: #9ca3af;
}

.ai-cl__list {
    max-width: 640px;
    margin: 0 auto;
}

.ai-cl__row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 12px;
    padding: 16px 14px;
    border-bottom: 1px solid #eef1f5;
    font-family: inherit;
    cursor: pointer;
}

.ai-cl__row:hover {
    background: #f2f5f9;
}

.ai-cl__title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 500;
    color: #0D1E3B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-cl__date {
    flex: 0 0 auto;
    font-size: 13px;
    color: #b6bcc6;
}

.ai-cl__del {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b6bcc6;
    font-size: 18px;
    line-height: 1;
}

.ai-cl__del:hover {
    background: #fdecec;
    color: #ef4444;
}

/* --- Анимации --- */
@keyframes aiBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@keyframes aiFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

@keyframes aiPop {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: none; }
}

@keyframes aiDot {
    0%, 80%, 100% { opacity: .25; }
    40% { opacity: 1; }
}

@keyframes aiSlideIn {
    from { transform: translateX(-100%); }
    to { transform: none; }
}

/* --- Адаптив --- */
/* Ниже 992px общий .nav превращается в выездную панель под бургер, которого
   в оверлее нет — прячем nav и оставляем лого + контакты. */
@media (max-width: 1100px) {
    .ai-header .nav {
        display: none;
    }
}

@media (max-width: 640px) {
    .ai-header .container {
        padding-left: 14px;
        padding-right: 14px;
    }

    .ai-header .header__contacts {
        display: flex;
    }

    .ai-header .header__phone,
    .ai-header .header__contacts .button {
        font-size: 14px;
    }

    .ai-header .logo__text {
        display: none;
    }


    .ai-carcard {
        grid-template-columns: 1fr;
    }

    .ai-carcard__side {
        border-left: none;
        border-top: 1px solid #f0f1f3;
        align-items: flex-start;
        text-align: left;
    }

    .ai-ghost {
        font-size: 14px;
    }

    .ai-hero__input {
        font-size: 15px;
    }
}
