/* =========================================
   AVTOPILOT — ОСНОВНЫЕ СТИЛИ КАРТОЧКИ
   + АДАПТИВ ЦВЕТОВ 425–1024px
   ========================================= */

:root{
  --ap-blue:#174eb5;
  --ap-red:#c52034;
  --ap-border:#d7eef7;
  --ap-text:#231f20;
  --ap-muted:#7e7e7e;
}

.ap-custom-options,
.ap-custom-options *{
  box-sizing:border-box;
  font-family:"Inter Tight",Arial,sans-serif!important;
}

.ap-custom-options{
  display:grid!important;
  grid-template-columns:minmax(340px,390px) minmax(360px,1fr)!important;
  gap:20px!important;
  width:100%!important;
  margin-top:20px!important;
  padding:0!important;
  align-items:start!important;
}

/* Когда есть только цвет — одна колонка */
.ap-custom-options.ap-only-color{
  grid-template-columns:1fr!important;
}

.ap-materials,
.ap-colors{
  margin:0!important;
  min-width:0!important;
}

.ap-custom-options > .t-product__option > .t-product__option-title,
.ap-custom-options > .t-product__option > .js-product-edition-option-name,
.ap-custom-options > .t-product__option > .js-product-option-name{
  font-size:16px!important;
  line-height:1.2!important;
  font-weight:700!important;
  text-transform:uppercase!important;
  color:var(--ap-text)!important;
  margin:0 0 16px!important;
  padding:0!important;
}

/* =========================
   МАТЕРИАЛЫ
   ========================= */

.ap-materials .t-product__option-variants_custom{
  display:flex!important;
  flex-direction:column!important;
  gap:10px!important;
  margin:0!important;
  padding:0!important;
}

.ap-materials .t-product__option-item{
  display:grid!important;
  grid-template-columns:18px minmax(0,1fr) 98px!important;
  column-gap:8px!important;
  align-items:center!important;
  min-height:42px!important;
  margin:0!important;
  padding:0!important;
}

/* Обычный пустой кружок */
.ap-materials .t-product__option-checkmark_image{
  width:18px!important;
  height:18px!important;
  margin:0!important;
  border:2px solid var(--ap-border)!important;
  border-radius:50%!important;
  background:#fff!important;
  background-image:none!important;
  box-shadow:none!important;
}

/* Скрываем штатные декоративные элементы */
.ap-materials .t-product__option-checkmark_image:before,
.ap-materials .t-product__option-checkmark_image:after{
  display:none!important;
}

/* Выбранный материал — синий кружок */
.ap-materials
.t-product__option-item:has(input:checked)
.t-product__option-checkmark_image{
  border-color:var(--ap-blue)!important;
  background:var(--ap-blue)!important;
  background-image:none!important;
  box-shadow:inset 0 0 0 4px #fff!important;
}

/* Невыбранные материалы */
.ap-materials
.t-product__option-item:not(:has(input:checked))
.t-product__option-checkmark_image{
  border-color:var(--ap-border)!important;
  background:#fff!important;
  background-image:none!important;
  box-shadow:none!important;
}

.ap-materials .t-product__option-title_radio{
  font-size:14px!important;
  line-height:1.15!important;
  font-weight:500!important;
  color:var(--ap-text)!important;
  white-space:normal!important;
  overflow:visible!important;
  text-overflow:unset!important;
}

.ap-materials .t-product__option-title_radio:after{
  content:"Доступно расцветок: уточняйте";
  display:block;
  margin-top:3px;
  font-size:14px!important;
  line-height:1.15!important;
  font-weight:400!important;
  color:var(--ap-muted)!important;
}

.ap-materials .t-product__option-item:before{
  display:none!important;
}

/* Цена справа от материала */
.ap-materials .t-product__option-item:after{
  content:var(--ap-price,"");
  width:98px;
  height:30px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:0;
  background:var(--ap-blue);
  color:#fff;
  font-size:14px!important;
  line-height:1!important;
  font-weight:700!important;
  white-space:nowrap;
}

.ap-materials .t-product__option-item_disabled{
  opacity:.38!important;
}

/* =========================
   ЦВЕТА
   ========================= */

.ap-colors .t-product__option-variants_custom{
  display:grid!important;
  grid-template-columns:repeat(5,70px)!important;
  gap:8px!important;
  margin:0!important;
  padding:0!important;
}

.ap-colors .t-product__option-item_image{
  width:70px!important;
  height:56px!important;
  margin:0!important;
  padding:0!important;
}

.ap-colors .t-product__option-checkmark_image{
  width:70px!important;
  height:56px!important;
  border:2px solid var(--ap-border)!important;
  border-radius:0!important;
  background-size:cover!important;
  background-position:center!important;
}

/* Названия цветов скрыты: показываем только фотографии.
   Информация о цвете остаётся в нашей подсказке. */
.ap-colors .t-product__option-title_radio,
.ap-colors .t-product__option-title_image,
.ap-colors .t-product__option-item > .t-product__option-title,
.ap-colors .t-product__option-item > .t-product__option-title_radio{
  display:none!important;
}

/* Красная рамка выбранного цвета */
.ap-colors .t-product__option-item_active .t-product__option-checkmark_image,
.ap-colors input:checked + .t-product__option-checkmark_image{
  border-color:var(--ap-red)!important;
}

.ap-colors .t-product__option-input:checked + .t-product__option-checkmark_image:before{
  display:none!important;
}

/* =========================
   УСТАНОВКА
   ========================= */

.ap-install{
  margin-top:22px!important;
  padding:20px!important;
  border:1px solid var(--ap-border)!important;
  background:#f8f8f8!important;
}

.ap-install .t-product__option-title{
  font-size:16px!important;
  line-height:1.25!important;
  font-weight:700!important;
  color:var(--ap-text)!important;
  margin-bottom:14px!important;
}

.ap-install .t-checkbox__control{
  font-size:14px!important;
  line-height:1.35!important;
  margin-bottom:9px!important;
}

/* Скрываем миниатюры под галереей */
.t-store__prod-popup .t-slds__thumbsbullet-wrapper,
.t-store__product-snippet .t-slds__thumbsbullet-wrapper,
.t-catalog__prod-snippet .t-slds__thumbsbullet-wrapper{
  display:none!important;
}

/* =========================
   ПЛАНШЕТ — ИСХОДНЫЕ НАСТРОЙКИ
   ========================= */

@media(max-width:1200px){
  .ap-custom-options{
    grid-template-columns:minmax(320px,370px) minmax(300px,1fr)!important;
    gap:18px!important;
  }

  .ap-colors .t-product__option-variants_custom{
    grid-template-columns:repeat(4,68px)!important;
    gap:8px!important;
  }

  .ap-colors .t-product__option-item_image,
  .ap-colors .t-product__option-checkmark_image{
    width:68px!important;
    height:54px!important;
  }
}

/* =========================
   МОБИЛЬНАЯ ВЕРСИЯ — ИСХОДНАЯ
   ========================= */

@media(max-width:980px){
  .ap-custom-options{
    display:block!important;
    width:100%!important;
    margin-top:20px!important;
  }

  .ap-materials,
  .ap-colors{
    width:100%!important;
    max-width:none!important;
  }

  .ap-colors{
    margin-top:28px!important;
  }

  .ap-colors .t-product__option-variants_custom{
    grid-template-columns:repeat(3,70px)!important;
    justify-content:center!important;
    gap:8px!important;
  }

  .ap-colors .t-product__option-item_image,
  .ap-colors .t-product__option-checkmark_image{
    width:70px!important;
    height:70px!important;
  }
}

@media(max-width:480px){
  .ap-materials .t-product__option-item{
    grid-template-columns:18px minmax(0,1fr) 94px!important;
  }

  .ap-materials .t-product__option-item:after{
    width:94px!important;
  }
}

/* =========================================
   НОВЫЙ АДАПТИВ ЦВЕТОВ 425–1024px
   ========================================= */

@media screen and (min-width:425px) and (max-width:1024px){

  /* Одна колонка: материалы сверху, цвета снизу */
  .ap-custom-options{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:24px!important;
    width:100%!important;
    max-width:100%!important;
  }

  .ap-custom-options .ap-materials,
  .ap-custom-options .ap-colors{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
  }

  .ap-custom-options .ap-colors{
    margin-top:0!important;
  }

  /* Растягиваем сетку цветов */
  .ap-custom-options .ap-colors
  .t-product__option-variants_custom{
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    justify-content:stretch!important;
    gap:12px!important;
    width:100%!important;
    max-width:100%!important;
    margin-left:0!important;
    margin-right:0!important;
    padding:0!important;
    box-sizing:border-box!important;
  }

  /* Каждая цветовая плашка занимает ячейку */
  .ap-custom-options .ap-colors
  .t-product__option-item{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    margin:0!important;
    box-sizing:border-box!important;
  }

  /* Фото заполняет ширину ячейки */
  .ap-custom-options .ap-colors
  .t-product__option-item_image,
  .ap-custom-options .ap-colors
  .t-product__option-checkmark_image{
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    aspect-ratio:5/4;
    box-sizing:border-box!important;
  }
}

/* На планшете — шесть цветов в ряд */
@media screen and (min-width:768px) and (max-width:1024px){

  .ap-custom-options .ap-colors
  .t-product__option-variants_custom{
    grid-template-columns:repeat(6,minmax(0,1fr))!important;
  }
}

/* =========================================
   AVTOPILOT — ПОДСКАЗКИ ЦВЕТОВ
   ========================================= */

.ap-tip{
  position:fixed;
  z-index:2147483000;
  width:max-content;
  max-width:min(300px,calc(100vw - 24px));
  padding:12px 14px;
  background:#fff;
  border:1px solid #d7eef7;
  box-shadow:0 8px 28px rgba(0,0,0,.15);
  color:#231f20;
  font-family:"Inter Tight",Arial,sans-serif;
  font-size:13px;
  line-height:1.4;
  pointer-events:none;
  opacity:0;
  visibility:hidden;
  transition:opacity .12s ease;
  box-sizing:border-box;
}

.ap-tip.ap-tip-visible{
  opacity:1;
  visibility:visible;
}

.ap-tip-title{
  font-weight:700;
  margin-bottom:5px;
}

.ap-tip-status{
  color:#7e7e7e;
}

.ap-tip-materials{
  margin-top:6px;
  color:#174eb5;
  font-weight:600;
}

.ap-mobile-tip{
  display:none;
}

@media(max-width:767px){
  .ap-tip{
    display:none!important;
  }

  .ap-mobile-tip{
    display:block;
    margin-top:14px;
    padding:14px;
    border:1px solid #d7eef7;
    background:#f8fbfd;
    font-family:"Inter Tight",Arial,sans-serif;
    color:#231f20;
    font-size:13px;
    line-height:1.4;
    box-sizing:border-box;
  }

  .ap-mobile-tip-title{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    font-size:14px;
    font-weight:700;
  }

  .ap-mobile-tip-close{
    display:flex;
    align-items:center;
    justify-content:center;
    width:26px;
    height:26px;
    padding:0;
    border:0;
    background:transparent;
    color:#7e7e7e;
    font-size:22px;
    line-height:1;
    cursor:pointer;
  }

  .ap-mobile-tip-status{
    margin-top:6px;
    color:#7e7e7e;
  }

  .ap-mobile-tip-materials{
    margin-top:8px;
    color:#174eb5;
    font-weight:600;
  }
}