/* Свои продукты партнёра — стили надстройки над print-house-products (/@media/custom-products/css) */

.cp-custom,
.cp-contacts,
.cp-modal {
    --cp-brown: #593821;
    --cp-brown-dark: #472e1d;
    --cp-muted: #826c5d;
    --cp-line: #e9e6e4;
    --cp-line-strong: #d4cac1;
    --cp-bg: #f2f0ee;
    --cp-bg-card: #ffffff;
    --cp-accent: #21a4df;
    --cp-danger: #c0392b;
    --cp-success: #2e7d4f;
    --cp-radius: .78rem;
    --cp-radius-sm: .39rem;
    color: var(--cp-brown);
    font-family: inherit;
    box-sizing: border-box;
}

.cp-custom *,
.cp-custom *::before,
.cp-custom *::after,
.cp-contacts *,
.cp-modal *,
.cp-modal *::before,
.cp-modal *::after {
    box-sizing: border-box;
}

.cp-custom[hidden],
.cp-custom [hidden],
.cp-contacts [hidden],
.cp-modal [hidden] {
    display: none !important;
}

/* ---------------------------------------------------------------- карточки */

.print-house-products-app .product_item[data-id^="-"] .product__label {
    position: relative;
}

.print-house-products-app .product_item.cp-card--image .product__label__image,
.print-house-products-app .product_item.cp-card--image .product__label:hover .product__label__image {
    top: 0;
    bottom: auto;
    height: 100%;
    object-fit: cover;
}

.print-house-products-app .product_item.cp-card--active .product__label {
    box-shadow: 0 0 0 2px #593821, 0 0 10px rgba(0, 0, 0, .5);
}

.print-house-products-app .product_item.cp-card--hidden .product__label__image {
    opacity: .45;
    filter: grayscale(1);
}

.print-house-products-app .product_item.cp-card-add .product__label {
    background: transparent;
    box-shadow: none;
}

/* «пузырёк» с ID продукта (виден менеджерам): у «+» прячем, у своих продуктов — «свой N» вместо -1000000-N */
.print-house-products-app .product_item.cp-card-add .developer-box {
    display: none;
}

.print-house-products-app .product_item.cp-card .developer-box__bubble[data-cp-label] > span:first-child {
    display: none;
}

.print-house-products-app .product_item.cp-card .developer-box__bubble[data-cp-label]::before {
    content: attr(data-cp-label);
}

.cp-card__badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    max-width: calc(100% - 16px);
    z-index: 3;
    padding: 5px 8px;
    border-radius: 999px;
    background: #472e1d;
    color: #fff;
    font: 600 11px/1 Arial, Helvetica, sans-serif;
    letter-spacing: .04em;
    text-transform: uppercase;
    pointer-events: none;
}

/* ------------------------------------------------------------------ блок */

/* Блок своего продукта над формой заказа приложения (между прайсом и «Параметрами заказа») */
.cp-custom {
    display: block;
    margin: .5rem 0 0;
    padding: 12px;
    background: var(--cp-bg);
    border-radius: var(--cp-radius);
    scroll-margin-top: 16px;
}

.cp-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
}

.cp-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.25;
    text-transform: uppercase;
    color: var(--cp-brown-dark);
}

.cp-owner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.cp-owner__message {
    flex-basis: 100%;
    color: var(--cp-danger);
    font-size: .9rem;
}

.cp-remove {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.cp-remove__question {
    font-weight: 600;
}

/* ----------------------------------------------------------- калькулятор */

.cp-calc {
    position: relative;
    background: var(--cp-bg-card);
    border-radius: var(--cp-radius);
    box-shadow: 0 0 0 1px var(--cp-line);
    overflow: hidden;
}

.cp-calc__frame {
    display: block;
    width: 100%;
    height: 320px;
    border: 0;
    background: transparent;
    transition: opacity .2s;
}

/* Пока страница калькулятора грузится — прелоадер по центру, iframe скрыт */
.cp-calc--loading .cp-calc__frame {
    opacity: 0;
}

.cp-calc__loader {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    text-align: center;
    color: var(--cp-muted);
    font-weight: 600;
}

.cp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--cp-line-strong);
    border-top-color: var(--cp-brown);
    border-radius: 50%;
    animation: cp-spin .8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .cp-spinner {
        animation-duration: 2.4s;
    }
}

.cp-calc--empty {
    padding: 16px 12px;
    text-align: center;
}

.cp-calc__empty {
    max-width: 560px;
    margin: 0 auto;
    color: var(--cp-muted);
    line-height: 1.5;
}

.cp-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 24px;
    align-items: start;
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--cp-bg-card);
    border-radius: var(--cp-radius);
    box-shadow: 0 0 0 1px var(--cp-line);
}

.cp-summary__params-text {
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.cp-summary__price {
    text-align: right;
}

.cp-summary__price-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--cp-brown-dark);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ------------------------------------------------ поля (контакты, настройки) */

.cp-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
}

.cp-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.cp-field--wide {
    grid-column: 1 / -1;
}

.cp-custom .cp-label,
.cp-contacts .cp-label,
.cp-modal .cp-label {
    display: block;
    margin: 0;
    font-size: .85rem;
    font-weight: 600;
    color: var(--cp-muted);
}

.cp-required {
    color: var(--cp-danger);
}

.cp-hint {
    font-size: .8rem;
    line-height: 1.4;
    color: var(--cp-muted);
}

.cp-contacts .cp-input,
.cp-modal .cp-input {
    width: 100%;
    max-width: 100%;
    min-height: 40px;
    height: auto;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--cp-line-strong);
    border-radius: var(--cp-radius-sm);
    background: #fff;
    color: var(--cp-brown-dark);
    font: inherit;
    font-size: 1rem;
    line-height: 1.3;
    box-shadow: none;
}

.cp-contacts .cp-input:focus,
.cp-modal .cp-input:focus {
    outline: 2px solid var(--cp-accent);
    outline-offset: 0;
    border-color: var(--cp-accent);
}

.cp-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cp-method {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid var(--cp-line-strong);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.cp-method:has(input:checked) {
    border-color: var(--cp-brown);
    background: var(--cp-bg);
}

.cp-method input {
    margin: 0;
    accent-color: var(--cp-brown);
}

.cp-hp {
    position: absolute !important;
    left: -10000px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Контакты покупателя в шаге «Название заказа» (гость и владелец сайта) */
.cp-contacts {
    position: relative;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--cp-line);
}

.cp-contacts__title {
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--cp-brown-dark);
}

/* Форма заказа приложения для своего продукта: выключенные шаги и строки итогов */
.print-house-products-app .order-form .step.cp-step-hidden,
.print-house-products-app .total-cost__table tr.cp-row-hidden {
    display: none !important;
}

/* Настройки продукта: вложенные поля под тумблером */
.cp-section-title {
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--cp-line);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cp-brown-dark);
}

.cp-subfields {
    display: grid;
    gap: 14px;
    margin: -6px 0 0 52px;
    padding: 12px 0 4px 16px;
    border-left: 2px solid var(--cp-line);
}

/* ------------------------------------------------ видимость по регионам */

.cp-geo .cp-methods {
    margin-top: 4px;
}

.cp-geo .cp-subfields {
    margin: 10px 0 0 12px;
}

.cp-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cp-checklist--scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 2px 12px;
    max-height: 220px;
    margin-top: 8px;
    padding: 8px 10px;
    overflow-y: auto;
    border: 1px solid var(--cp-line-strong);
    border-radius: var(--cp-radius-sm);
}

.cp-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    line-height: 1.3;
}

.cp-checklist:not(.cp-checklist--scroll) .cp-check {
    padding: 6px 12px;
    border: 1px solid var(--cp-line-strong);
    border-radius: 999px;
    font-weight: 600;
}

.cp-checklist:not(.cp-checklist--scroll) .cp-check:has(input:checked) {
    border-color: var(--cp-brown);
    background: var(--cp-bg);
}

.cp-checklist--scroll .cp-check {
    padding: 4px 0;
}

.cp-check input {
    margin: 0;
    accent-color: var(--cp-brown);
}

.cp-checklist-wrap > .cp-hint:empty {
    display: none;
}

.cp-suggest-wrap {
    position: relative;
}

.cp-suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 5;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--cp-line-strong);
    border-radius: var(--cp-radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.cp-modal .cp-suggest__item {
    display: flex;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--cp-radius-sm);
    background: transparent;
    color: var(--cp-brown-dark);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.cp-modal .cp-suggest__item:hover,
.cp-modal .cp-suggest__item:focus-visible {
    background: var(--cp-bg);
    outline: none;
}

.cp-suggest__item.is-selected {
    opacity: .5;
}

.cp-suggest__region,
.cp-suggest__empty {
    color: var(--cp-muted);
    font-size: .85rem;
}

.cp-suggest__empty {
    padding: 8px 10px;
}

.cp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    background: var(--cp-bg);
    box-shadow: inset 0 0 0 1px var(--cp-line-strong);
    font-size: .9rem;
}

.cp-modal .cp-chip__remove {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--cp-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.cp-modal .cp-chip__remove:hover {
    background: var(--cp-line-strong);
    color: var(--cp-brown-dark);
}

/* ---------------------------------------------------------------- кнопки */

.cp-custom .cp-btn,
.cp-modal .cp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    margin: 0;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: var(--cp-radius-sm);
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

.cp-custom .cp-btn:disabled,
.cp-modal .cp-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.cp-custom .cp-btn:focus-visible,
.cp-modal .cp-btn:focus-visible {
    outline: 2px solid var(--cp-accent);
    outline-offset: 2px;
}

.cp-btn--primary {
    background: var(--cp-brown);
    color: #fff;
}

.cp-btn--primary:hover:not(:disabled) {
    background: var(--cp-brown-dark);
}

.cp-btn--ghost {
    background: #fff;
    border-color: var(--cp-line-strong) !important;
    color: var(--cp-brown);
}

.cp-btn--ghost:hover:not(:disabled) {
    border-color: var(--cp-brown) !important;
}

.cp-btn--danger {
    color: var(--cp-danger);
}

.cp-btn--danger:not(.cp-btn--ghost) {
    background: var(--cp-danger);
    color: #fff;
}

/* --------------------------------------------------------------- тумблер */

.cp-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    cursor: pointer;
    font-weight: 600;
    user-select: none;
}

.cp-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.cp-switch__track {
    position: relative;
    flex: 0 0 auto;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--cp-line-strong);
    transition: background-color .15s;
}

.cp-switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform .15s;
}

.cp-switch input:checked + .cp-switch__track {
    background: var(--cp-success);
}

.cp-switch input:checked + .cp-switch__track::after {
    transform: translateX(18px);
}

.cp-switch input:focus-visible + .cp-switch__track {
    outline: 2px solid var(--cp-accent);
    outline-offset: 2px;
}

.cp-switch input:disabled + .cp-switch__track {
    opacity: .6;
}

/* --------------------------------------------------------------- сообщения */

.cp-alert {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--cp-radius-sm);
    background: var(--cp-bg);
    line-height: 1.4;
}

.cp-alert--error {
    background: #fbeceb;
    color: var(--cp-danger);
}

.cp-alert--success {
    background: #e7f4ec;
    color: var(--cp-success);
}

.cp-alert--info {
    color: var(--cp-muted);
}

/* ------------------------------------------------------------ модалка */

.cp-modal-open,
.cp-modal-open body {
    overflow: hidden;
}

.cp-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
    background: rgba(35, 24, 16, .55);
}

.cp-modal__box {
    width: 100%;
    max-width: 640px;
    margin: auto 0;
    background: #fff;
    border-radius: var(--cp-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.cp-modal__head,
.cp-modal__foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
}

.cp-modal__head {
    justify-content: space-between;
    border-bottom: 1px solid var(--cp-line);
}

.cp-modal__foot {
    justify-content: flex-end;
    border-top: 1px solid var(--cp-line);
}

.cp-modal__title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--cp-brown-dark);
}

.cp-modal .cp-modal__close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--cp-muted);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.cp-modal .cp-modal__close:hover {
    background: var(--cp-bg);
    color: var(--cp-brown-dark);
}

.cp-modal__body {
    display: grid;
    gap: 18px;
    padding: 20px 24px;
}

.cp-image {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.cp-image__frame {
    position: relative;
    flex: 0 0 auto;
    width: 148px;
    height: 148px;
    overflow: hidden;
    border-radius: var(--cp-radius-sm);
    background: var(--cp-bg);
    box-shadow: 0 0 0 1px var(--cp-line);
}

.cp-image__preview {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: top;
}

.cp-image__controls {
    display: flex;
    flex: 1 1 220px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.cp-image__pick {
    position: relative;
    overflow: hidden;
}

.cp-image__file {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* --------------------------------------------------------------- мобильные */

@media (max-width: 767px) {
    .cp-custom {
        padding: 8px;
    }

    .cp-title {
        font-size: 1.3rem;
    }

    .cp-grid,
    .cp-summary {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .cp-summary__price {
        text-align: left;
    }

    .cp-subfields {
        margin-left: 0;
    }

    .cp-calc__frame {
        height: 360px;
    }

    .cp-modal {
        padding: 0;
    }

    .cp-modal__box {
        min-height: 100%;
        border-radius: 0;
    }

    .cp-modal__head,
    .cp-modal__body,
    .cp-modal__foot {
        padding-left: 16px;
        padding-right: 16px;
    }
}
