/* KS Home Manager — Blocco B — v4.0
   B1 Camere+Bagni | B2 Energia | B3 Dati Energetici | B4 Garage | B5 Dotazioni+Piano */

/* ════════════════════════════════════════════════
   STRUTTURA BLOCCO B
   ════════════════════════════════════════════════ */

.ks-block-b {
    padding-top: 20px;
    padding-bottom: 24px;
}

/* ── Header ──────────────────────────────────────── */
.ks-block-header {
    margin-bottom: 20px;
}

/* ── Back button ─────────────────────────────────── */
.ks-b-back-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #84A8D5;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    transition: color 150ms ease;
    letter-spacing: 0.02em;
}
.ks-b-back-btn:hover { color: #162660; }
.ks-b-back-btn[hidden] { display: none !important; }

.ks-block-eyebrow {
    margin: 0 0 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.10em;
    color: #84A8D5;
    text-transform: uppercase;
}

.ks-block-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #1A2A4F;
    letter-spacing: -0.01em;
}

/* ── Step indicator (5 passi) ────────────────────── */
.ks-b-steps {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
}

.ks-b-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #DAEAF5;
    flex-shrink: 0;
    transition: background 300ms ease, transform 200ms ease;
}

.ks-b-dot.active { background: #0063FA; transform: scale(1.25); }
.ks-b-dot.done   { background: #162660; }

.ks-b-line {
    flex: 1;
    height: 2px;
    background: #DAEAF5;
    transition: background 300ms ease;
}

.ks-b-line.done { background: #162660; }

/* ── Viewport / Slide track ──────────────────────── */
.ks-b-viewport {
    overflow: hidden;
    position: relative;
    width: 100%;
}

.ks-b-track {
    display: flex;
    width: 100%;
    transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.ks-b-panel {
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* ── Impact text ─────────────────────────────────── */
.ks-field-impact {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #84A8D5;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

.ks-impact-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #84A8D5;
    flex-shrink: 0;
}

/* ── Pulsante primario (Avanti) ───────────────────── */
.ks-btn-primary {
    display: block;
    width: 100%;
    height: 70px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #162660 0%, #0063FA 100%);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 180ms ease, transform 130ms ease;
    margin-top: 16px;
}
.ks-btn-primary:hover  { opacity: 0.88; transform: translateY(-1px); }
.ks-btn-primary:active { opacity: 1;    transform: translateY(0); }
.ks-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ════════════════════════════════════════════════
   B1: Camere + Bagni
   ════════════════════════════════════════════════ */

.ks-b1-steppers {
    display: flex;
    gap: 24px;
    margin-top: 8px;
    margin-bottom: 16px;
}

.ks-b1-stepper-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ks-b1-stepper-label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #1A2A4F;
}

.ks-b1-hint {
    font-size: 12px;
    color: #b0c4d4;
    font-style: italic;
    margin: 0;
}

/* Stepper (bottoni −/+ con numero centrale) */
.ks-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1.5px solid #DAEAF5;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.ks-stepper-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: #F6F9FC;
    font-family: inherit;
    font-size: 20px;
    font-weight: 400;
    color: #5a7290;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.ks-stepper-btn:hover  { background: #edf4fb; color: #162660; }
.ks-stepper-btn:active { background: #DAEAF5; }

.ks-stepper-val {
    min-width: 48px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: #1A2A4F;
    padding: 0 4px;
    user-select: none;
}

/* ════════════════════════════════════════════════
   B2: Classe energetica
   ════════════════════════════════════════════════ */

.ks-energia-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ks-energia-card {
    min-height: 72px;
    align-items: center;
    text-align: center;
    padding: 10px 8px;
}

/* Badge lettera con colori EU */
.ks-energia-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    margin: 0 auto 4px;
    flex-shrink: 0;
}

.ks-e-a  { background: #1a7f37; }
.ks-e-b  { background: #5aa623; }
.ks-e-c  { background: #a0c420; }
.ks-e-d  { background: #ffc107; color: #1A2A4F; }
.ks-e-e  { background: #f97316; }
.ks-e-f  { background: #ef4444; }
.ks-e-g  { background: #b91c1c; }
.ks-e-ns { background: #8fa5b8; }

.ks-energia-card.selected .ks-energia-badge { opacity: 0.85; }

/* ════════════════════════════════════════════════
   B3: Dati energetici estesi
   ════════════════════════════════════════════════ */

.ks-b3-classe-confirmed {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f0f6ff;
    border: 1px solid #DAEAF5;
    border-radius: 6px;
    font-size: 12px;
    color: #5a7290;
    margin-bottom: 14px;
    width: fit-content;
}

.ks-b3-classe-confirmed strong {
    color: #162660;
    font-weight: 700;
}

.ks-b3-classe-confirmed[hidden] { display: none !important; }

.ks-b3-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* Riscaldamento a tutta larghezza (unico campo obbligatorio) */
.ks-b3-field--full {
    margin-bottom: 14px;
}

/* Riscaldamento: card a 3 colonne (coerente con B2/B4) */
.ks-risc-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.ks-risc-grid .kshm-card {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 8px;
    min-height: 74px;
    gap: 6px;
}

.ks-risc-grid .kshm-card-icon  { font-size: 22px; }
.ks-risc-grid .kshm-card-label { font-size: 12px; text-align: center; line-height: 1.25; }

/* Toggle "Aggiungi altri dettagli energetici" */
.ks-b3-optional-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1.5px dashed #DAEAF5;
    border-radius: 12px;
    background: #F7FBFE;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #5a7290;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.ks-b3-optional-toggle:hover {
    border-color: #0063FA;
    color: #0063FA;
}

.ks-b3-optional-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #EAF1FF;
    color: #0063FA;
    font-weight: 700;
    line-height: 1;
    transition: transform 200ms ease;
}

.ks-b3-optional-toggle.is-open .ks-b3-optional-icon {
    transform: rotate(45deg); /* + → × */
}

.ks-b3-optional-text { flex: 1; text-align: left; }

.ks-b3-optional-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #84A8D5;
    background: #fff;
    border: 1px solid #DAEAF5;
    border-radius: 999px;
    padding: 2px 8px;
}

.ks-b3-optional[hidden] { display: none !important; }

.ks-b3-optional {
    animation: kshm-fadein 280ms ease;
}

.ks-b3-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ks-b3-label {
    font-size: 11px;
    font-weight: 600;
    color: #8fa5b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ks-required {
    color: #e53e3e;
    margin-left: 2px;
}

.ks-b3-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ks-b3-pill {
    padding: 4px 9px;
    border: 1.5px solid #DAEAF5;
    border-radius: 20px;
    background: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: #1A2A4F;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.ks-b3-pill:hover {
    border-color: #0063FA;
    color: #0063FA;
}

.ks-b3-pill.selected {
    border-color: #162660;
    background: #162660;
    color: #fff;
}

.ks-b3-hint {
    font-size: 12px;
    color: #e53e3e;
    font-style: italic;
    margin: 6px 0 0;
}

.ks-b3-hint[hidden] { display: none !important; }

.ks-b3-tip {
    font-size: 12px;
    color: #b0c4d4;
    font-style: italic;
    margin: 4px 0 0;
    text-align: center;
}

.ks-b3-avanti {
    margin-top: 12px;
}

/* ════════════════════════════════════════════════
   B4: Garage — usa .kshm-card da kshm-fields.css
   Scope esplicito per non dipendere dall'ordine CSS
   ════════════════════════════════════════════════ */

#ks-b4 .kshm-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

#ks-b4 .kshm-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border: 1.5px solid #DAEAF5;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    min-height: 80px;
    text-align: left;
    box-sizing: border-box;
    transition: border-color 160ms ease, background 160ms ease,
                transform 160ms ease, box-shadow 160ms ease;
}

#ks-b4 .kshm-card:hover {
    border-color: #0063FA;
    background: #f0f6ff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,99,250,0.12);
}

#ks-b4 .kshm-card.selected {
    border-color: #162660;
    background: #162660;
    box-shadow: 0 4px 14px rgba(22,38,96,0.22);
}

#ks-b4 .kshm-card.selected .kshm-card-label { color: #fff; }
#ks-b4 .kshm-card.selected .kshm-card-delta { color: rgba(255,255,255,0.70); }
#ks-b4 .kshm-card-icon  { font-size: 20px; line-height: 1; }
#ks-b4 .kshm-card-label { font-size: 13px; font-weight: 600; color: #1A2A4F; line-height: 1.3; }
#ks-b4 .kshm-card-delta { font-size: 11px; font-weight: 500; }
#ks-b4 .kshm-card-delta.positive { color: #16a34a; }
#ks-b4 .kshm-card-delta.neutral  { color: #8fa5b8; }

/* ════════════════════════════════════════════════
   B5: Dotazioni + Piano / Livelli
   ════════════════════════════════════════════════ */

.ks-b5-garage-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #f0f6ff;
    border: 1px solid #DAEAF5;
    border-radius: 6px;
    font-size: 12px;
    color: #5a7290;
    margin-bottom: 14px;
}

.ks-b5-garage-chip[hidden] { display: none !important; }

.ks-b5-livelli-wrap,
.ks-b5-piano-wrap {
    margin-bottom: 16px;
}

.ks-b5-livelli-wrap[hidden],
.ks-b5-piano-wrap[hidden] { display: none !important; }

.ks-b5-label {
    display: block;
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1A2A4F;
}

/* Piano: gruppo di bottoni discreti */
.ks-piano-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ks-piano-btn {
    flex: 1;
    min-width: 44px;
    height: 42px;
    border: 1.5px solid #DAEAF5;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #1A2A4F;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.ks-piano-btn:hover    { border-color: #0063FA; background: #f0f6ff; }
.ks-piano-btn.selected { border-color: #162660; background: #162660; color: #fff; }

.ks-piani-wrap    { margin-bottom: 16px; }
.ks-ascensore-wrap { margin-bottom: 16px; }

/* Ascensore toggle pill */
.ks-toggle-pill {
    display: inline-flex;
    border: 1.5px solid #DAEAF5;
    border-radius: 8px;
    overflow: hidden;
}

.ks-toggle-option {
    padding: 9px 22px;
    border: none;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #1A2A4F;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease;
}

.ks-toggle-option + .ks-toggle-option { border-left: 1.5px solid #DAEAF5; }

.ks-toggle-option[aria-pressed="true"],
.ks-toggle-option.selected { background: #162660; color: #fff; }

.ks-toggle-option:hover:not([aria-pressed="true"]):not(.selected) {
    background: #f0f6ff;
    color: #0063FA;
}

.ks-piano-section { margin-bottom: 4px; }

/* Dotazioni: griglia 3 colonne */
.ks-b5-dotazioni { margin-bottom: 4px; }

.ks-dotazioni-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.ks-dotazione-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 12px;
    border: 1.5px solid #DAEAF5;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    user-select: none;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.ks-dotazione-item:hover {
    border-color: #0063FA;
}

.ks-dotazione-item.is-checked {
    border-color: #162660;
    background: #F5F8FF;
    box-shadow: 0 2px 8px rgba(22,38,96,0.08);
}

.ks-dotazione-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ks-checkbox-box {
    width: 18px;
    height: 18px;
    border: 1.5px solid #DAEAF5;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    margin-top: 1px;
    transition: border-color 160ms ease, background 160ms ease;
    position: relative;
}

.ks-dotazione-item input:checked ~ .ks-checkbox-box {
    background: #162660;
    border-color: #162660;
}

.ks-dotazione-item input:checked ~ .ks-checkbox-box::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: 2.5px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(40deg);
}

.ks-checkbox-label {
    font-size: 12px;
    color: #1A2A4F;
    font-weight: 500;
    line-height: 1.3;
}

.ks-cb-delta {
    display: block;
    font-size: 11px;
    color: #16a34a;
    font-weight: 500;
}

/* ════════════════════════════════════════════════
   Blocchi B/C: larghezza piena garantita
   ════════════════════════════════════════════════ */

#ks-block-b-wrap,
#ks-block-c-wrap {
    width: 100%;
    box-sizing: border-box;
}

/* ════════════════════════════════════════════════
   Responsive mobile
   ════════════════════════════════════════════════ */

@media (max-width: 600px) {
    .ks-energia-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ks-b3-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ks-dotazioni-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ks-b1-steppers {
        gap: 16px;
    }

    .ks-piano-group {
        gap: 6px;
    }

    .ks-piano-btn {
        min-width: 38px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .ks-b3-grid {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════
   PULSANTI CONTESTUALI B1 / B5 (v4.1)
   Desktop: nascosti di default, rivelati dopo 800ms
            o alla prima interazione.
   Mobile:  sempre visibili + fissi in fondo
            quando il pannello è attivo.
   ════════════════════════════════════════════════ */

/* B1 pulsante contestuale — sempre visibile */
.ks-b1-advance {
    margin-top: 20px;
    transition: transform 130ms ease;
}

/* B5 pulsante contestuale — sempre visibile */
.ks-b5-avanti {
    margin-top: 16px;
    transition: transform 130ms ease;
}

/* Mobile (< 768px): fissi in fondo quando il pannello è attivo */
@media (max-width: 767px) {
    .ks-b1-advance {
        margin-top: 16px;
    }

    #ks-b1.ks-panel-active .ks-b1-advance {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        border-radius: 0;
        margin: 0;
        height: 52px;
        font-size: 15px;
    }

    #ks-b5.ks-panel-active .ks-b5-avanti {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        border-radius: 0;
        margin: 0;
        height: 52px;
        font-size: 15px;
    }

    /* Padding inferiore per non nascondere contenuto sotto il pulsante fisso */
    #ks-b1.ks-panel-active,
    #ks-b5.ks-panel-active {
        padding-bottom: 68px;
    }
}
