/* ── AS2 GDPR Cookie Banner — v1.2.0 ───────────────────────────────────── */
:root {
    --as2-cb-bg:           #ffffff;
    --as2-cb-text:         #212529;
    --as2-cb-border:       #dee2e6;
    --as2-cb-surface:      #f8f9fa;
    --as2-cb-accent:       #c41230;
    --as2-cb-accent-text:  #ffffff;
    --as2-cb-secondary:    #6c757d;
    --as2-cb-radius:       .5rem;
}

/* ── Stato iniziale: tutto nascosto via CSS (non con attributo hidden) ── */
#as2-cookie-banner,
#as2-cookie-overlay,
#as2-cookie-modal  { display: none; }

/* ── Stato visibile ──────────────────────────────────────────────────── */
#as2-cookie-banner.as2-open  { display: block; animation: as2-cb-slide-up .3s ease; }
#as2-cookie-overlay.as2-open { display: block; }
#as2-cookie-modal.as2-open   { display: flex; }

/* Banner */
#as2-cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    background: var(--as2-cb-bg);
    color: var(--as2-cb-text);
    border-top: 1px solid var(--as2-cb-border);
    box-shadow: 0 -4px 24px rgba(0,0,0,.12);
    padding: 1rem 1.25rem;
    font-size: 14px;
}
@keyframes as2-cb-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.as2-cb-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.as2-cb-text { flex: 1 1 320px; line-height: 1.5; }
.as2-cb-text p { margin: .2rem 0; }
.as2-cb-title { font-weight: 600; }
.as2-cb-body  { color: var(--as2-cb-secondary); }
.as2-cb-policy-link {
    color: var(--as2-cb-accent);
    text-decoration: underline;
    white-space: nowrap;
}
.as2-cb-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

/* Bottoni */
.as2-cb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .4rem .9rem;
    border-radius: var(--as2-cb-radius);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
    transition: filter .15s ease;
    white-space: nowrap;
    background: none;
}
.as2-cb-btn-reject {
    background: #495057;
    border-color: #495057;
    color: #ffffff;
}
.as2-cb-btn-reject:hover  { filter: brightness(1.15); color: #ffffff; }
.as2-cb-btn-customize {
    background: transparent;
    border-color: var(--as2-cb-secondary);
    color: var(--as2-cb-secondary);
}
.as2-cb-btn-customize:hover { filter: brightness(.85); }
.as2-cb-btn-accept {
    background: var(--as2-cb-accent);
    border-color: var(--as2-cb-accent);
    color: var(--as2-cb-accent-text);
    font-weight: 600;
}
.as2-cb-btn-accept:hover { filter: brightness(1.1); color: var(--as2-cb-accent-text); }

/* Overlay */
#as2-cookie-overlay {
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(2px);
}

/* Modale — layout flex colonna: header fisso + body scrollabile + footer fisso */
#as2-cookie-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100002;
    width: min(520px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    overflow: hidden;          /* solo il body interno scrolla */
    background: var(--as2-cb-bg);
    border: 1px solid var(--as2-cb-border);
    border-radius: .75rem;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    flex-direction: column;    /* display:flex viene da .as2-open */
    font-size: 14px;
}
.as2-cm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem .75rem;
    border-bottom: 1px solid var(--as2-cb-border);
    flex-shrink: 0;            /* non si restringe */
}
.as2-cm-title { font-weight: 700; font-size: 16px; margin: 0; }
.as2-cm-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem;
    color: var(--as2-cb-secondary);
    font-size: 20px;
    line-height: 1;
}
.as2-cm-close:hover { color: var(--as2-cb-text); }
.as2-cm-body {
    padding: 1rem 1.25rem;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;             /* necessario per overflow in flexbox */
}
.as2-cm-intro { color: var(--as2-cb-secondary); font-size: 13px; margin-bottom: 1rem; }

/* Categorie cookie */
.as2-cookie-cat {
    padding: .75rem 0;
    border-bottom: 1px solid var(--as2-cb-border);
}
.as2-cookie-cat:last-child { border-bottom: none; }
.as2-cookie-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .3rem;
}
.as2-cookie-cat-label { display: flex; align-items: center; gap: .5rem; }
.as2-cookie-cat-name  { font-weight: 600; }
.as2-cookie-always-on {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--as2-cb-secondary);
    background: var(--as2-cb-surface);
    border: 1px solid var(--as2-cb-border);
    border-radius: 2rem;
    padding: .1rem .55rem;
}
.as2-cookie-cat-desc { color: var(--as2-cb-secondary); font-size: 13px; margin: 0; }

/* Toggle switch */
.as2-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.as2-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.as2-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--as2-cb-border);
    border-radius: 22px;
    cursor: pointer;
    transition: background .2s;
}
.as2-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.as2-toggle input:checked + .as2-toggle-slider { background: var(--as2-cb-accent); }
.as2-toggle input:checked + .as2-toggle-slider::before { transform: translateX(18px); }
.as2-toggle input:disabled + .as2-toggle-slider { opacity: .55; cursor: not-allowed; }

/* Footer modale */
.as2-cm-footer {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    padding: .75rem 1.25rem 1rem;
    border-top: 1px solid var(--as2-cb-border);
    flex-shrink: 0;            /* non si restringe */
    flex-wrap: wrap;
    background: var(--as2-cb-bg);
}

/* Responsive */
@media (max-width: 600px) {
    .as2-cb-actions { width: 100%; justify-content: flex-end; }
    .as2-cm-footer  { justify-content: stretch; }
    .as2-cm-footer .as2-cb-btn { flex: 1; }
}
