/* S-Data AI Widget — scoped */
.sdata-ai-section {
    padding: 1.25rem 0 0.5rem;
    position: relative;
    z-index: 5;
}

/* Widget in cima alla pagina: padding minimo */
.sdata-ai-section--first {
    padding: 0.15rem 0 0.25rem;
    margin: 0;
}

.sdata-ai-root {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 1rem;
}

/*
 * Hero subito dopo il widget: evita il "buco" da min-height 100vh + contenuto centrato
 * e padding-top pensato per quando l'hero era il primo blocco sotto la navbar.
 */
.sdata-ai-section--first + .hero,
.sdata-ai-section--first + section.hero {
    min-height: auto;
    align-items: flex-start;
    padding-top: 0.5rem;
    padding-bottom: 2.5rem;
}

.sdata-ai-section--first + .hero.data-entry-hero {
    min-height: auto;
    align-items: flex-start;
    padding-top: 0.5rem;
}

.sdata-ai-section--first + .ls-hero {
    padding-top: 0.75rem;
    padding-bottom: 2.5rem;
}

.sdata-ai-section--first + .vpmi-hero,
.sdata-ai-section--first + header.vpmi-hero {
    padding-top: 0.75rem;
    padding-bottom: 2.5rem;
}

.sdata-ai-card {
    position: relative;
    background: linear-gradient(145deg, rgba(12, 16, 28, 0.97), rgba(8, 12, 24, 0.99));
    border: none;
    border-radius: 18px;
    box-shadow:
        0 0 24px rgba(0, 240, 255, 0.12),
        0 0 48px rgba(123, 97, 255, 0.08),
        0 16px 48px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    isolation: isolate;
}

.sdata-ai-card::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 2px;
    border-radius: 18px;
    background: linear-gradient(
        120deg,
        #00f0ff,
        #7b61ff,
        #00ff9d,
        #58a6ff,
        #c678ff,
        #00f0ff
    );
    background-size: 320% 320%;
    animation: sdata-ai-neon-flow 7s ease infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 0;
}

.sdata-ai-card::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(14, 18, 32, 0.98), rgba(6, 10, 22, 0.99));
    pointer-events: none;
    z-index: 0;
}

.sdata-ai-card > * {
    position: relative;
    z-index: 1;
}

@keyframes sdata-ai-neon-flow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .sdata-ai-card::before {
        animation: none;
        background-position: 50% 50%;
    }
}

/* Barra compatta (chiusa) — click per espandere */
.sdata-ai-header-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin: 0;
    padding: 0.7rem 1rem;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.sdata-ai-header-bar:hover,
.sdata-ai-header-bar:focus-visible {
    background: rgba(0, 240, 255, 0.05);
    outline: none;
}

.sdata-ai-header-text {
    flex: 1;
    min-width: 0;
}

.sdata-ai-header-title {
    display: block;
    margin: 0 0 0.2rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #f0f6fc;
    line-height: 1.3;
    text-shadow: 0 0 16px rgba(0, 240, 255, 0.2);
}

.sdata-ai-robot {
    display: inline-block;
    margin-left: 0.2em;
    font-size: 1.1em;
    vertical-align: -0.05em;
    filter: drop-shadow(0 0 6px rgba(0, 240, 255, 0.35));
}

.sdata-ai-header-desc {
    display: block;
    margin: 0;
    font-size: 0.82rem;
    color: #8b949e;
    line-height: 1.4;
}

.sdata-ai-chevron {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid rgba(0, 240, 255, 0.45);
    background: rgba(0, 240, 255, 0.06);
    position: relative;
    transition: transform 0.2s ease, background 0.2s ease;
}

.sdata-ai-chevron::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 46%;
    width: 8px;
    height: 8px;
    margin: -6px 0 0 -4px;
    border-right: 2px solid #7ee8ff;
    border-bottom: 2px solid #7ee8ff;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.sdata-ai-card.is-expanded .sdata-ai-chevron::after {
    transform: rotate(-135deg);
    top: 54%;
}

.sdata-ai-expandable {
    display: none;
}

.sdata-ai-card.is-expanded .sdata-ai-expandable {
    display: block;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sdata-ai-cta-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sdata-ai-cta-bar a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    color: #e6edf3;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.15s, border-color 0.15s;
}

.sdata-ai-cta-bar a:hover,
.sdata-ai-cta-bar a:focus-visible {
    background: rgba(88, 166, 255, 0.15);
    border-color: rgba(88, 166, 255, 0.45);
    outline: none;
}

.sdata-ai-cta-wa {
    border-color: rgba(37, 211, 102, 0.35);
    color: #3fb950;
}

.sdata-ai-panel {
    display: none;
    flex-direction: column;
}

.sdata-ai-card.is-expanded .sdata-ai-panel.is-open {
    display: flex;
    max-height: 50vh;
}

.sdata-ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
}

.sdata-ai-chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #c9d1d9;
    cursor: pointer;
}

.sdata-ai-chip:hover,
.sdata-ai-chip:focus-visible {
    border-color: rgba(88, 166, 255, 0.5);
    color: #58a6ff;
    outline: none;
}

.sdata-ai-chip--primary {
    border-color: rgba(35, 134, 54, 0.55);
    color: #3fb950;
    font-weight: 600;
}

.sdata-ai-lead-sub {
    margin: 0 0 0.65rem;
    font-size: 0.82rem;
    color: #8b949e;
}

.sdata-ai-call-banner {
    margin: 0.5rem 1rem 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 240, 255, 0.35);
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(123, 97, 255, 0.1));
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.1);
}

.sdata-ai-call-banner p {
    margin: 0 0 0.55rem;
    font-size: 0.88rem;
    color: #e6edf3;
    line-height: 1.45;
}

.sdata-ai-call-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.sdata-ai-call-banner-actions .sdata-ai-btn-contatti {
    width: 100%;
    justify-content: center;
    text-align: center;
}

.sdata-ai-call-banner-actions button,
.sdata-ai-call-banner-actions a {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.sdata-ai-call-banner-actions .sdata-ai-btn-call {
    background: linear-gradient(135deg, #238636, #2ea043);
    color: #fff;
    box-shadow: 0 0 12px rgba(46, 160, 67, 0.35);
}

.sdata-ai-call-banner-actions .sdata-ai-btn-form {
    background: rgba(0, 240, 255, 0.12);
    color: #7ee8ff;
    border: 1px solid rgba(0, 240, 255, 0.4);
}

.sdata-ai-lead--pulse {
    animation: sdata-ai-lead-pulse 1.2s ease-in-out 2;
    border-color: rgba(0, 240, 255, 0.45);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

@keyframes sdata-ai-lead-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
    50% { box-shadow: 0 0 0 6px rgba(0, 240, 255, 0.2); }
}

.sdata-ai-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    min-height: min(220px, 32vh);
    max-height: calc(50vh - 12rem);
    scroll-behavior: smooth;
}

.sdata-ai-msg {
    margin-bottom: 0.65rem;
    max-width: 92%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.sdata-ai-msg--user {
    margin-left: auto;
    background: rgba(88, 166, 255, 0.2);
    color: #e6edf3;
    border-bottom-right-radius: 4px;
}

.sdata-ai-msg--assistant {
    background: rgba(255, 255, 255, 0.06);
    color: #c9d1d9;
    border-bottom-left-radius: 4px;
}

.sdata-ai-msg--system {
    font-size: 0.8rem;
    color: #8b949e;
    text-align: center;
    max-width: 100%;
    background: transparent;
}

.sdata-ai-typing {
    padding: 0 1rem 0.5rem;
    font-size: 0.8rem;
    color: #8b949e;
    font-style: italic;
    display: none;
}

.sdata-ai-typing.is-visible {
    display: block;
}

.sdata-ai-compose {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sdata-ai-compose input {
    flex: 1;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.35);
    color: #e6edf3;
    font-size: 1rem;
}

.sdata-ai-compose input:focus {
    outline: 2px solid rgba(88, 166, 255, 0.5);
    border-color: transparent;
}

.sdata-ai-compose button[type="submit"] {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    background: #238636;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}

.sdata-ai-compose button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sdata-ai-lead {
    display: none;
    padding: 1rem;
    border-top: 1px solid rgba(88, 166, 255, 0.2);
    background: rgba(88, 166, 255, 0.06);
}

.sdata-ai-lead.is-visible {
    display: block;
}

.sdata-ai-lead h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    color: #e6edf3;
}

.sdata-ai-lead label {
    display: block;
    font-size: 0.75rem;
    color: #8b949e;
    margin-bottom: 0.2rem;
}

.sdata-ai-lead input,
.sdata-ai-lead textarea {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.3);
    color: #e6edf3;
    font-size: 0.9rem;
}

.sdata-ai-lead textarea {
    min-height: 72px;
    resize: vertical;
}

.sdata-ai-lead-submit {
    width: 100%;
    padding: 0.55rem;
    border: 0;
    border-radius: 8px;
    background: #58a6ff;
    color: #0d1117;
    font-weight: 600;
    cursor: pointer;
}

.sdata-ai-hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.sdata-ai-privacy {
    padding: 0.5rem 1rem 0.85rem;
    font-size: 0.72rem;
    color: #6e7681;
    line-height: 1.4;
}

.sdata-ai-privacy a {
    color: #58a6ff;
}

.sdata-ai-build {
    padding: 0 1rem 0.5rem;
    font-size: 0.65rem;
    color: #484f58;
    text-align: right;
}

.sdata-ai-fallback {
    padding: 1rem;
    text-align: center;
    color: #d29922;
    font-size: 0.88rem;
}

@media (max-width: 768px) {
    .sdata-ai-section {
        padding-top: 0.5rem;
    }

    .sdata-ai-section--first {
        padding: 0.1rem 0 0.2rem;
    }

    .sdata-ai-section--first + .hero,
    .sdata-ai-section--first + section.hero,
    .sdata-ai-section--first + .hero.data-entry-hero {
        padding-top: 0.35rem;
        padding-bottom: 2rem;
    }

    .sdata-ai-section--first + .ls-hero {
        padding-top: 0.5rem;
        padding-bottom: 2rem;
    }

    .sdata-ai-section--first + .vpmi-hero,
    .sdata-ai-section--first + header.vpmi-hero {
        padding-top: 0.5rem;
        padding-bottom: 2rem;
    }
    .sdata-ai-card.is-expanded .sdata-ai-panel.is-open {
        max-height: 50vh;
    }
    .sdata-ai-messages {
        min-height: min(180px, 28vh);
        max-height: calc(50vh - 11rem);
    }
    .sdata-ai-header-desc {
        font-size: 0.78rem;
    }
    .sdata-ai-cta-bar {
        justify-content: center;
    }
}
