/* KS Home Manager — v0.3.0 */

:root {
    --kshm-navy:        #1A2A4F;
    --kshm-navy-action: #162660;
    --kshm-electric:    #0063FA;
    --kshm-mist:        #DAEAF5;
    --kshm-cream:       #F6F1E9;
    --kshm-white:       #ffffff;
    --kshm-radius:      10px;
    --kshm-ease:        300ms ease;
}

/* ── Root ───────────────────────────────────── */
.kshm-root {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    color: var(--kshm-navy);
    box-sizing: border-box;
}

.kshm-root *,
.kshm-root *::before,
.kshm-root *::after {
    box-sizing: inherit;
}

/* ── Address wrapper ────────────────────────── */
.kshm-address-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    /*padding: 32px 16px;*/
}

.kshm-address-inner {
    width: 100%;
    max-width: 640px;
}

.kshm-lead {
    margin: 0 0 22px;
    font-size: 18px;
    line-height: 1.55;
    color: var(--kshm-navy);
}

/* ── Bubble tooltip pulsante ────────────────── */
.kshm-address-bubble {
    display: inline-flex;
    align-items: center;
    background: var(--kshm-electric);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    letter-spacing: 0.01em;
    animation: kshm-bubble-pulse 2.2s ease-in-out infinite;
    box-shadow: 0 4px 14px rgba(0, 99, 250, 0.32);
}

.kshm-address-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 22px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--kshm-electric);
}

@keyframes kshm-bubble-pulse {
    0%, 100% {
        transform: translateY(0px);
        box-shadow: 0 4px 14px rgba(0, 99, 250, 0.32);
    }
    50% {
        transform: translateY(-4px);
        box-shadow: 0 8px 22px rgba(0, 99, 250, 0.44);
    }
}

/* 2026-07-09 — Bubble nascosta mentre il campo indirizzo è a fuoco;
   ricompare al blur (gestita da kshm-address.js).
   Usiamo visibility invece di display:none così il box resta nel flusso e
   riserva il suo spazio (~52px): la card sottostante non si sposta più
   (niente layout shift), pur mantenendo identico l'effetto visivo del bubble. */
.kshm-address-bubble.kshm-address-bubble--hidden {
    visibility: hidden;
}

/* ── Address card (wrapper) ─────────────────── */
.kshm-address-card {
    background: var(--kshm-white);
    border-radius: 14px;
    box-shadow:
        0 1px 3px rgba(26, 42, 79, 0.08),
        0 6px 24px rgba(26, 42, 79, 0.10);
    padding: 8px;
    border: 1px solid rgba(218, 234, 245, 0.8);
}

/* ── Address row ────────────────────────────── */
.kshm-address-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

.kshm-field-group {
    display: flex;
    flex-direction: column;
}

/* 2026-07-09 — Civico allargato (96→120px) così mostra "N°/Interno" per intero;
   l'indirizzo (flex:1 1 auto) si restringe da solo della stessa quantità →
   larghezza totale della riga invariata. */
.kshm-field-address { flex: 1 1 auto; min-width: 0; }
.kshm-field-civico  { flex: 0 0 120px; position: relative; }

/* 2026-07-09 — Divisore verticale azzurro tenue tra il campo indirizzo e il
   campo N°/Interno, centrato nel gap (6px) della riga. */
.kshm-field-civico::before{
    content: "";
    position: absolute;
    left: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: #daeaf5;
    border-radius: 8px;
    pointer-events: none;
}

/* ── Inputs ─────────────────────────────────── */
/* 2026-07-09 — Controlli più "chunky": altezza 52→60px. Serve anche min-height
   perché l'input è un flex-item dentro .kshm-field-group (a sua volta stirato
   all'altezza della riga): con la sola `height` il flex-shrink lo ricomprimeva
   a 52px. min-height blocca la compressione e trascina riga + pulsante a 60px. */
.kshm-input {
    width: 100%;
    height: 60px;
    min-height: 60px;
    padding: 0 16px;
    border: 2px solid #c8d8e8;
    border-radius: var(--kshm-radius);
    font-family: inherit;
    font-size: 16px;
    color: var(--kshm-navy);
    background: var(--kshm-white);
    outline: none;
    transition: border-color var(--kshm-ease), box-shadow var(--kshm-ease);
}

.kshm-input::placeholder { color: #8fa5b8; }

.kshm-input:focus {
    border-color: var(--kshm-electric);
    box-shadow: 0 0 0 3px rgba(0, 99, 250, 0.14);
}

.kshm-input-civico {
    text-align: center;
    letter-spacing: 0.04em;
    padding: 0 8px;
}

/* ── Hint & error ───────────────────────────── */
.kshm-address-hint {
    margin: 6px 0 0;
    font-size: 13px;
    color: #5a7290;
}

.kshm-address-error {
    margin: 8px 0 0;
    font-size: 14px;
    color: #c0392b;
    font-weight: 500;
}

/* ── CTA button — inline nella card ────────── */
/* 2026-07-09 — Il tema Salient applica `margin: 25px 0 !important` a tutti i
   <button>: nella riga flex quei margini (a) spingevano l'altezza della riga a
   68px lasciando un gap bianco di ~16px sotto gli input (alti 52px), e (b) in
   align-self:stretch riducevano il contenuto del pulsante a ~18px (sottilissimo).
   Azzerare il margine con specificità .kshm-root + !important risolve entrambi:
   la riga torna a 52px e il pulsante riempie tutta l'altezza. */
.kshm-root .kshm-cta-btn {
    margin: 0 !important;
}

.kshm-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    background: var(--kshm-navy-action);
    color: var(--kshm-white);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--kshm-ease), transform var(--kshm-ease), box-shadow var(--kshm-ease);
    letter-spacing: 0.01em;
}

button#kshm-discover-btn {
    font-size: 17px;
    font-weight: 400;
}

.kshm-cta-btn:not([disabled]):hover {
    background: #0054d4;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(22, 38, 96, 0.28);
}

.kshm-cta-btn:not([disabled]):active {
    transform: translateY(0);
    box-shadow: none;
}

.kshm-cta-btn[disabled],
.kshm-cta-btn[aria-disabled="true"] {
    opacity: 0.42;
    cursor: not-allowed;
}

/* ── Screen reader only ─────────────────────── */
.kshm-root .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── jQuery UI autocomplete override ───────── */
.ui-autocomplete.ui-widget-content {
    /* 2026-07-30 — Reset esplicito di list-style/padding/margin del <ul>: di norma lo
       fornisce la CSS base di jQuery UI (.ui-menu), ma sulle LP lean quella è rimossa
       dal dequeue → il <ul> tornava al padding-left di default = rientro strano. (Claude/dev) */
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #c8d8e8;
    border-radius: var(--kshm-radius);
    box-shadow: 0 8px 24px rgba(26, 42, 79, 0.10);
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 15px;
    background: var(--kshm-white);
    max-width: 92vw;       /* non superare mai il bordo dello schermo */
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    z-index: 9999;
}

.ui-autocomplete .ui-menu-item { list-style: none; margin: 0; padding: 0; }

.ui-autocomplete .ui-menu-item-wrapper {
    padding: 10px 16px;
    color: var(--kshm-navy);
    cursor: pointer;
    border-radius: 0;
    border: none !important;
    white-space: normal;       /* le vie lunghe vanno a capo invece di allargare il menu */
    overflow-wrap: anywhere;
}

.ui-autocomplete .ui-menu-item-wrapper.ui-state-active,
.ui-autocomplete .ui-menu-item-wrapper:hover {
    background: var(--kshm-mist);
    color: var(--kshm-navy-action);
    border: none !important;
    margin: 0;
}

/* ── Dark theme ─────────────────────────────── */
.kshm-theme-dark {
    background: var(--kshm-navy);
    color: var(--kshm-white);
}

.kshm-theme-dark .kshm-lead {
    color: var(--kshm-white);
}

.kshm-theme-dark .kshm-input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.20);
    color: var(--kshm-white);
}

.kshm-theme-dark .kshm-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.kshm-theme-dark .kshm-input:focus {
    border-color: var(--kshm-electric);
    box-shadow: 0 0 0 3px rgba(0, 99, 250, 0.25);
}

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 540px) {
    .kshm-address-wrapper {
        padding: 20px 12px;
    }

    .kshm-address-card {
        padding: 6px;
    }

        body input[type=text]{
        font-size: 13px !important;
        text-align: -webkit-center;
    }


    .kshm-address-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* 2026-07-29 — Indirizzo + civico sulla STESSA riga (come la LP), CTA a piena
       larghezza sotto. Prima .kshm-field-address era flex:1 1 100% → l'indirizzo
       occupava tutta la riga e mandava il civico sotto. Rapporto ~63/37 così
       entrambi i placeholder ("Inserisci l'indirizzo" / "N°/Interno") restano
       leggibili anche su schermi stretti. */
    .kshm-field-address {
        flex: 1.7 1 0;
        min-width: 0;
    }

    .kshm-field-civico {
        flex: 1 1 0;
        min-width: 0;
    }

    /* 2026-07-09 — Divisore civico nascosto su mobile (gap sufficiente). */
    .kshm-field-civico::before {
        display: none;
    }

    .kshm-cta-btn {
        flex: 1 1 100%;
        font-size: 15px;
        padding: 0 12px;
        min-height: 65px;
    }

    .kshm-input {
        height: 60px;
        min-height: 44px; /* 2026-07-09 — su mobile la card resta compatta (44px): sovrascrive il min-height:60 base */
        font-size: 15px;
    }

    .kshm-lead {
        font-size: 16px;
    }
}
