/* Isola il widget dagli effetti (se possibile) */
.ab-widget, .ab-widget * { filter: none !important; }

/* Contenitore toast */
.ab-widget {
    position: fixed;
    z-index: 999999;
    font-size: 1rem; /* Isola il font-size del widget da quello della pagina */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.ab-inline { position: relative; z-index: 1; }

/* Posizioni */
.ab-widget.bottom-right { bottom: var(--ab-offset-v, 20px); right: var(--ab-offset-h, 20px); }
.ab-widget.bottom-left  { bottom: var(--ab-offset-v, 20px); left: var(--ab-offset-h, 20px); }
.ab-widget.top-right    { top: var(--ab-offset-v, 20px); right: var(--ab-offset-h, 20px); }
.ab-widget.top-left     { top: var(--ab-offset-v, 20px); left: var(--ab-offset-h, 20px); }

/* Posizioni centrali usano un offset fisso per semplicità */
.ab-widget.center-right { right: var(--ab-offset-h, 20px); top: 50%; transform: translateY(-50%); }
.ab-widget.center-left  { left: var(--ab-offset-h, 20px); top: 50%; transform: translateY(-50%); }

/* Bottone */
.ab-btn { 
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    box-shadow:0 8px 18px rgba(0,0,0,.15);
    transition: transform .15s ease, box-shadow .2s ease;
    background: var(--ab-btn-bg, #0ea5e9);
    color: var(--ab-btn-fg, #fff);
}
.ab-btn:hover { transform: scale(1.06); 
    box-shadow:0 10px 22px rgba(0,0,0,.2); 
}
.ab-btn:focus { 
    outline: 2px solid rgb(11, 167, 223);
    outline-offset: 2px;
}

.ab-icon { 
    width: 28px; 
    height: 28px; 
    display:block;
    transform: translateX(1px);
}

/* Pannello */
.ab-panel { 
    position: absolute; 
    min-width: 300px; 
    max-width: 360px; 
    background: var(--ab-panel-bg, #fff); 
    color: var(--ab-panel-fg, #0f172a); 
    border-radius: 14px; 
    box-shadow: 0 20px 60px rgba(0,0,0,.2); 
    padding: 14px; 
    display: none; 
    max-height: 500px;
    overflow-y: auto;
}
.ab-panel.open { 
    display: block;
}

/* Stile scrollbar per un look moderno e integrato */
.ab-panel::-webkit-scrollbar {
    width: 8px;
}
.ab-panel::-webkit-scrollbar-track {
    background: transparent;
    margin: 14px 0; /* Applica il padding verticale anche alla traccia */
}
.ab-panel::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,.2);
    border-radius: 4px;
    border: 2px solid transparent; /* Crea un effetto padding */
    background-clip: content-box;
}
.ab-panel {
    scrollbar-width: thin; /* Per Firefox */
    scrollbar-color: rgba(0,0,0,.2) transparent; /* Per Firefox */
}

/* Header */
.ab-head { 
    display:flex; 
    align-items:center; 
    justify-content:space-between; 
    gap:10px; 
    margin-bottom:10px; 
}
.ab-title { 
    font-weight: 700; 
    font-size: 15px; 
    margin:0; 
}
.ab-close { 
    background: transparent; 
    border:0; 
    cursor:pointer; 
    font-size: 18px; 
    line-height:1; 
    border-radius: 6px; /* Aggiunge un raggio per coerenza con il focus */
}
.ab-close:focus {
    outline: 2px solid var(--ab-btn-bg, #0ea5e9);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2); /* Aggiunge un alone per maggiore visibilità */
}

/* Sezioni */
.ab-section { 
    border-top: 1px solid rgba(0,0,0,.06); 
    padding-top:10px; 
    margin-top:10px; 
}
.ab-label { 
    font-size: 12px; 
    font-weight: 600; 
    text-transform: uppercase; 
    opacity:.7; 
    margin-bottom:6px; 
}

/* Opzioni */
.ab-grid { 
    display:grid; 
    grid-template-columns:1fr 1fr; 
    gap:8px; 
}
.ab-toggle { 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    text-align: center;
    font-size: 13px;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.ab-toggle:hover {
    border-color: rgba(0,0,0,.1);
}
.ab-toggle.active { 
    background: var(--ab-btn-bg, #0ea5e9);
    color: var(--ab-btn-fg, #fff);
    border-color: transparent;
}
/* Stile di focus per tutti gli elementi interattivi del pannello */
.ab-toggle:focus, .ab-toggle:focus-within {
    outline: 2px solid var(--ab-btn-bg, #0ea5e9);
    outline-offset: 2px;
    border-color: var(--ab-btn-bg, #0ea5e9);
}
.ab-grid-full { grid-template-columns: 1fr; }
.ab-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* Slider */
.ab-row { 
    display:flex; 
    align-items:center; 
    gap: 8px; 
    margin-bottom: 16px;
}
.ab-row input[type="range"] { width: 100%; }
.ab-val { min-width: 42px; text-align:right; font-variant-numeric: tabular-nums; }

/* Select lingua */
.ab-lang-select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.1); background-color: rgba(0,0,0,.04); }
.ab-lang-select:focus {
    outline: 2px solid var(--ab-btn-bg, #0ea5e9);
    outline-offset: 1px;
    border-color: var(--ab-btn-bg, #0ea5e9);
}

/* Select zoom */
.ab-zoom-select { flex-grow: 1; padding: 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.1); background-color: rgba(0,0,0,.04); -webkit-appearance: none; appearance: none; }
.ab-zoom-select:focus {
    outline: 2px solid var(--ab-btn-bg, #0ea5e9);
    outline-offset: 1px;
    border-color: var(--ab-btn-bg, #0ea5e9);
}

/*
 * Posizionamento dinamico pannello
 * Queste regole devono stare DOPO la definizione di .ab-panel e .ab-panel.open
 * per garantire la corretta specificità e sovrascrittura delle proprietà.
*/
.ab-widget.bottom-right .ab-panel, .ab-widget.center-right .ab-panel { bottom: 0; right: 0; }
.ab-widget.bottom-left .ab-panel, .ab-widget.center-left .ab-panel  { bottom: 0; left: 0; }
.ab-widget.top-right .ab-panel { top: 0; right: 0; }
.ab-widget.top-left .ab-panel  { top: 0; left: 0; }

/* Margini per distanziare il pannello dal bottone */
.ab-widget.bottom-right .ab-panel, .ab-widget.bottom-left .ab-panel { margin-bottom: 58px; } /* 48px (btn) + 10px */
.ab-widget.top-right .ab-panel, .ab-widget.top-left .ab-panel { margin-top: 58px; }
.ab-widget.center-right .ab-panel { margin-right: 58px; }
.ab-widget.center-left .ab-panel { margin-left: 58px; }

/* CSS class added by JS to body/html when modal is open */
html.ab-modal-open, 
body.ab-modal-open { 
    overflow: hidden !important; 
    overscroll-behavior: none;
}


.ab-modal-overlay {
    position: fixed;
    overscroll-behavior: contain;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6); /* Usa un colore scuro semi-trasparente */
    backdrop-filter: blur(4px); /* Effetto sfocatura per browser moderni */
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000; /* Ancora più alto del widget */
    padding: 20px;
}

.ab-modal-content {
    overscroll-behavior: contain;
    background: var(--ab-panel-bg, #fff);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    padding: 24px;
    max-width: 960px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    line-height: 1.6;
}
.ab-modal-content :where(h1, h2, h3, h4, h5, h6, p, ul, ol, li) {
    color: var(--ab-panel-fg, #000);
}

/* Stile scrollbar per un look moderno e integrato */
.ab-modal-content::-webkit-scrollbar {
    width: 8px;
}
.ab-modal-content::-webkit-scrollbar-track {
    background: transparent;
    margin: 14px 0; /* Applica il padding verticale anche alla traccia */
}
.ab-modal-content::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,.2);
    border-radius: 4px;
    border: 2px solid transparent; /* Crea un effetto padding */
    background-clip: content-box;
}
.ab-modal-content {
    scrollbar-width: thin; /* Per Firefox */
    scrollbar-color: rgba(0,0,0,.2) transparent; /* Per Firefox */
}

.ab-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.ab-modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.ab-modal-close { font-size: 24px; line-height: 1; background: transparent; border: 0; cursor: pointer; opacity: 0.7; }
.ab-modal-close:hover { opacity: 1; }
.ab-modal-body p { margin-top: 0; margin-bottom: 0; }
.ab-modal-body h4 { margin-top: 1.5em; margin-bottom: 0.5em; }

/* Force blue links in accessibility statement */
#accessibility-statement a { color: #0000EE !important; text-decoration: underline !important; }