/**
 * GDPR Cookie Manager - Frontend Styles
 * Stili per il banner cookie e tutti gli elementi frontend
 */

/* VARIABILI CSS - Sovrascritte da PHP inline */
:root {
    --gdpr-primary-color: #044074;
    --gdpr-secondary-color: #6c757d;
    --gdpr-text-color: #495057;
    --gdpr-background-color: #ffffff;
    --gdpr-border-color: #dee2e6;
    --gdpr-light-bg: #f8f9fa;
    --gdpr-muted-color: #6c757d;
    --gdpr-primary-hover: #032d52;
    --gdpr-primary-darker: #021d34;
    --gdpr-secondary-hover: #5a6268;
    --gdpr-switch-bg: #ccc;
    --gdpr-success-color: #28a745;
    --gdpr-shadow: 0 4px 12px rgba(4, 64, 116, 0.15);
    --gdpr-border-radius: 8px;
    --gdpr-font-family: 'Archivo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --gdpr-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET E BASE */
.gdpr-cookie-banner,
.gdpr-cookie-banner * {
    box-sizing: border-box;
    font-family: var(--gdpr-font-family);
}

/* UTILITÀ */
.gdpr-sr-only,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

.gdpr-hidden {
    display: none !important;
}

/* OVERLAY SFONDO */
.gdpr-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 64, 116, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--gdpr-transition);
}

.gdpr-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* BANNER PRINCIPALE */
.gdpr-cookie-banner {
    position: fixed;
    top: 0;
    width: 500px;
    height: 100vh;
    background: var(--gdpr-background-color);
    box-shadow: var(--gdpr-shadow);
    transition: var(--gdpr-transition);
    z-index: 10000;
    overflow-y: auto;
    border-left: 3px solid var(--gdpr-primary-color);
    font-size: 14px;
    line-height: 1.5;
}

/* Posizionamento banner */
.gdpr-cookie-banner.position-right {
    right: -550px;
}

.gdpr-cookie-banner.position-right.open {
    right: 0;
}

.gdpr-cookie-banner.position-left {
    left: -550px;
}

.gdpr-cookie-banner.position-left.open {
    left: 0;
}

.gdpr-cookie-banner.position-bottom {
    top: auto;
    bottom: -100%;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 90vh;
    border-left: none;
    border-top: 3px solid var(--gdpr-primary-color);
}

.gdpr-cookie-banner.position-bottom.open {
    bottom: 0;
}

/* CONTENUTO BANNER */
.gdpr-banner-content {
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.gdpr-banner-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gdpr-border-color);
}

.gdpr-banner-title {
    font-size: 1.4rem;
    color: var(--gdpr-primary-color);
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

.gdpr-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--gdpr-muted-color);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--gdpr-border-radius);
    transition: var(--gdpr-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.gdpr-close-btn:hover,
.gdpr-close-btn:focus {
    background: var(--gdpr-light-bg);
    color: var(--gdpr-primary-color);
    outline: 2px solid var(--gdpr-primary-color);
}

/* DESCRIZIONE */
.gdpr-banner-description {
    font-size: 0.95rem;
    margin-bottom: 20px;
    line-height: 1.5;
    color: var(--gdpr-text-color);
}

/* TOGGLE DETTAGLI */
.gdpr-toggle-details {
    background: none;
    border: 1px solid var(--gdpr-border-color);
    padding: 12px 16px;
    border-radius: var(--gdpr-border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--gdpr-transition);
    width: 100%;
    text-align: left;
    color: var(--gdpr-primary-color);
}

.gdpr-toggle-details:hover,
.gdpr-toggle-details:focus {
    background: var(--gdpr-light-bg);
    border-color: var(--gdpr-primary-color);
    outline: none;
}

.gdpr-toggle-details[aria-expanded="true"] .gdpr-chevron {
    transform: rotate(180deg);
}

.gdpr-chevron {
    transition: transform 0.2s ease;
    color: var(--gdpr-primary-color);
}

/* DETTAGLI COOKIE */
.gdpr-cookie-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    margin-bottom: 20px;
}

.gdpr-cookie-details.expanded {
    max-height: 2000px;
    overflow-y: auto;
}

/* CATEGORIE COOKIE */
.gdpr-cookie-category {
    background: var(--gdpr-light-bg);

    border-radius: var(--gdpr-border-radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--gdpr-border-color);
}

.gdpr-category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.gdpr-category-info {
    flex: 1;
    margin-right: 16px;
}

.gdpr-category-title {
    font-size: 1rem;
    margin: 0 0 8px 0;
    color: var(--gdpr-primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.gdpr-category-title .gdpr-icon {
    font-size: 1.1rem;
}

.gdpr-category-description {
    font-size: 0.85rem;
    margin: 0;
    color: var(--gdpr-text-color);
    line-height: 1.4;
}

.gdpr-cookie-list {
    font-size: 0.8rem;
    color: var(--gdpr-muted-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

/* TOGGLE SWITCH */
.gdpr-toggle-switch {
    display: flex;
    align-items: center;
}

.gdpr-toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    visibility: hidden;
}

.gdpr-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    cursor: pointer;
}

.gdpr-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gdpr-switch-bg);
    border-radius: 24px;
    transition: var(--gdpr-transition);
}

.gdpr-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: var(--gdpr-transition);
}

input:checked + .gdpr-switch .gdpr-slider {
    background-color: var(--gdpr-primary-color);
}

input:disabled + .gdpr-switch .gdpr-slider {
    background-color: var(--gdpr-success-color);
    cursor: not-allowed;
}

input:checked + .gdpr-switch .gdpr-slider:before {
    transform: translateX(24px);
}

input:focus + .gdpr-switch .gdpr-slider {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--gdpr-primary-color);
}

/* LINK */
.gdpr-cookie-links {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.gdpr-cookie-links a {
    color: var(--gdpr-primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--gdpr-transition);
}

.gdpr-cookie-links a:hover,
.gdpr-cookie-links a:focus {
    color: var(--gdpr-primary-hover);
    text-decoration: underline;
}

/* PULSANTI */
.gdpr-banner-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--gdpr-border-color);
}

.gdpr-btn {
    padding: 12px 20px;
    border-radius: var(--gdpr-border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--gdpr-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    text-decoration: none;
    min-height: 44px; /* Accessibilità touch */
}

.gdpr-btn-primary {
    background: var(--gdpr-primary-color);
    color: white;
}

.gdpr-btn-primary:hover,
.gdpr-btn-primary:focus {
    background: var(--gdpr-primary-hover);
    outline: 2px solid var(--gdpr-primary-darker);
    transform: translateY(-1px);
}

.gdpr-btn-secondary {
    background: var(--gdpr-secondary-color);
    color: white;
}

.gdpr-btn-secondary:hover,
.gdpr-btn-secondary:focus {
    background: var(--gdpr-secondary-hover);
    outline: 2px solid var(--gdpr-text-color);
    transform: translateY(-1px);
}

.gdpr-btn-outline {
    background: transparent;
    color: var(--gdpr-primary-color);
    border: 1px solid var(--gdpr-primary-color);
}

.gdpr-btn-outline:hover,
.gdpr-btn-outline:focus {
    background: var(--gdpr-primary-color);
    color: white;
    outline: 2px solid var(--gdpr-primary-hover);
    transform: translateY(-1px);
}

/* FOOTER AZIENDA */
.gdpr-banner-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gdpr-border-color);
}

.gdpr-company-info {
    font-size: 0.8rem;
    color: var(--gdpr-muted-color);
    line-height: 1.4;
}

.gdpr-company-info p {
    margin: 4px 0;
}

.gdpr-company-info strong {
    color: var(--gdpr-primary-color);
}

.gdpr-company-info a {
    color: var(--gdpr-primary-color);
    text-decoration: none;
}

.gdpr-company-info a:hover {
    text-decoration: underline;
}

/* TOGGLE BUTTON RIAPRI */
.gdpr-settings-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gdpr-primary-color);
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    z-index: 10000;
    font-size: 1rem;
    box-shadow: var(--gdpr-shadow);
    transition: var(--gdpr-transition);
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.gdpr-settings-toggle:hover,
.gdpr-settings-toggle:focus {
    background: var(--gdpr-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(4, 64, 116, 0.4);
    outline: 2px solid var(--gdpr-primary-darker);
}

.gdpr-settings-toggle.hidden {
    display: none;
}

/* Nuovo bottone trigger */
#cookie-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--gdpr-primary-color);
    color: #fff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 10000;
    box-shadow: var(--gdpr-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--gdpr-transition);
}

#cookie-toggle:hover,
#cookie-toggle:focus {
    background: #032d52;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(4, 64, 116, 0.4);
    outline: 2px solid #021d34;
}

/* CONTENUTI BLOCCATI */
.gdpr-blocked-content {
    background: var(--gdpr-light-bg);
    border: 2px dashed var(--gdpr-border-color);
    border-radius: var(--gdpr-border-radius);
    padding: 20px;
    text-align: center;
    margin: 20px 0;
    color: var(--gdpr-text-color);
}

.gdpr-blocked-iframe {
    background: var(--gdpr-light-bg);
    border: 2px dashed var(--gdpr-border-color);
    border-radius: var(--gdpr-border-radius);
    padding: 20px;
    text-align: center;
    margin: 20px 0;
}

.gdpr-iframe-placeholder h4 {
    margin: 0 0 10px 0;
    color: var(--gdpr-text-color);
    font-size: 1.2rem;
}

.gdpr-iframe-placeholder p {
    margin: 0 0 15px 0;
    color: var(--gdpr-muted-color);
}

.gdpr-enable-iframe {
    background: var(--gdpr-primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--gdpr-border-radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--gdpr-transition);
}

.gdpr-enable-iframe:hover,
.gdpr-enable-iframe:focus {
    background: var(--gdpr-primary-hover);
    transform: translateY(-1px);
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .gdpr-cookie-banner {
        width: 100%;
        right: -100% !important;
        left: auto !important;
        padding: 0;
    }
    
    .gdpr-cookie-banner.position-left {
        left: -100% !important;
        right: auto !important;
    }
    
    .gdpr-cookie-banner.position-left.open {
        left: 0 !important;
    }
    
    .gdpr-cookie-banner.position-right.open {
        right: 0 !important;
    }
    
    .gdpr-banner-content {
        padding: 20px;
    }
    
    .gdpr-banner-buttons {
        position: sticky;
        bottom: 0;
        background: var(--gdpr-background-color);
        margin: 0 -20px;
        padding: 16px 20px;
        border-top: 2px solid var(--gdpr-border-color);
    }
    
    .gdpr-banner-footer {
        position: sticky;
        bottom: 0;
        background: var(--gdpr-background-color);
        margin: 0 -20px;
        padding: 16px 20px;
        border-top: 2px solid var(--gdpr-border-color);
    }
    
    .gdpr-category-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .gdpr-toggle-switch {
        align-self: flex-end;
    }
    
    .gdpr-cookie-banner.position-bottom {
        max-height: 95vh;
    }
    
    .gdpr-settings-toggle {
        bottom: 10px;
        right: 10px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .gdpr-banner-content {
        padding: 16px;
    }
    
    .gdpr-banner-title {
        font-size: 1.2rem;
    }
    
    .gdpr-banner-description {
        font-size: 0.9rem;
    }
    
    .gdpr-btn {
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    
    .gdpr-cookie-links {
        flex-direction: column;
        gap: 8px;
    }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
    .gdpr-cookie-banner {
        border: 2px solid #000;
    }
    
    .gdpr-btn {
        border: 2px solid currentColor;
    }
    
    .gdpr-category-description,
    .gdpr-cookie-list {
        color: #000;
    }
    
    .gdpr-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* FOCUS VISIBLE */
.gdpr-cookie-banner :focus-visible,
.gdpr-btn:focus-visible,
.gdpr-cookie-links a:focus-visible,
.gdpr-toggle-details:focus-visible,
.gdpr-close-btn:focus-visible,
.gdpr-settings-toggle:focus-visible {
    outline: 2px solid var(--gdpr-primary-color);
    outline-offset: 2px;
}


/* ANIMAZIONI */
@keyframes gdpr-slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes gdpr-slide-in-left {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes gdpr-slide-in-bottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gdpr-cookie-banner.open {
    animation-duration: 0.4s;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.gdpr-cookie-banner.position-right.open {
    animation-name: gdpr-slide-in-right;
}

.gdpr-cookie-banner.position-left.open {
    animation-name: gdpr-slide-in-left;
}

.gdpr-cookie-banner.position-bottom.open {
    animation-name: gdpr-slide-in-bottom;
}

/* LOADING STATE */
.gdpr-banner-loading {
    opacity: 0.7;
    pointer-events: none;
}

.gdpr-banner-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--gdpr-primary-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: gdpr-spin 1s linear infinite;
}

@keyframes gdpr-spin {
    to {
        transform: rotate(360deg);
    }
}

/* PRINT STYLES */
@media print {
    .gdpr-cookie-banner,
    .gdpr-overlay,
    .gdpr-settings-toggle,
    .gdpr-blocked-content,
    .gdpr-blocked-iframe {
        display: none !important;
    }
}