/**
 * Cedral Facade Configurator — Frontend Styles
 * Adapted from eternit-roof-configurator CSS patterns with cedral- prefix.
 */

/* ========== Reset & Container ========== */
.cedral-configurator {
    --cedral-accent: var(--ast-global-color-0, #023d2a);
    --cedral-accent-hover: var(--ast-global-color-1, #467061);
    --cedral-card-bg: var(--ast-global-color-5, #ffffff);
    --cedral-border: #dfe2e6;
    --cedral-text: var(--ast-global-color-3, #040605);
    --cedral-error: #e53935;
    --cedral-radius: 4px;

    font-family: inherit;
    color: var(--cedral-text);
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    line-height: 1.5;
}

.cedral-configurator *,
.cedral-configurator *::before,
.cedral-configurator *::after {
    box-sizing: border-box;
}

/* ========== Step Indicator (inside footer, matches eternit) ========== */
.cedral-steps {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding-top: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.cedral-step-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--cedral-border);
    background: var(--cedral-card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--cedral-accent);
    cursor: pointer;
    transition: all 0.3s ease;
}
.cedral-step-dot:first-child {
    cursor: default;
}

.cedral-step-dot.active {
    border-color: var(--cedral-accent);
    background: var(--cedral-accent);
    color: #fff;
}

.cedral-step-dot.completed {
    border-color: var(--cedral-accent);
    background: var(--cedral-card-bg);
    color: var(--cedral-accent);
    cursor: pointer;
}

.cedral-step-dot:not(:first-child):hover {
    background: var(--cedral-accent);
    color: #fff;
}

/* ========== Main Layout (grid) ========== */
.cedral-main {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    padding: 0;
    min-height: 500px;
}

.cedral-controls {
    background: var(--cedral-card-bg);
    border: none;
    border-radius: 12px;
    padding: 24px;
    overflow-y: auto;
    max-height: 650px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.cedral-preview {
    background: var(--cedral-card-bg);
    border: none;
    border-radius: 12px;
    position: relative;
    min-height: 500px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

/* ========== Step Content ========== */
.cedral-configurator h3 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--cedral-accent);
}

/* ========== Product Selector (Step 0) ========== */
.cedral-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.cedral-product-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 2px solid var(--cedral-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--cedral-card-bg);
    min-height: 64px;
}

.cedral-product-card:hover {
    border-color: var(--cedral-accent);
}

.cedral-product-card.selected {
    border-color: var(--cedral-accent);
    border-left: 4px solid var(--cedral-accent);
}

.cedral-product-card svg {
    display: block;
    width: 80px;
    height: 50px;
}
.cedral-product-card .product-img {
    width: 64px;
    height: 48px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: calc(var(--cedral-radius) - 2px);
    display: block;
    flex-shrink: 0;
}

.cedral-product-card .product-card-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.cedral-product-card .product-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.cedral-product-card .product-desc {
    font-size: 11px;
    color: var(--cedral-accent);
    line-height: 1.2;
}

.cedral-product-card .product-price {
    font-size: 12px;
    color: var(--cedral-accent);
    margin-top: 2px;
    line-height: 1.25;
}

.cedral-product-card .product-price strong {
    font-weight: 700;
}

/* ── Finish selector ── */
.cedral-finish-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.cedral-finish-row .finish-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cedral-text);
}

.cedral-finish-btn {
    padding: 6px 16px;
    border: 1px solid #023d29;
    border-radius: 20px;
    background: none;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.cedral-finish-btn:hover,
.cedral-finish-btn.selected {
    background: #023d29;
    color: #fff;
}

/* ========== Shape Selector (Step 0) ========== */
.cedral-shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.cedral-shape-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px 6px;
    border: 2px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.cedral-shape-card:hover {
    border-color: var(--cedral-accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cedral-shape-card.selected {
    border-color: var(--cedral-accent);
    border-left: 3px solid var(--cedral-accent);
    background: transparent;
}

.cedral-shape-card svg {
    display: block;
    width: 56px;
    height: 42px;
}

.cedral-shape-card .shape-name {
    font-size: 12px;
    font-weight: 600;
}

.cedral-shape-card .shape-desc {
    font-size: 10px;
    color: #023d29;
}

/* ========== Slider Input ========== */
.cedral-slider-group {
    margin-bottom: 16px;
}

.cedral-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cedral-derived-val {
    font-size: 13px;
    color: var(--cedral-accent);
    margin: 0 0 12px;
}

.cedral-slider-header label {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.cedral-slider-value {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cedral-slider-group input[type="range"] {
    display: block;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--cedral-border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.cedral-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cedral-accent);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.cedral-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.cedral-slider-group input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cedral-accent);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.cedral-num-input {
    width: 6em !important;
    min-width: 6em !important;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    padding: 6px 4px;
    -moz-appearance: textfield;
}

.cedral-num-input::-webkit-inner-spin-button,
.cedral-num-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cedral-slider-unit {
    font-size: 14px;
    color: var(--cedral-accent);
}

.cedral-constraint-msg {
    display: block;
    font-size: 12px;
    color: var(--cedral-error);
    min-height: 16px;
    margin-top: 4px;
}

/* ========== Wall Sections (Step 1) ========== */
.cedral-wall-section {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
}

.cedral-wall-section h5 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cedral-wall-area {
    font-size: 13px;
    font-weight: 400;
    color: var(--cedral-accent);
}

.cedral-global-height {
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    padding: 14px;
    margin-bottom: 16px;
}

.cedral-gable-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-top: -8px;
    margin-bottom: 8px;
}

.cedral-gable-toggle input[type="checkbox"] {
    accent-color: var(--cedral-accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ── Floor-based rectangle input ── */
.cedral-floor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.cedral-floor-header h5 {
    margin: 0;
}
.cedral-remove-floor {
    background: none;
    border: 1px solid #c44;
    color: #c44;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: var(--cedral-radius);
    cursor: pointer;
}
.cedral-remove-floor:hover {
    background: #c44;
    color: #fff;
}
.cedral-add-floor {
    display: block;
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--cedral-accent);
    background: none;
    border: 2px dashed var(--cedral-border);
    border-radius: var(--cedral-radius);
    cursor: pointer;
    margin-bottom: 16px;
}
.cedral-add-floor:hover {
    background: color-mix(in srgb, var(--cedral-accent) 6%, var(--cedral-card-bg));
    border-color: var(--cedral-accent);
}

/* ========== Openings (Step 2) ========== */
.cedral-wall-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cedral-wall-tab {
    padding: 6px 14px;
    border: 1px solid #023d29;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: none;
    color: #000;
    transition: color 0.2s, background-color 0.2s;
}

.cedral-wall-tab:hover,
.cedral-wall-tab.active {
    background: #023d29;
    color: #fff;
}

.cedral-wall-tab .tab-badge {
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    margin-left: 4px;
}

.cedral-opening-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.cedral-preset-btn {
    padding: 10px 8px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    background: var(--cedral-card-bg);
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    transition: all 0.2s;
}

.cedral-preset-btn:hover {
    border-color: var(--cedral-accent);
    background: color-mix(in srgb, var(--cedral-accent) 6%, var(--cedral-card-bg));
}

.cedral-preset-btn .preset-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.cedral-preset-btn .preset-label {
    display: block;
    color: #000;
    font-size: 12px;
}

.cedral-preset-btn .preset-size {
    display: block;
    color: #013d29;
    font-size: 11px;
}

/* "+" custom-opening card — same shape as a preset card but visually flagged
   as a CTA: dashed accent border + accent-tinted icon. Replaces the old
   "Lisa kohandatud ava..." details/form. */
.cedral-preset-btn.cedral-preset-custom {
    border-style: dashed;
    border-color: var(--cedral-accent);
    color: var(--cedral-accent);
}
.cedral-preset-btn.cedral-preset-custom .preset-icon {
    font-size: 28px;
    line-height: 1;
    color: var(--cedral-accent);
}

.cedral-openings-list {
    margin-top: 12px;
    min-height: 360px;
    overflow-y: auto;
}

.cedral-opening-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--cedral-card-bg);
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    margin-bottom: 6px;
}

.cedral-opening-item .opening-info {
    flex: 1;
    font-size: 13px;
}

.cedral-opening-item .opening-dims {
    color: var(--cedral-accent);
    font-size: 12px;
}

.cedral-opening-edit,
.cedral-opening-duplicate,
.cedral-opening-remove {
    width: 28px;
    height: 28px;
    border: 1px solid var(--cedral-border);
    background: none;
    font-size: 14px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    color: var(--cedral-accent);
}

.cedral-opening-edit:hover,
.cedral-opening-duplicate:hover {
    background: var(--cedral-accent);
    border-color: var(--cedral-accent);
    color: #fff;
}

.cedral-opening-remove:hover {
    background: var(--cedral-error);
    border-color: var(--cedral-error);
    color: #fff;
}

/* Opening inline edit form */
.cedral-opening-edit-form {
    background: var(--cedral-card-bg);
    border: 2px solid var(--cedral-accent);
    border-radius: var(--cedral-radius);
    padding: 14px;
    margin-bottom: 6px;
}

.cedral-opening-edit-form h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 10px;
}

.cedral-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.cedral-edit-actions button {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--cedral-radius);
    cursor: pointer;
    border: none;
}

.cedral-edit-save {
    background: var(--cedral-accent);
    color: #fff;
}

.cedral-edit-cancel {
    background: var(--cedral-card-bg);
    color: var(--cedral-text);
    border: 1px solid var(--cedral-border) !important;
}

/* ── Dormers (Vintskapid) ── */
.cedral-dormer-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--cedral-border);
}
.cedral-dormer-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}
.cedral-dormer-subtitle {
    font-size: 12px;
    color: var(--cedral-accent);
}
.cedral-dormer-item {
    background: var(--cedral-card-bg);
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    padding: 12px;
    margin-bottom: 8px;
}
.cedral-dormer-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.cedral-dormer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
}
.cedral-side-btn {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    background: var(--cedral-card-bg);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--cedral-text);
}
.cedral-side-btn.active {
    background: var(--cedral-accent);
    border-color: var(--cedral-accent);
    color: #fff;
}
.cedral-dormer-add {
    width: 100%;
    justify-content: center;
}

/* ── Accessories step (Lisatarvikud) ── */
.cedral-acc-group {
    padding: 14px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.cedral-acc-group h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 10px;
    color: var(--cedral-text);
}
.cedral-acc-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.cedral-acc-item:last-child { margin-bottom: 0; }
.cedral-acc-item:hover {
    border-color: var(--cedral-accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.cedral-acc-item input[type="checkbox"] {
    accent-color: var(--cedral-accent);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    margin-top: 2px;
}
.cedral-acc-item.cedral-acc-checked {
    border-color: var(--cedral-accent);
    background: color-mix(in srgb, var(--cedral-accent) 5%, var(--cedral-card-bg, #fff));
}
.cedral-acc-item.cedral-acc-disabled { opacity: 0.45; }
.cedral-acc-body { flex: 1; min-width: 0; }
.cedral-acc-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.cedral-acc-calc { font-size: 12px; color: var(--cedral-accent); }
.cedral-acc-calc strong { color: var(--cedral-text); }
.cedral-acc-alt { border-style: dashed; }
.cedral-acc-alt.cedral-acc-checked { border-style: solid; }
.cedral-acc-note {
    font-size: 11px;
    font-weight: 400;
    color: var(--cedral-accent);
    font-style: italic;
}
.cedral-acc-debug-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}
.cedral-acc-debug-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #f60;
    user-select: none;
}
.cedral-acc-debug-toggle input { accent-color: #f60; cursor: pointer; }

/* ── Debug profile editor panel ── */
#cedral-debug-profile-panel {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 25;
    background: rgba(0, 0, 0, 0.88);
    color: #ccc;
    font: 11px/1.3 monospace;
    border-radius: 6px;
    width: 240px;
    max-height: 55%;
    display: none;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.cedral-dbg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(255,255,255,0.08);
    font-weight: bold;
    color: #fff;
    font-size: 11px;
}
.cedral-dbg-copy-btn {
    background: #333;
    color: #0ff;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 2px 8px;
    font: 10px monospace;
    cursor: pointer;
}
.cedral-dbg-copy-btn:hover { background: #555; }
.cedral-dbg-list {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}
.cedral-dbg-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.1s;
}
.cedral-dbg-row:hover { background: rgba(255,255,255,0.08); }
.cedral-dbg-row.active {
    background: rgba(255,255,0,0.15);
    color: #ff0;
}
.cedral-dbg-row-label { flex: 1; }
.cedral-dbg-reset-btn {
    background: none;
    border: 1px solid #555;
    color: #f80;
    border-radius: 3px;
    padding: 1px 5px;
    font: 11px monospace;
    cursor: pointer;
    margin-left: 6px;
}
.cedral-dbg-reset-btn:hover { background: #333; color: #ff0; }
.cedral-dbg-info {
    padding: 6px 10px;
    color: #0f0;
    border-top: 1px solid #333;
    min-height: 40px;
}

/* ── Installation method + joint style selectors ── */
.cedral-method-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}
.cedral-method-card {
    position: relative;
    border: 1px solid var(--cedral-border);
    border-radius: 12px;
    padding: 0;
    text-align: left;
    cursor: pointer;
    background: var(--cedral-card-bg);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 6px rgba(15, 23, 42, 0.035);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}
.cedral-method-card:hover {
    border-color: color-mix(in srgb, var(--cedral-accent) 40%, var(--cedral-border));
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1), 0 2px 4px rgba(15, 23, 42, 0.05);
}
.cedral-method-card.selected {
    border-color: var(--cedral-accent);
    box-shadow: 0 0 0 2px var(--cedral-accent), 0 10px 22px rgba(15, 23, 42, 0.12);
}
.cedral-method-card.selected::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--cedral-accent) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center / 14px 14px no-repeat;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.method-icon {
    font-size: 11px;
    line-height: 1.2;
    margin: 14px 10px 6px;
    color: var(--cedral-accent);
    font-family: monospace;
    text-align: center;
}
.method-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
    transition: transform 0.45s ease;
}
.cedral-method-card:hover .method-img {
    transform: scale(1.04);
}
.method-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    padding: 12px 14px 2px;
    color: var(--cedral-text);
    letter-spacing: 0.1px;
}
.method-desc {
    display: block;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
    padding: 2px 14px 12px;
    color: color-mix(in srgb, var(--cedral-text) 55%, transparent);
}
.cedral-style-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.cedral-style-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    background: none;
    color: var(--cedral-text);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.cedral-style-btn:hover {
    border-color: var(--cedral-accent);
}
.cedral-style-btn.selected {
    border-color: var(--cedral-accent);
    background: color-mix(in srgb, var(--cedral-accent) 6%, var(--cedral-card-bg));
    color: var(--cedral-accent);
}
@media (max-width: 600px) {
    .cedral-method-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ========== Color Swatches (Step 3) ========== */
.cedral-colors {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cedral-color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cedral-color-swatch {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid var(--cedral-border);
    transition: all 0.2s ease;
    position: relative;
}

.cedral-color-swatch:hover {
    transform: scale(1.1);
}

.cedral-color-swatch.selected {
    border-color: var(--cedral-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cedral-accent) 30%, transparent);
}

.cedral-color-swatch.selected::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 14px; height: 14px;
    transform: translate(-50%, -50%);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.cedral-color-label {
    text-align: center;
    font-size: 11px;
    color: var(--cedral-accent);
    margin-top: 4px;
}

/* ========== Summary Table ========== */
.cedral-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    border: none !important;
}

.cedral-summary-table th,
.cedral-summary-table td {
    padding: 10px 12px;
    text-align: left;
    border: none !important;
    border-bottom: 1px solid color-mix(in srgb, var(--cedral-border) 40%, transparent) !important;
}

.cedral-summary-table th {
    font-weight: 500;
    color: var(--cedral-accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cedral-summary-table td {
    font-weight: 600;
}

.cedral-summary-table tr:last-child th,
.cedral-summary-table tr:last-child td {
    border-bottom: none !important;
}

.cedral-summary-table tr.total-row td,
.cedral-summary-table tr.total-row th {
    font-size: 16px;
    font-weight: 700;
    color: var(--cedral-accent);
    padding-top: 14px;
}

.cedral-summary-section {
    margin-bottom: 20px;
}

.cedral-summary-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--cedral-accent);
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Result cards */
.cedral-result-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.cedral-result-card {
    background: var(--cedral-card-bg);
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
    padding: 14px;
    text-align: center;
}

.cedral-result-card .result-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--cedral-accent);
    line-height: 1.2;
}

.cedral-result-card .result-label {
    font-size: 12px;
    color: var(--cedral-accent);
    margin-top: 4px;
}

/* ========== Preview Panel ========== */
.cedral-preview-tabs {
    display: flex;
    border-bottom: 1px solid var(--cedral-border);
    flex-shrink: 0;
}

.cedral-preview-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #000;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.cedral-preview-tab:hover,
.cedral-preview-tab.active {
    color: #fff;
    background: #023d29;
    border-bottom-color: #023d29;
}

.cedral-preview-3d {
    width: 100%;
    flex: 1;
    min-height: 400px;
    background: var(--cedral-card-bg);
    position: relative;
}

.cedral-preview-3d canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    cursor: grab;
}

.cedral-preview-3d canvas:active {
    cursor: grabbing;
}

.cedral-preview-elevation {
    width: 100%;
    flex: 1;
    min-height: 400px;
    background: #fff;
    padding: 12px;
}

.cedral-elevation-nav {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#cedral-elevation-canvas {
    width: 100%;
    height: 350px;
    border: 1px solid var(--cedral-border);
    border-radius: var(--cedral-radius);
}

#cedral-elevation-canvas.hovering-opening {
    cursor: grab;
}

#cedral-elevation-canvas.dragging-opening {
    cursor: grabbing;
}

/* ========== Footer / Navigation (matches eternit-roof-configurator) ========== */
.cedral-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 20px 0;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 16px;
}

.cedral-nav {
    display: flex;
    gap: 12px;
}

.cedral-btn {
    padding: 15px 31px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--cedral-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.cedral-btn:active {
    transform: scale(0.98);
}

.cedral-btn-next {
    background: var(--cedral-accent);
    color: #fff !important;
}

.cedral-btn-next:hover {
    background: var(--cedral-accent-hover);
    color: #fff !important;
}

.cedral-btn-back {
    background: var(--cedral-card-bg);
    color: var(--cedral-text) !important;
    border: 1px solid var(--cedral-border);
}

.cedral-btn-back:hover {
    background: color-mix(in srgb, var(--cedral-accent) 6%, var(--cedral-card-bg));
    color: var(--cedral-text) !important;
}

/* ========== Preview Hint Overlay ========== */
.cedral-preview-hint {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0.85;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.cedral-preview-hint.faded {
    opacity: 0;
}

/* ========== Error ========== */
.cedral-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--cedral-radius);
    padding: 10px 14px;
    color: #991b1b;
    font-size: 13px;
    margin-top: 8px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .cedral-configurator {
        display: flex;
        flex-direction: column;
    }

    .cedral-main {
        display: flex;
        flex-direction: column;
        gap: 0;
        min-height: auto;
    }

    .cedral-preview {
        position: sticky;
        top: 0;
        z-index: 11;
        order: -1;
        height: 35vh;
        min-height: 180px;
        max-height: 260px;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        touch-action: none;
    }

    .cedral-preview-3d {
        min-height: 0;
        touch-action: none;
    }

    .cedral-preview-3d canvas {
        border-radius: 12px 12px 0 0;
    }

    .cedral-preview-elevation {
        min-height: 0;
        flex: 1;
        overflow: hidden;
        padding: 6px;
    }

    #cedral-elevation-canvas {
        height: auto;
        max-height: 100%;
    }

    .cedral-elevation-nav {
        margin-bottom: 4px;
    }

    .cedral-preview-collapse {
        display: none !important;
    }

    .cedral-controls {
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    .cedral-footer {
        background: var(--cedral-card-bg);
        border-top: 1px solid var(--cedral-border);
        border-radius: 0 0 12px 12px;
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 10px 16px;
    }

    .cedral-steps {
        padding: 4px 0 6px;
    }

    .cedral-step-dot {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .cedral-nav {
        width: 100%;
        justify-content: center;
    }

    .cedral-btn {
        padding: 12px 24px;
        font-size: 14px;
    }

    .cedral-shape-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .cedral-opening-presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .cedral-openings-list {
        min-height: 0;
        overflow-y: visible;
    }

    .cedral-result-summary {
        grid-template-columns: 1fr;
    }

    .cedral-method-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) {
    .cedral-preview-collapse {
        display: none;
    }
}

/* ========== Email-gated Pricing (Lead Capture) ========== */
.cedral-pricing-gate {
    position: relative;
    margin-bottom: 20px;
}

.cedral-pricing-blurred {
    filter: blur(8px);
    -webkit-filter: blur(8px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.cedral-pricing-heading {
    margin-bottom: 0;
}

.cedral-pricing-heading + .cedral-pricing-gate {
    margin-top: 0;
}

.cedral-pricing-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.55);
    border-radius: var(--cedral-radius, 4px);
    z-index: 10;
    padding: 16px;
}

.cedral-pricing-overlay-content {
    background: var(--cedral-card-bg, #fff);
    border: 1px solid var(--cedral-accent, #023d2a);
    border-radius: 12px;
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
}

.cedral-pricing-lock-icon {
    color: var(--cedral-accent, #023d2a);
    margin-bottom: 8px;
}

.cedral-pricing-lock-icon svg {
    display: inline-block;
}

.cedral-pricing-overlay-content h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--cedral-accent, #023d2a);
    margin: 0 0 6px;
}

.cedral-pricing-overlay-content p {
    font-size: 13px;
    color: var(--cedral-accent);
    margin: 0 0 16px;
}

.cedral-lead-field {
    margin-bottom: 12px;
    text-align: left;
}

.cedral-lead-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid var(--cedral-border, #dfe2e6);
    border-radius: var(--cedral-radius, 4px);
    background: var(--cedral-card-bg, #fff);
    color: var(--cedral-text, #040605);
    transition: border-color 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.cedral-lead-input:focus {
    border-color: var(--cedral-accent, #023d2a);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cedral-accent, #023d2a) 15%, transparent);
}

.cedral-lead-input-error {
    border-color: var(--cedral-error, #e53935) !important;
}

.cedral-lead-error {
    font-size: 12px;
    color: var(--cedral-error, #e53935);
    margin-top: 4px;
    min-height: 16px;
}

.cedral-lead-submit {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--cedral-radius, 4px);
    background: var(--cedral-accent, #023d2a);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.cedral-lead-submit:hover:not(:disabled) {
    background: var(--cedral-accent-hover, #467061);
}

.cedral-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
