/* Конструктор катера — стили */
:root {
    /* Цвет акцента берём из настроек темы Аспро Премьер (--theme-base-color),
       fallback — дефолт-синий; при смене темы в админке конструктор обновится автоматом. */
    --cfg-accent: var(--theme-base-color, #44558f);
    --cfg-accent-light: var(--theme-base-opacity-color, rgba(68,85,143,.12));
}
.cfg-root { padding: 20px 0; color: #222; }
/* hover-состояния делаем через filter, чтобы не зависеть от конкретного цвета */
.cfg-root .cfg-step-btn.is-active:hover,
.cfg-root .cfg-submit-btn:hover,
.cfg-root .cfg-form-submit:hover,
.cfg-root .cfg-step-actions .cfg-step-next:hover,
.cfg-root .cfg-step-actions .cfg-step-finish:hover {
    filter: brightness(0.88);
}
.cfg-intro { margin-bottom: 24px; }
.cfg-intro h2 { margin: 0 0 8px; font-size: 26px; }
.cfg-intro p { margin: 0; color: #666; }

/* Базовая комплектация (collapsible) */
.cfg-base-equipment {
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
}
.cfg-base-equipment > summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 20px;
    background: var(--cfg-accent-light, rgba(68,85,143,.10));
    color: var(--cfg-accent, #44558f);
    border-bottom: 1px solid #eaeaea;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transition: background .15s;
}
.cfg-base-equipment > summary:hover {
    background: var(--cfg-accent-light, rgba(68,85,143,.16));
    filter: brightness(0.96);
}
.cfg-base-equipment > summary::before {
    border-color: var(--cfg-accent, #44558f) !important;
}
.cfg-base-equipment > summary::-webkit-details-marker { display: none; }
.cfg-base-equipment > summary::before {
    content: '';
    width: 8px; height: 8px;
    border: solid #888;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    transition: transform .2s;
    flex-shrink: 0;
    margin-right: 4px;
}
.cfg-base-equipment[open] > summary::before { transform: rotate(-135deg); margin-top: 4px; }
.cfg-base-equipment[open] > summary { border-bottom-color: #eaeaea; }
.cfg-base-equipment-body {
    padding: 18px 22px;
    font-size: 15px;
    line-height: 1.6;
    color: #333;
}
.cfg-base-equipment-body ul,
.cfg-base-equipment-body ol { margin: 0 0 8px; padding-left: 24px; }
.cfg-base-equipment-body li { margin: 8px 0; padding-left: 4px; }
.cfg-base-equipment-body p { margin: 0 0 8px; }
.cfg-base-equipment-body p:last-child,
.cfg-base-equipment-body ul:last-child { margin-bottom: 0; }
.cfg-base-equipment-body li::marker { color: var(--cfg-accent, #44558f); font-size: 1.05em; }
@media (max-width: 639px) {
    .cfg-base-equipment { margin-bottom: 16px; border-radius: 6px; }
    .cfg-base-equipment > summary { padding: 12px 14px; font-size: 15px; gap: 8px; }
    .cfg-base-equipment-body { padding: 14px 14px 16px; font-size: 15px; line-height: 1.5; }
    .cfg-base-equipment-body ul,
    .cfg-base-equipment-body ol { padding-left: 20px; }
    .cfg-base-equipment-body li { margin: 8px 0; padding-left: 3px; }
    /* Subtle separators for easier scanning of long lists */
    .cfg-base-equipment-body li + li { border-top: 1px dashed #f0f0f0; padding-top: 8px; }
}

/* Layout: конструктор слева, sticky-сайдбар справа */
.cfg-layout { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
@media (max-width: 991px) { .cfg-layout { grid-template-columns: 1fr; } }

/* Full-height sticky rail beside top-info + configurator */
.catalog-detail__item.has-cfg-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    column-gap: 28px;
    align-items: start;
}
.catalog-detail__item.has-cfg-rail > *:not(.cfg-sticky-rail) {
    grid-column: 1;
    min-width: 0;
}
.catalog-detail__item.has-cfg-rail > .basket_props_block,
.catalog-detail__item.has-cfg-rail > .catalog-detail__bottom-info {
    grid-column: 1 / -1;
}
.catalog-detail__item.has-cfg-rail > .cfg-sticky-rail {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: stretch;
}
.cfg-sticky-rail .cfg-summary {
    position: sticky;
    top: 90px;
}
/* Boat image appears only when user scrolls to configurator (toggled by IntersectionObserver via .is-in-config) */
.cfg-sticky-rail .cfg-boat-pic { display: none; }
.cfg-sticky-rail.is-in-config .cfg-boat-pic { display: block; }
/* Inline summary slot — visible only when JS has placed summary there (tablet/mobile) */
.cfg-inline-slot:empty { display: none; }
.cfg-inline-slot .cfg-summary { position: static; margin: 16px 0 24px; }
.cfg-inline-slot .cfg-summary-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    box-shadow: none;
}
.cfg-inline-slot .cfg-boat-pic,
.cfg-inline-slot .cfg-summary-title,
.cfg-inline-slot .cfg-selected-list { display: none; }
.cfg-inline-slot .cfg-row { grid-column: 1; padding: 4px 0; border-top: 0; font-size: 13px; }
.cfg-inline-slot .cfg-total { grid-column: 1; border-top: 2px solid #222; padding: 8px 0 0; margin-top: 4px; }
.cfg-inline-slot .cfg-submit-btn { grid-column: 2; grid-row: 1 / 4; align-self: stretch; min-width: 220px; margin: 0; padding: 14px 24px; }
@media (max-width: 639px) {
    .cfg-inline-slot .cfg-summary-inner { grid-template-columns: 1fr; gap: 10px; }
    .cfg-inline-slot .cfg-submit-btn { grid-column: 1; grid-row: auto; min-width: 0; padding: 12px; }
}


/* Steps nav (arrow-breadcrumbs через clip-path) */
.cfg-steps-nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 20px; }
@media (max-width: 991px) { .cfg-steps-nav { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 479px) { .cfg-steps-nav { grid-template-columns: 1fr; } }
.cfg-step-btn {
    min-width: 0;
    position: relative; padding: 12px 24px 12px 36px;
    background: #eef2f7; border: 0; font: inherit; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    text-align: left; color: #555; transition: background .15s, color .15s;
    min-height: 48px;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%, 16px 50%);
}
/* 4-col grid (desktop): 1st and 5th are row-start; 4th and 8th are row-end */
@media (min-width: 992px) {
    .cfg-step-btn:nth-child(4n+1) {
        padding-left: 20px;
        clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
        border-radius: 8px 0 0 8px;
    }
    .cfg-step-btn:nth-child(4n) {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 16px 50%);
        border-radius: 0 8px 8px 0;
    }
}
/* 2-col grid (tablet/mobile 480-991) */
@media (min-width: 480px) and (max-width: 991px) {
    .cfg-step-btn:nth-child(odd) {
        padding-left: 20px;
        clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
        border-radius: 8px 0 0 8px;
    }
    .cfg-step-btn:nth-child(even) {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 16px 50%);
        border-radius: 0 8px 8px 0;
    }
}
/* 1-col grid (<480): each step is its own row — no notch on either side */
@media (max-width: 479px) {
    .cfg-step-btn {
        clip-path: none;
        border-radius: 8px;
        padding: 14px 20px;
    }
}
.cfg-step-btn:hover { background: #dde4ee; }
.cfg-step-btn.is-active { background: var(--cfg-accent, #00b290); color: #fff; }
.cfg-step-btn.is-active .cfg-step-num { background: #fff; color: var(--cfg-accent, #00b290); }
.cfg-step-btn.has-selected .cfg-step-num { background: #2a9d4b; color: #fff; }
.cfg-step-btn.has-selected.is-active .cfg-step-num { background: #fff; color: #2a9d4b; }
.cfg-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 26px; padding: 0 7px;
    background: #fff; color: var(--cfg-accent, #00b290); border-radius: 50%;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.cfg-step-name {
    font-size: 13px; font-weight: 500; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal;
}
.cfg-step-count {
    margin-left: 6px; font-size: 11px; background: rgba(255,255,255,.9);
    color: var(--cfg-accent, #00b290); padding: 2px 7px; border-radius: 10px; font-weight: 600;
}
.cfg-step-btn.is-active .cfg-step-count { background: #fff; color: var(--cfg-accent, #00b290); }

/* Step actions (prev/next) */
.cfg-step-actions {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; background: #fafbfc; border-top: 1px solid #eaeaea;
    gap: 10px;
}
.cfg-step-actions button { padding: 10px 22px; background: #fff; border: 1px solid #d0d7e0; border-radius: 6px; cursor: pointer; font-weight: 500; transition: all .15s; }
.cfg-step-actions button:hover { background: #f0f4f8; border-color: var(--cfg-accent, #00b290); color: var(--cfg-accent, #00b290); }
.cfg-step-actions .cfg-step-next, .cfg-step-actions .cfg-step-finish { background: var(--cfg-accent, #00b290); color: #fff; border-color: var(--cfg-accent, #00b290); }
.cfg-step-actions .cfg-step-next:hover, .cfg-step-actions .cfg-step-finish:hover { background: var(--cfg-accent, #44558f); color: #fff; }
.cfg-step-actions > span { flex: 1; }
.cfg-step-actions button + button { margin-left: auto; }

/* Sections */
.cfg-section { display: none; background: #fff; border: 1px solid #eaeaea; border-radius: 8px; overflow: hidden; }
.cfg-section.is-active { display: block; }
.cfg-section-title { margin: 0; padding: 14px 18px; background: #f5f7fa; font-size: 18px; font-weight: 600; border-bottom: 1px solid #eaeaea; }
.cfg-block { padding: 10px 18px; border-top: 1px solid #f0f0f0; }
.cfg-block:first-of-type { border-top: 0; }
.cfg-block-head { font-size: 13px; color: #888; padding: 4px 0 10px; }
.cfg-items { display: flex; flex-direction: column; gap: 6px; }

/* Item */
.cfg-item { display: block; cursor: pointer; border-radius: 6px; transition: background .15s; position: relative; }
.cfg-item:hover { background: #f8f9fb; }
.cfg-item input { position: absolute; opacity: 0; pointer-events: none; }
.cfg-item-body { position: relative; display: flex; align-items: center; gap: 16px; padding: 16px 16px 16px 44px; min-height: 48px; }
.cfg-item-body::before {
    content: ''; position: absolute; left: 14px; top: 50%;
    width: 20px; height: 20px; border: 2px solid #ccc; border-radius: 4px; background: #fff; transition: all .15s;
    box-sizing: border-box; transform: translateY(-50%);
}
.cfg-block-radio .cfg-item-body::before { border-radius: 50%; }
.cfg-item input:checked + .cfg-item-body::before { border-color: var(--cfg-accent, #00b290); background: var(--cfg-accent, #00b290); }
.cfg-item input:checked + .cfg-item-body::after {
    content: ''; position: absolute; left: 24px; top: 50%;
    width: 5px; height: 9px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: translate(-50%, -60%) rotate(45deg);
    box-sizing: border-box;
}
.cfg-block-radio .cfg-item input:checked + .cfg-item-body::after {
    left: 24px; top: 50%;
    width: 8px; height: 8px;
    border: 0; background: #fff; border-radius: 50%;
    transform: translate(-50%, -50%);
}

.cfg-item-pic { flex: 0 0 120px; }
.cfg-item-pic img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; display: block; background: #f5f5f5; }
.cfg-item-main { flex: 1 1 auto; min-width: 0; }
.cfg-item-name { display: block; font-weight: 500; font-size: 15px; line-height: 1.4; overflow-wrap: break-word; }
.cfg-item-desc { display: block; font-size: 14px; color: #888; margin-top: 6px; line-height: 1.5; }
.cfg-item-price { flex: 0 0 auto; white-space: nowrap; font-weight: 700; color: var(--cfg-accent, #00b290); text-align: right; font-size: 16px; }
.cfg-free { color: #aaa; font-weight: 400; }

@media (max-width: 639px) {
    /* Stacked card layout on phones: image on top, then checkbox next to name+desc+price */
    .cfg-item-body {
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr);
        grid-template-areas:
            "image image"
            "check main"
            ".     price";
        column-gap: 12px;
        row-gap: 8px;
        padding: 16px;
        align-items: start;
    }
    .cfg-item-pic { grid-area: image; }
    .cfg-item-pic img { width: 100%; height: auto; max-height: 220px; object-fit: cover; border-radius: 6px; display: block; }
    .cfg-item-main { grid-area: main; }
    .cfg-item-name { font-size: 15px; line-height: 1.4; }
    .cfg-item-desc { font-size: 14px; line-height: 1.5; margin-top: 6px; }
    .cfg-item-price { grid-area: price; text-align: left; font-size: 17px; padding: 0; white-space: normal; }
    /* Checkbox box + check mark as grid items sharing the "check" cell */
    .cfg-item-body::before {
        position: static;
        grid-area: check;
        align-self: start;
        justify-self: start;
        margin-top: 2px;
        transform: none;
    }
    .cfg-item input:checked + .cfg-item-body::after {
        position: static;
        grid-area: check;
        width: 5px; height: 9px;
        align-self: start;
        justify-self: start;
        margin: 7px 0 0 7px;
        transform: rotate(45deg);
    }
    .cfg-block-radio .cfg-item input:checked + .cfg-item-body::after {
        width: 8px; height: 8px;
        margin: 8px 0 0 6px;
        transform: none;
    }
}

/* Summary (sticky) */
.cfg-summary { position: sticky; top: 90px; }
.cfg-summary-inner { background: #fff; border: 1px solid #eaeaea; border-radius: 8px; padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,.04); }
.cfg-boat-pic img { width: 100%; height: auto; border-radius: 6px; display: block; margin-bottom: 12px; }
.cfg-summary-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; }
.cfg-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: #666; }
.cfg-row b { color: #222; font-weight: 600; }
.cfg-total { font-size: 17px; color: #222; padding: 10px 0; border-top: 2px solid #222; margin-top: 8px; }
.cfg-total b { color: var(--cfg-accent, #00b290); font-weight: 700; }
.cfg-vat-note { text-align: right; font-size: 12px; color: #888; margin-top: -2px; padding-right: 2px; }
.cfg-submit-btn { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; font-weight: 600; background: var(--cfg-accent, #00b290); color: #fff; border: 0; border-radius: 6px; cursor: pointer; transition: background .15s; }
.cfg-submit-btn:hover { background: var(--cfg-accent, #44558f); }
.cfg-selected-list { margin-top: 14px; font-size: 12px; color: #888; max-height: 240px; overflow: auto; }
.cfg-selected-list div { padding: 4px 0; border-top: 1px dashed #eee; display: flex; align-items: flex-start; gap: 10px; }
.cfg-selected-list div span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.cfg-selected-list div b { flex: 0 0 auto; white-space: nowrap; color: #444; }

@media (max-width: 991px) {
    .cfg-summary { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 100; box-shadow: 0 -4px 20px rgba(0,0,0,.12); }
    .cfg-summary-inner { border-radius: 8px 8px 0 0; padding: 12px 16px; }
    .cfg-boat-pic, .cfg-summary-title, .cfg-selected-list { display: none; }
    .cfg-row { font-size: 13px; padding: 2px 0; }
    .cfg-total { font-size: 16px; padding: 6px 0; margin-top: 4px; }
    .cfg-submit-btn { margin-top: 8px; padding: 10px; }
    .cfg-groups { padding-bottom: 140px; }
}

/* Модалка */
.cfg-modal[hidden] { display: none; }
.cfg-modal { position: fixed; inset: 0; z-index: 2147483647; display: flex; align-items: center; justify-content: center; padding: 20px; }
.cfg-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.cfg-modal-inner { position: relative; background: #fff; border-radius: 10px; padding: 28px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; }
.cfg-modal-close { position: absolute; top: 10px; right: 14px; width: 32px; height: 32px; background: transparent; border: 0; font-size: 28px; cursor: pointer; color: #888; }
.cfg-modal-close:hover { color: #222; }
.cfg-modal h3 { margin: 0 0 14px; font-size: 20px; }
.cfg-modal-summary { background: #f7f9fc; border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; max-height: 200px; overflow: auto; }
.cfg-modal-summary .sum-row { display: flex; justify-content: space-between; padding: 2px 0; }
.cfg-modal-summary .sum-total { font-weight: 700; font-size: 14px; margin-top: 6px; padding-top: 6px; border-top: 1px solid #ddd; }

.cfg-form .cfg-field { margin-bottom: 12px; }
.cfg-form label { display: block; font-size: 13px; color: #555; }
.cfg-form input[type="text"], .cfg-form input[type="tel"], .cfg-form input[type="email"], .cfg-form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit; margin-top: 4px;
}
.cfg-form input:focus, .cfg-form textarea:focus { border-color: var(--cfg-accent, #00b290); outline: 0; }
.cfg-field-checkbox label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #666; }
.cfg-field-checkbox input { margin: 0; }
.cfg-form-submit { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; background: var(--cfg-accent, #00b290); color: #fff; border: 0; border-radius: 6px; cursor: pointer; margin-top: 6px; }
.cfg-form-submit:hover { background: var(--cfg-accent, #44558f); }
.cfg-form-submit[disabled] { opacity: .5; cursor: not-allowed; }
.cfg-form-status { margin-top: 10px; font-size: 13px; text-align: center; }
.cfg-form-status.ok { color: #2a9d4b; }
.cfg-form-status.err { color: #c0392b; }
