/*
  TM AI Visualizer — страница AI-визуализации штор (/tm-ai-visualizer-test/).
  Подключается методом Битрикса из шаблона страницы, см. tm-ai-visualizer.js рядом в /js/.
*/

.tm-ai-page {
    width: 100%;
    overflow-x: hidden;
}

.tm-ai-visualizer {
    width: 100%;
    background: radial-gradient(circle at top center, rgba(88, 155, 137, .08), transparent 360px), #f7f5f2;
    padding: 28px 18px 44px;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    color: #21100f;
    overflow-x: hidden;
}

.tm-ai-visualizer * {
    box-sizing: border-box;
}

.tm-ai-visualizer__inner {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
}

.tm-ai-visualizer__head {
    text-align: center;
    margin-bottom: 18px;
}

.tm-ai-visualizer__label {
    font-size: 16px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #21100f;
    margin-bottom: 6px;
}

.tm-ai-visualizer__title {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
    font-size: clamp(36px, 4.2vw, 64px);
    line-height: .98;
    letter-spacing: -.04em;
    color: #2a1110;
}

.tm-ai-visualizer__subtitle {
    margin: 16px 0 0;
    font-size: clamp(16px, 1.35vw, 22px);
    line-height: 1.35;
    color: #8a8582;
}

.tm-ai-visualizer__panel {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 28px;
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, .94);
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 18px 45px rgba(42, 17, 16, .08);
    overflow: hidden;
}

.tm-ai-visualizer__left {
    min-width: 0;
    padding-right: 24px;
    border-right: 1px solid #e9e3df;
}

.tm-ai-visualizer__right,
.tm-result,
.tm-variants {
    min-width: 0;
}

/* Шаги загрузки */

.tm-upload-step {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee8e4;
}

/* Шаг второй ткани, когда выбрано «Не использую»: остаётся только заголовок с переключателем */
.tm-upload-step.is-off .tm-upload-step__body,
.tm-upload-step.is-off .tm-upload-step__check {
    display: none;
}

.tm-upload-step.is-off .tm-upload-step__top {
    margin-bottom: 12px;
}

.tm-upload-step__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.tm-upload-step__title {
    font-size: 17px;
    font-weight: 700;
}

.tm-upload-step__hint {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
    color: #8a8582;
    margin-top: 5px;
}

.tm-upload-step__hint:empty {
    display: none;
}

/* Переключатель типа ткани — от него зависит список доступных вариантов отображения */

.tm-fabric-type {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 16px;
}

.tm-fabric-type__label {
    font-size: 14px;
    color: #4f4a48;
}

.tm-fabric-type__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tm-fabric-type__btn {
    height: 34px;
    padding: 0 14px;
    border: 1px solid #e0d9d4;
    border-radius: 7px;
    background: #f7f4f1;
    color: #4f4a48;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.tm-fabric-type__btn:hover {
    border-color: #cfe0da;
    background: #eef3f2;
}

.tm-fabric-type__btn.is-active {
    border-color: #589B89;
    background: #eef3f2;
    color: #2b6f63;
    font-weight: 700;
}

.tm-upload-step__check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #d8dedc;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .5;
    flex: 0 0 26px;
}

.tm-upload-step.is-loaded .tm-upload-step__check {
    background: #589B89;
    opacity: 1;
}

.tm-upload-step.is-invalid {
    border-bottom-color: #d9534f;
}

.tm-upload-step.is-invalid .tm-upload-step__placeholder {
    border-color: #d9534f;
    color: #b3413d;
}

.tm-upload-step__body {
    position: relative;
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 22px;
    align-items: center;
}

.tm-upload-step__preview,
.tm-upload-step__placeholder {
    width: 170px;
    height: 145px;
    border-radius: 9px;
}

.tm-upload-step__preview {
    object-fit: cover;
    display: none;
}

.tm-upload-step.is-loaded .tm-upload-step__preview {
    display: block;
}

.tm-upload-step__placeholder {
    background: #f0ece8;
    border: 1px dashed #cfc7c1;
    color: #9c918b;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    cursor: pointer;
}

.tm-upload-step.is-loaded .tm-upload-step__placeholder {
    display: none;
}

.tm-upload-step__info {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.tm-upload-step__icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #eef3f2;
    color: #376f66;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.tm-upload-step__status {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 7px;
}

.tm-upload-step__format {
    font-size: 14px;
    color: #4f4a48;
}

.tm-upload-step__input {
    display: none;
}

.tm-upload-step__btn {
    grid-column: 2 / 3;
    width: fit-content;
    min-width: 142px;
    max-width: 100%;
    height: 44px;
    border: 0;
    border-radius: 7px;
    background: #589B89;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 18px;
    white-space: nowrap;
}

.tm-upload-step__btn:hover,
.tm-ai-visualizer__generate:hover {
    background: #4c8a7a;
}

/* Распределение тканей: какая идёт на 70% полотна, какая на кант */

.tm-order-choice {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee8e4;
}

.tm-order-choice[hidden] {
    display: none;
}

.tm-order-choice__title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
}

.tm-order-choice__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tm-order-choice__btn {
    height: 38px;
    padding: 0 16px;
    border: 1px solid #e0d9d4;
    border-radius: 7px;
    background: #f7f4f1;
    color: #4f4a48;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.tm-order-choice__btn:hover {
    border-color: #cfe0da;
    background: #eef3f2;
}

.tm-order-choice__btn.is-active {
    border-color: #589B89;
    background: #eef3f2;
    color: #2b6f63;
    font-weight: 700;
}

/* Место для блока вариантов на узких экранах, скрипт переносит блок сюда */

.tm-variants-slot {
    margin-bottom: 22px;
}

.tm-variants-slot:empty {
    display: none;
}

.tm-ai-visualizer__generate {
    width: 100%;
    height: 64px;
    border: 0;
    border-radius: 9px;
    background: #589B89;
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

/* Кнопка выключена во время генерации и когда под выбранные ткани нет вариантов */
.tm-ai-visualizer__generate:disabled {
    opacity: .7;
    cursor: not-allowed;
}

/* Сообщения и остаток попыток */

.tm-ai-visualizer__message {
    display: none;
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.4;
}

.tm-ai-visualizer__message.is-visible {
    display: block;
}

.tm-ai-visualizer__message--error {
    background: #fdeceb;
    color: #a3352f;
}

.tm-ai-visualizer__message--info {
    background: #eef3f2;
    color: #2b6f63;
}

.tm-ai-visualizer__message a {
    color: inherit;
    text-decoration: underline;
}

.tm-ai-visualizer__attempts {
    display: none;
    margin-top: 12px;
    font-size: 14px;
    color: #8a8582;
    text-align: center;
}

.tm-ai-visualizer__attempts.is-visible {
    display: block;
}

/* Результат */

.tm-result__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
}

.tm-result__image-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 520px;
    border-radius: 12px;
    overflow: hidden;
    background: #f0ece8;
}

.tm-result.is-ready .tm-result__image-wrap {
    cursor: zoom-in;
}

.tm-result__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.tm-result.is-ready .tm-result__image {
    display: block;
}

.tm-result__empty {
    position: absolute;
    inset: 0;
    color: #9c918b;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    font-size: 20px;
}

.tm-result.is-ready .tm-result__empty {
    display: none;
}

.tm-result__loader {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(247, 245, 242, .88);
    color: #2b6f63;
    font-size: 16px;
    text-align: center;
    padding: 20px;
    z-index: 2;
}

.tm-result.is-loading .tm-result__loader {
    display: flex;
}

.tm-result__spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(88, 155, 137, .25);
    border-top-color: #589B89;
    border-radius: 50%;
    animation: tm-result-spin 1s linear infinite;
}

@keyframes tm-result-spin {
    to {
        transform: rotate(360deg);
    }
}

.tm-result__bottom {
    margin-top: 18px;
    width: 100%;
    max-width: 100%;
}

/* На узких экранах блок вариантов уезжает в левую колонку и место под ним не нужно */
.tm-result__bottom:empty {
    margin-top: 0;
}

.tm-variants__title {
    font-size: 18px;
    margin-bottom: 14px;
}

.tm-variants__list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
    max-width: 100%;
}

/* Вариант, который не подходит выбранной паре тканей */
.tm-variant[hidden] {
    display: none;
}

.tm-variants__empty {
    font-size: 14px;
    line-height: 1.4;
    color: #8a8582;
}

.tm-variants__empty[hidden] {
    display: none;
}

.tm-variant {
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    text-align: center;
    color: #161010;
    font-size: 13px;
    line-height: 1.25;
}

.tm-variant img {
    width: 100%;
    aspect-ratio: 6 / 5;
    height: auto;
    object-fit: cover;
    border-radius: 10px;
    display: block;
    margin-bottom: 8px;
    border: 2px solid transparent;
    background: #f0ece8;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.tm-variant:hover img {
    transform: translateY(-2px);
}

.tm-variant--active img {
    border-color: #589B89;
    box-shadow: 0 0 0 3px rgba(88, 155, 137, .18);
}

.tm-variant__name {
    display: block;
    font-weight: 500;
}

.tm-variant--active .tm-variant__name {
    color: #2b6f63;
}

/* Преимущества */

.tm-ai-advantages {
    margin-top: 36px;
    margin-bottom: 10px;
}

.tm-ai-advantages__inner {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    background: rgba(255, 255, 255, .95);
    border-radius: 22px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    box-shadow: 0 15px 40px rgba(0, 0, 0, .05);
}

.tm-ai-advantages__promo {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 26px;
    background: linear-gradient(135deg, rgba(88, 155, 137, .12), rgba(88, 155, 137, .04));
}

.tm-ai-advantages__promo-icon {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: rgba(88, 155, 137, .12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #589B89;
    font-size: 38px;
}

.tm-ai-advantages__promo-title {
    font-family: Georgia, serif;
    font-size: 24px;
    line-height: 1.15;
    color: #2A1110;
    margin-bottom: 8px;
}

.tm-ai-advantages__promo-text {
    color: #666;
    line-height: 1.45;
    font-size: 15px;
}

.tm-ai-advantages__items {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    padding: 26px 30px;
    align-items: center;
}

.tm-ai-advantages__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #2A1110;
    font-size: 14px;
    line-height: 1.4;
    min-width: 0;
}

.tm-ai-advantages__check {
    width: 26px;
    height: 26px;
    border: 2px solid #589B89;
    border-radius: 50%;
    color: #589B89;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 26px;
}

/* Просмотр результата на весь экран */

.tm-ai-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(20, 12, 10, .82);
    backdrop-filter: blur(6px);
}

.tm-ai-modal.is-open {
    display: flex;
}

.tm-ai-modal__content {
    position: relative;
    max-width: min(1400px, 96vw);
    max-height: 92vh;
}

.tm-ai-modal__image {
    display: block;
    max-width: 100%;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
    background: #f7f5f2;
}

.tm-ai-modal__close {
    position: absolute;
    top: -18px;
    right: -18px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    color: #2A1110;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}

.tm-ai-modal__close:hover {
    background: #f2eeee;
}

@media (max-width: 1400px) {
    .tm-ai-visualizer__inner,
    .tm-ai-advantages__inner {
        max-width: 1280px;
    }

    .tm-ai-visualizer__panel {
        grid-template-columns: 390px minmax(0, 1fr);
        gap: 22px;
        padding: 22px;
    }

    .tm-ai-visualizer__left {
        padding-right: 22px;
    }

    .tm-upload-step__body {
        grid-template-columns: 150px minmax(0, 1fr);
        gap: 18px;
    }

    .tm-upload-step__preview,
    .tm-upload-step__placeholder {
        width: 150px;
        height: 130px;
    }

    .tm-result__image-wrap {
        height: 460px;
    }

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

@media (max-width: 1100px) {
    .tm-ai-visualizer__panel {
        grid-template-columns: 1fr;
    }

    .tm-ai-visualizer__left {
        border-right: 0;
        border-bottom: 1px solid #e9e3df;
        padding-right: 0;
        padding-bottom: 24px;
    }

    .tm-result__image-wrap {
        height: auto;
        aspect-ratio: 16 / 9;
    }

    .tm-ai-advantages__items {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .tm-ai-visualizer {
        padding: 24px 12px 34px;
    }

    .tm-ai-visualizer__title br,
    .tm-ai-visualizer__subtitle br {
        display: none;
    }

    .tm-ai-visualizer__panel {
        padding: 16px;
        border-radius: 18px;
    }

    .tm-upload-step__body {
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 14px;
    }

    .tm-upload-step__preview,
    .tm-upload-step__placeholder {
        width: 120px;
        height: 120px;
    }

    .tm-upload-step__info {
        grid-template-columns: 46px minmax(0, 1fr);
        gap: 10px;
    }

    .tm-upload-step__icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
    }

    .tm-upload-step__btn {
        grid-column: 1 / -1;
        width: 100%;
        height: 42px;
        font-size: 14px;
    }

    .tm-ai-visualizer__generate {
        height: 58px;
        font-size: 16px;
    }

    .tm-result__image-wrap {
        aspect-ratio: 4 / 3;
    }

    .tm-variants__list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .tm-ai-advantages__promo {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }

    .tm-ai-advantages__promo-title {
        font-size: 24px;
    }

    .tm-ai-advantages__items {
        grid-template-columns: 1fr;
        padding: 24px;
        gap: 20px;
    }

    .tm-ai-modal {
        padding: 14px;
    }

    .tm-ai-modal__content {
        max-width: 100%;
    }

    .tm-ai-modal__close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .tm-ai-modal__image {
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .tm-ai-visualizer__title {
        font-size: 30px;
    }

    .tm-upload-step__body {
        grid-template-columns: 1fr;
    }

    .tm-upload-step__preview,
    .tm-upload-step__placeholder {
        width: 100%;
        height: 180px;
    }

    .tm-variants__list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
