/**
 * Адаптация вёрстки carmar под данные движка.
 * В оригинале логотипы и иконки были вшиты в разметку как SVG,
 * здесь они приходят картинками из админки — доводим размеры и цвет.
 */

/* Логотипы марок: подгоняем под круглую плитку и обесцвечиваем в белый,
   т.к. тема монохромная, а из каталога приходят цветные логотипы */
.marks-popular-list__item__logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* До 1250px кнопка слайда позиционируется абсолютно под баннером (top: 100% + 52px).
   Базовый отступ секции меньше её высоты, поэтому кнопка налезала на блок марок.
   Селектор с .f-carousel нужен, чтобы перебить .f-carousel.has-dots{margin-bottom:80px!important}. */
@media screen and (max-width: 1249px) {
    .slider-index.f-carousel {
        margin-bottom: 140px !important;
    }
}

/* В оригинале у стрелок и точек главного баннера был класс-модификатор,
   которого Carousel сам не ставит — повторяем правила через контекст .slider-index */
.slider-index > .f-carousel__nav {
    bottom: -35px;
    justify-content: space-between;
    right: 50%;
    transform: translateX(50%);
    width: 110px;
}

.slider-index > .f-carousel__dots {
    bottom: -35px !important;
    right: 50%;
    transform: translateX(50%);
}

/* Волнистый декор (.background-decoration:after) шире своего слайда и вылезает
   за его границы. Соседние слайды идут дальше по разметке, поэтому их волны
   рисовались поверх кнопки под баннером. Даём кнопкам собственный слой:
   декор лежит на z-index 0, картинка авто — на 1, значит 5 перекрывает всё. */
.slider-index__buttons.desktop {
    position: relative;
    z-index: 5;
}

.slider-index__buttons.mobile {
    z-index: 5;
}

/* Картинка авто в баннере спозиционирована абсолютно. В оригинале её сдвиг
   задавали модификаторы slider-index__image-1..4 под каждую конкретную
   картинку; из админки приходят произвольные баннеры, поэтому задаём общий
   сдвиг вниз — иначе на узких экранах авто наезжает на заголовок слайда. */
@media screen and (max-width: 949px) {
    .slider-index__image {
        top: 70px;
    }
}

@media screen and (max-width: 767px) {
    .slider-index__image {
        top: 100px;
    }
}

/* Длина заголовка и подписи задаётся в админке. Если подпись переносится
   на две строки, она заходит на картинку авто (у той z-index: 1),
   поэтому текст кладём слоем выше. */
.slider-index__number,
.slider-index__text {
    position: relative;
    z-index: 2;
}

/* Зачёркнутая старая цена в теме залита чёрным (color: #000) — в оригинале
   этот класс не использовался на тёмных карточках. Делаем приглушённо-серой. */
.mini-card__price-old {
    color: #8a8a8a;
}

/* Мозаика акций: в оригинале высоту строк задавали пропорции конкретных картинок.
   Из админки приходят любые фото, поэтому фиксируем высоту строк, а фото растягиваем по карточке. */
.services--promotions .services__content-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ячейки 3 и 6 — узкие и высокие. Фото машин обычно скомпонованы низом кадра,
   поэтому обрезаем сверху, а не по центру. */
@media screen and (min-width: 901px) {
    .services--promotions .services__item--3 .services__content-image,
    .services--promotions .services__item--6 .services__content-image {
        object-position: center bottom;
    }
}

@media screen and (min-width: 1250px) {
    .services--promotions {
        grid-template-rows: repeat(2, 172px);
    }
}

@media screen and (min-width: 901px) and (max-width: 1249px) {
    .services--promotions {
        grid-template-rows: repeat(4, 172px);
    }
}

/* «Показать все» в оригинале абсолютно позиционирована под сетку из 6 колонок.
   Марок у нас может быть любое число, поэтому ставим кнопку обычным блоком под сеткой. */
.section--popular-mark__show-link {
    position: static !important;
    aspect-ratio: auto !important;
    height: auto !important;
    border-radius: 100px !important;
    margin: 32px auto 0 !important;
    width: -moz-fit-content;
    width: fit-content;
}

/* Шапка прозрачная только наверху страницы. При скролле возвращаем фон,
   иначе меню накладывается на заголовки и текст под ним не читается. */
.header.header--opacity.header--scrolled .header__top {
    background: var(--color-bg);
}

/* В тему зашит логотип сайта-источника (img/logo-ww.svg) как водяной знак
   на фото и в модалках. Подменяем его логотипом этого сайта из настроек. */
.offer__slider .f-carousel__slide:after,
.offer__slider-line-slide:after,
.fancybox__content:after {
    background-image: var(--carmar-watermark, none);
}

/* --- Формы движка на тёмной теме ---
   Поля и селекты движка приходят со своей светлой вёрсткой, поэтому
   доводим их до вида полей темы: прозрачный фон, белая рамка, скругление 30px. */

/* Подпись над группой полей («Какой автомобиль хотите», «Ваш автомобиль») */
.form-new__block-title {
    color: #fff;
    font-family: Gothampro-bold;
    font-size: 16px;
}

/* intl-tel-input оборачивает поле в inline-block, из-за чего телефон уже соседних полей */
.form__control .iti,
.modal-form__fields .iti {
    display: block;
    width: 100%;
}

/* Код страны в поле телефона (intl-tel-input) по умолчанию чёрный */
.iti__selected-dial-code,
.iti__search-input {
    color: #fff;
}

/* Список стран в поле телефона */
.iti__dropdown-content {
    background-color: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
}

.iti__country.iti__highlight {
    background-color: rgba(255, 255, 255, .12);
}

.iti__dial-code {
    color: rgba(255, 255, 255, .6);
}

/* Селекты марки и модели рисует SlimSelect */
.ss-main {
    background-color: transparent;
    border: 1px solid #fff;
    border-radius: 30px;
    color: #fff;
    font-family: Gothampro;
    font-size: 16px;
    min-height: 50px;
    padding: 0 20px;
}

.ss-main .ss-values .ss-placeholder,
.ss-main .ss-values .ss-single {
    color: #fff;
}

.ss-main .ss-arrow path {
    stroke: #fff;
}

/* Модель недоступна, пока не выбрана марка — приглушаем, но не заливаем светлым */
.ss-main.ss-disabled {
    background-color: transparent;
    border-color: rgba(255, 255, 255, .25);
}

.ss-main.ss-disabled .ss-values .ss-placeholder {
    color: rgba(255, 255, 255, .35);
}

.ss-main.ss-disabled .ss-arrow path {
    stroke: rgba(255, 255, 255, .35);
}

/* Выпадающий список SlimSelect добавляется в конец body, поэтому без вложенности */
.ss-content {
    background-color: var(--color-surface);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 14px;
    overflow: hidden;
}

.ss-content .ss-search input {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 20px;
    color: #fff;
    height: 38px;
}

.ss-content .ss-list .ss-option {
    background-color: transparent;
    color: #fff;
}

.ss-content .ss-list .ss-option:hover,
.ss-content .ss-list .ss-option.ss-highlighted {
    background-color: rgba(255, 255, 255, .12);
}

.ss-content .ss-list .ss-option.ss-selected {
    background-color: var(--color-primary);
    color: #000;
}

/* Калькулятор кредита движка внутри блока формы темы */
.form-new__block--calculator .credit__calc {
    display: flex;
    flex-direction: column;
    gap: 22px;
    width: 100%;
}

.form-new__block--calculator .credit__item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.form-new__block--calculator .credit__item-subtitle {
    color: var(--color-element);
    font-size: 14px;
}

/* Поле со значением ползунка — только для чтения на вид */
.form-new__block--calculator .credit__item-header input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    text-align: right;
    width: 110px;
}

.form-new__block--calculator .credit__calc-result_wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.form-new__block--calculator .credit__calc-desc-subtitle {
    color: var(--color-element);
    font-size: 14px;
}

.form-new__block--calculator .credit__calc-desc_text {
    color: #fff;
    font-size: 20px;
}

/* Ползунки ion.rangeSlider по умолчанию синие — красим в акцент темы.
   Стиль библиотеки подключается после темы, поэтому селекторы удвоены для веса. */
.irs.irs--round .irs-bar,
.irs.irs--round .irs-handle {
    background-color: var(--color-primary);
}

.irs.irs--round .irs-handle {
    border-color: var(--color-primary);
}

.irs.irs--round .irs-line {
    background: rgba(255, 255, 255, .15);
}

.irs.irs--round .irs-min,
.irs.irs--round .irs-max {
    background: transparent;
    color: rgba(255, 255, 255, .4);
}

/* Всплывающая подсказка над ползунком — тоже акцентная */
.irs.irs--round .irs-from,
.irs.irs--round .irs-to,
.irs.irs--round .irs-single {
    background-color: var(--color-primary);
    color: #000;
}

.irs.irs--round .irs-from:before,
.irs.irs--round .irs-to:before,
.irs.irs--round .irs-single:before {
    border-top-color: var(--color-primary);
}

/* Согласие на обработку данных не должно вылезать из колонки */
.form-new__block .checkbox--inputPlace,
.form-new__block .checkbox--inputPlace .checkbox__text {
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.form-new__block--col-4 {
    min-width: 0;
}

.form-new__block .checkbox--inputPlace a {
    color: var(--color-primary);
}

/* Селекты марок/моделей в формах занимают всю ширину блока */
.form-new__block select,
.form-new__block .choices,
.form-new__block .ss-main {
    width: 100%;
}

/* Текущая марка в списке каталога — подсвечиваем акцентом */
.popular__mark--active .popular__mark-name {
    color: var(--color-primary);
}

.popular__mark--active .popular__mark-logo img {
    opacity: 1;
}

/* Детальная страница акции */
.promo-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    padding: 24px;
    margin-top: 24px;
}

.promo-detail__image {
    flex: 1 1 320px;
    max-width: 520px;
}

.promo-detail__image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
}

.promo-detail__content {
    flex: 1 1 320px;
}

.promo-detail__content .button {
    margin-top: 24px;
    width: -moz-fit-content;
    width: fit-content;
}

/* Логотип марки в шапке страницы бренда */
.mark__info-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* Логотипы марок в каталоге — та же логика, что и на плитках главной */
.popular__mark-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* В оригинале на тач-устройствах вместо фото показывался отдельный мобильный слайдер
   с несколькими снимками. У нас одно фото, поэтому показываем его на любом экране. */
.mini-card__slider-desktop {
    display: block;
}

.mini-card__slider-desktop img {
    aspect-ratio: 4 / 3;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Фото автомобилей приходят разного размера — вписываем в карточку */
.mini-card__image-wrapper img,
.mini-card__slider--render img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Фото модели приходит крупным — не даём вылезать за колонку */
.offer__image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Выбор цвета: кружки-образцы под фото */
.offer__colors {
    display: flex;
    align-items: center;
    gap: 12px;
}

.offer__colors-title {
    color: var(--color-element, #9a9a9a);
    font-size: 14px;
}

.offer__colors-list {
    display: flex;
    gap: 8px;
}

.offer__color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color .2s;
}

.offer__color--active {
    border-color: var(--color-primary);
}

/* Техданные в карточке без иконок — выравниваем как обычный список */
.mini-card__tech-item {
    align-items: center;
}

/* Кнопки-триггеры модалок должны выглядеть как ссылки-кнопки оригинала */
button.button {
    border: none;
    cursor: pointer;
    font: inherit;
}

/* Блок "все автомобили в наличии" под слайдером */
.section__more {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

/* Поля форм движка внутри тёмных блоков */
.modal__form input[type="text"],
.modal__form input[type="tel"] {
    width: 100%;
}

/* Согласие на обработку данных — мельче основного текста */
.modal__form-agree {
    font-size: 12px;
    line-height: 1.4;
    margin-top: 12px;
    opacity: .7;
}

.modal__form-agree a {
    color: var(--color-primary);
}

/* --- Модальные формы (fancybox) ---
   Fancybox по умолчанию рисует белую карточку, приводим её к тёмной теме. */
.fancybox__content {
    background: var(--color-surface);
    border-radius: 20px;
    color: #fff;
    padding: 0;
}

.fancybox__content > .carousel__button.is-close {
    color: #fff;
    top: 14px;
    right: 14px;
}

/* В компактных формах водяной знак ложится поверх текста согласия — убираем его. */
.fancybox__content:has(.modal-form):after,
.fancybox__content:has(.modal-form)::after {
    background-image: none;
    content: none;
    display: none;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 32px;
    width: min(440px, 88vw);
}

.modal-form__head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 32px;
}

.modal-form__title {
    color: #fff;
    font-family: DaysOne-Regular, Gothampro-bold, sans-serif;
    font-size: 22px;
    line-height: 1.25;
    text-transform: uppercase;
}

.modal-form__subtitle {
    color: rgba(255, 255, 255, .6);
    font-size: 14px;
    line-height: 1.4;
}

.modal-form form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-form__fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-form__fields .input {
    width: 100%;
}

.modal-form__fields .button {
    justify-content: center;
    margin-top: 4px;
    width: 100%;
}

/* Капча Яндекса резервирует высоту даже когда выключена — прячем пустой блок */
.modal-form__fields .y-smart-captcha:empty {
    display: none;
}

.modal-form__privacy {
    color: rgba(255, 255, 255, .5);
    font-size: 12px;
    line-height: 1.4;
}

.modal-form__privacy a {
    color: var(--color-primary);
}

/* Карточка автомобиля в модалках кредита и заявки */
.modal-form__car {
    align-items: center;
    background: rgba(255, 255, 255, .05);
    border-radius: 14px;
    display: flex;
    gap: 14px;
    padding: 12px;
}

.modal-form__car-pic {
    flex: 0 0 110px;
}

.modal-form__car-pic img {
    display: block;
    height: auto;
    width: 100%;
}

.modal-form__car-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.modal-form__car-name {
    color: #fff;
    font-family: Gothampro-bold, sans-serif;
    font-size: 16px;
}

.modal-form__car-compl {
    color: rgba(255, 255, 255, .55);
    font-size: 12px;
}

.modal-form__car-price {
    color: #fff;
    font-family: Gothampro-bold, sans-serif;
    font-size: 18px;
}

.modal-form__car-price-old {
    color: #8a8a8a;
    font-size: 13px;
    text-decoration: line-through;
}

/* Калькулятор кредита внутри модалки — тот же вид, что и на странице кредита.
   Класс .calculator из темы добавляет отступ сверху, в модалке он не нужен. */
.modal-form__calc.calculator {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 0;
}

.modal-form__calc .credit__item-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-form__calc .credit__item-subtitle {
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
}

.modal-form__calc .credit__item-header input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 15px;
    text-align: right;
    width: 110px;
}

.modal-form__calc .credit__calc-result_wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.modal-form__calc .credit__calc-desc-subtitle {
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
}

.modal-form__calc .credit__calc-desc_text {
    color: #fff;
    font-size: 18px;
}
