/* ==========================================================================
   CAMSCO — Product Configurator
   ========================================================================== */

.configurator-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

/* ---- Selection form ---- */
.configurator-form {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px;
}
.configurator-form h2 { margin-bottom: 6px; }
.configurator-form .lead { color: var(--muted); margin-bottom: 28px; }

.config-step {
    margin-bottom: 22px;
    opacity: .4;
    pointer-events: none;
    transition: opacity .2s;
}
.config-step.active { opacity: 1; pointer-events: auto; }
.config-step.completed { opacity: 1; pointer-events: auto; }

.config-step label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    background: var(--border);
    color: var(--muted);
    border-radius: 50%;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background .2s, color .2s;
}
.config-step.active .step-number  { background: var(--primary); color: #fff; }
.config-step.completed .step-number { background: #4caf50; color: #fff; }

.config-step select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .9rem;
    color: var(--body);
    background: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    transition: border-color .2s, box-shadow .2s;
}
.config-step select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,84,144,.12);
}
.config-step select:disabled { background-color: var(--lighter-bg); color: var(--muted); cursor: not-allowed; }

/* ---- Result panel ---- */
.config-result {
    background: var(--lighter-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 24px;
    display: none;
}
.config-result.visible { display: block; }

.config-result-sku {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}
.config-result-price {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--body);
    margin-bottom: 16px;
}
.config-result-price .config-price-total {
    display: block;
}
.config-result-price .config-price-breakdown {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted);
    margin-top: 2px;
}
.config-result-cap {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 14px;
}
.config-result-cap:empty { display: none; }
.result-cap-line small { opacity: .75; }

.config-needs-conditioning {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: .875rem;
    color: #5d4037;
    margin-top: 16px;
}
.config-needs-conditioning svg { flex-shrink: 0; color: #f9a825; }

.config-result-actions { display: flex; gap: 10px; }
.config-result-actions .btn { flex: 1; justify-content: center; }

.config-unavailable {
    font-size: .9rem;
    color: #555;
    line-height: 1.5;
}

/* ---- Image preview panel ---- */
.configurator-preview {
    position: sticky;
    top: 88px;
}
.composer-wrapper {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.composer-wrapper img.tube-body {
    position: relative;
    z-index: 1;
    max-height: 80%;
    width: auto;
    max-width: 80%;
    object-fit: contain;
}
.composer-wrapper img.cap-left,
.composer-wrapper img.cap-right {
    position: absolute;
    z-index: 2;
    height: 60%;
    width: auto;
    object-fit: contain;
}
.composer-wrapper img.cap-left  { left: 8%; }
.composer-wrapper img.cap-right { right: 8%; }
.composer-wrapper img.cap-overlay {
    position: absolute;
    z-index: 2;
    bottom: 0;
    right: 0;
    width: 18%;
    height: auto;
    object-fit: contain;
    border-radius: 4px 0 0 0;
    box-shadow: -2px -2px 6px rgba(0,0,0,.12);
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: .875rem;
    text-align: center;
    padding: 32px;
}
.preview-placeholder svg { opacity: .3; }

.config-spec-summary {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 16px;
    font-size: .875rem;
}
.config-spec-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.config-spec-row:last-child { border-bottom: none; }
.config-spec-row .spec-key { color: var(--muted); font-weight: 500; }
.config-spec-row .spec-val { font-weight: 600; color: var(--body); }

/* ---- Sorbent search ---- */
.config-search-wrap {
    position: relative;
}
.config-search-input {
    width: 100%;
    padding: 11px 14px 11px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .9rem;
    color: var(--body);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.config-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,84,144,.12);
}
.config-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}
.config-search-dropdown.open { display: block; }
.config-search-result {
    padding: 10px 14px;
    font-size: .875rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.config-search-result:last-child { border-bottom: none; }
.config-search-result:hover,
.config-search-result.highlighted { background: var(--lighter-bg); }
.config-search-result.selected { background: var(--primary); color: #fff; }
.config-search-empty {
    padding: 12px 14px;
    font-size: .875rem;
    color: var(--muted);
    font-style: italic;
}
.config-search-selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    padding: 4px 10px 4px 12px;
    font-size: .8rem;
    font-weight: 600;
    margin-top: 8px;
}
.config-search-clear {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}
.config-search-clear:hover { color: #fff; }

/* ---- Visual option buttons (material, cap) ---- */
.config-option-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.config-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: .8rem;
    font-weight: 600;
    color: var(--body);
    text-align: center;
    min-width: 90px;
    transition: border-color .15s, background .15s, color .15s;
    line-height: 1.3;
}
.config-option-btn:hover:not(:disabled):not(.unavailable):not(.selected) {
    border-color: var(--primary);
    background: rgba(0,84,144,.04);
}
.config-option-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.config-option-btn:disabled,
.config-option-btn.unavailable {
    opacity: .38;
    cursor: not-allowed;
    pointer-events: none;
}
.opt-cap-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    margin-bottom: 4px;
}
.config-option-btn .opt-label { font-weight: 600; }
.config-option-btn .opt-sub {
    font-size: .7rem;
    font-weight: 400;
    color: var(--muted);
    margin-top: 2px;
}
.config-option-btn.selected .opt-sub { color: rgba(255,255,255,.75); }

/* ---- Conditioning toggle ---- */
.config-toggle-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: fit-content;
}
.config-toggle-btn {
    padding: 10px 24px;
    background: #fff;
    border: none;
    border-right: 1px solid var(--border);
    font-family: var(--font-body);
    font-size: .875rem;
    font-weight: 500;
    color: var(--body);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.config-toggle-btn:last-child { border-right: none; }
.config-toggle-btn:hover:not(:disabled) { background: var(--lighter-bg); }
.config-toggle-btn.selected {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.config-toggle-btn:disabled { opacity: .38; cursor: not-allowed; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .configurator-wrap {
        grid-template-columns: 1fr;
    }
    /* Show form before preview on mobile — preview is empty until selections are made */
    .configurator-form    { order: 1; }
    .configurator-preview { order: 2; position: static; }
}

@media (max-width: 600px) {
    .configurator-form { padding: 20px; }
    .config-result-actions { flex-direction: column; }
    .config-result-actions .btn { width: 100%; }
    .config-option-group { gap: 6px; }
    .config-option-btn { min-width: 80px; padding: 8px 10px; font-size: .75rem; }
    .config-toggle-btn { padding: 9px 16px; font-size: .8rem; }
}
