/**
 * Cookie Banner — GDPR Compliant
 * Voci di Sicurezza | EBRET Theme
 * Dark theme matching the site design system
 */

/* =============================================
   BANNER WRAPPER
   ============================================= */
.cookie-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 48px);
    max-width: 680px;
    z-index: 999999; /* Aumentato per stare sopra a tutto */
    border-radius: 16px;
    overflow: hidden;
    background: #111118;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 1px rgba(232, 54, 75, 0.1),
        0 24px 60px rgba(0, 0, 0, 0.6),
        0 8px 20px rgba(0, 0, 0, 0.4);
    
    display: block; /* Visibile di base, gestito da [hidden] */
    animation: cookieBannerIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Nascondi quando l'attributo hidden è presente */
.cookie-banner[hidden] {
    display: none !important;
}

/* Stato visibile forzato quando JS aggiunge is-visible */
.cookie-banner.is-visible {
    display: block !important;
}

@keyframes cookieBannerIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* =============================================
   INNER CONTENT
   ============================================= */
.cookie-banner__inner {
    padding: 24px 28px;
}

.cookie-banner__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.cookie-banner__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(232, 54, 75, 0.12);
    color: #e8364b;
    flex-shrink: 0;
}

.cookie-banner__title {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.cookie-banner__desc {
    font-size: 0.85rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.6);
    margin: 0 0 20px 0;
}

.cookie-banner__link {
    color: #e8364b;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s;
}
.cookie-banner__link:hover {
    opacity: 0.8;
}

/* =============================================
   ACTIONS
   ============================================= */
.cookie-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.cookie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    letter-spacing: 0.01em;
    font-family: inherit;
}

.cookie-btn--primary {
    background: #e8364b;
    color: #ffffff;
}
.cookie-btn--primary:hover {
    background: #c92d3e;
    transform: translateY(-1px);
}

.cookie-btn--secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.cookie-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.cookie-btn--ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    padding: 10px 12px;
}
.cookie-btn--ghost:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* =============================================
   PREFERENCES PANEL
   ============================================= */
.cookie-banner__preferences[hidden] {
    display: none !important;
}

.cookie-banner__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.cookie-banner__back:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* =============================================
   COOKIE CATEGORIES
   ============================================= */
.cookie-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.cookie-category {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 14px 16px;
    transition: border-color 0.2s;
}
.cookie-category:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.cookie-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.cookie-category__name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    display: block;
    margin-bottom: 4px;
}

.cookie-category__badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(232, 54, 75, 0.15);
    color: #e8364b;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.cookie-category__badge--optional {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
}

.cookie-category__desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    line-height: 1.6;
}

/* =============================================
   TOGGLE SWITCH
   ============================================= */
.cookie-toggle {
    position: relative;
    display: flex;
    align-items: center;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.cookie-toggle__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-toggle__knob {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    transition: background 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.cookie-toggle__knob::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.cookie-toggle__input:checked ~ .cookie-toggle__knob {
    background: rgba(232, 54, 75, 0.9);
    border-color: #e8364b;
}
.cookie-toggle__input:checked ~ .cookie-toggle__knob::after {
    transform: translateX(20px);
    background: #ffffff;
}

.cookie-toggle--disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.cookie-toggle--disabled .cookie-toggle__knob {
    background: rgba(232, 54, 75, 0.5);
    border-color: rgba(232, 54, 75, 0.4);
}
.cookie-toggle--disabled .cookie-toggle__knob::after {
    transform: translateX(20px);
    background: rgba(255,255,255,0.7);
}

/* =============================================
   REOPEN BUTTON
   ============================================= */
.cookie-reopen-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 99998;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 8px 10px;
    background: #111118;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.cookie-reopen-btn:hover {
    color: #ffffff;
    border-color: rgba(232, 54, 75, 0.4);
    box-shadow: 0 4px 20px rgba(232, 54, 75, 0.15);
}
.cookie-reopen-btn[hidden] {
    display: none !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
    .cookie-banner {
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
    }

    @keyframes cookieBannerIn {
        from {
            opacity: 0;
            transform: translateY(40px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .cookie-banner__inner {
        padding: 20px 20px;
    }

    .cookie-banner__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cookie-btn {
        text-align: center;
        justify-content: center;
    }

    .cookie-reopen-btn {
        bottom: 16px;
        left: 16px;
    }
}
