/**
 * Cookie Banner Styles - GDPR Compliant
 * Compatible con Bootstrap 5 e CSP (Content Security Policy)
 * NO inline styles - Tutti gli stili sono esterni
 * 
 * Versione: 1.0
 * Data: 2025-11-03
 */

/* ============================================
   COOKIE BANNER PRINCIPALE
   ============================================ */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    animation: slideUp 0.4s ease-out;
    border-top: 4px solid #0d6efd;
}

.cookie-banner.show {
    display: block;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cookie-banner-content {
    padding: 1.5rem 1rem;
}

/* Header del banner */
.cookie-banner-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: relative;
}

.cookie-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.cookie-banner-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #212529;
    flex-grow: 1;
}

.cookie-close {
    position: absolute;
    top: -0.5rem;
    right: 0;
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.cookie-close:hover,
.cookie-close:focus {
    opacity: 1;
    color: #212529;
}

/* Body del banner */
.cookie-banner-body {
    margin-bottom: 1.25rem;
}

.cookie-banner-body p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #495057;
}

.cookie-banner-body p:last-child {
    margin-bottom: 0;
}

.cookie-banner-small {
    font-size: 0.9rem;
    color: #6c757d;
}

.cookie-link {
    color: #0d6efd;
    text-decoration: underline;
    font-weight: 500;
}

.cookie-link:hover,
.cookie-link:focus {
    color: #0a58ca;
    text-decoration: none;
}

/* Pulsanti azione */
.cookie-banner-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cookie-banner-actions .btn {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-icon {
    margin-right: 0.375rem;
}

/* Pulsante Accetta - più prominente */
.cookie-btn-accept {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
}

.cookie-btn-accept:hover,
.cookie-btn-accept:focus {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Pulsante Rifiuta - stesso risalto di Accetta */
.cookie-btn-reject {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #ffffff;
}

.cookie-btn-reject:hover,
.cookie-btn-reject:focus {
    background-color: #5c636a;
    border-color: #565e64;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

/* Pulsante Personalizza */
.cookie-btn-customize {
    border-color: #0d6efd;
    color: #0d6efd;
}

.cookie-btn-customize:hover,
.cookie-btn-customize:focus {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
    transform: translateY(-1px);
}

/* ============================================
   MODAL PERSONALIZZAZIONE
   ============================================ */

.cookie-category {
    padding: 1rem 0;
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cookie-category-icon {
    font-size: 1.75rem;
    margin-right: 0.75rem;
    line-height: 1;
}

.cookie-category-title {
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.cookie-category-description {
    padding-left: 2.5rem;
    color: #6c757d;
}

/* Switch per categorie cookie */
.form-check-input {
    cursor: pointer;
    width: 3rem;
    height: 1.5rem;
}

.form-check-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* ============================================
   PULSANTE FLOATING IMPOSTAZIONI
   ============================================ */

.cookie-settings-floating {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #0d6efd;
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    z-index: 9998;
}

.cookie-settings-floating.show {
    display: flex;
}

.cookie-settings-floating:hover,
.cookie-settings-floating:focus {
    background-color: #0b5ed7;
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Mobile Small (< 576px) */
@media (max-width: 575.98px) {
    .cookie-banner-content {
        padding: 1.25rem 0.75rem;
    }

    .cookie-banner-title {
        font-size: 1.1rem;
    }

    .cookie-icon {
        font-size: 1.5rem;
    }

    .cookie-banner-actions {
        flex-direction: column;
    }

    .cookie-banner-actions .btn {
        width: 100%;
        min-width: auto;
    }

    .cookie-close {
        font-size: 1.5rem;
        right: -0.5rem;
    }

    .cookie-category-icon {
        font-size: 1.5rem;
    }

    .cookie-category-description {
        padding-left: 0;
        margin-top: 0.5rem;
    }

    .cookie-settings-floating {
        bottom: 15px;
        left: 15px;
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
}

/* Tablet (576px - 991px) */
@media (min-width: 576px) and (max-width: 991.98px) {
    .cookie-banner-actions .btn {
        flex: 1 1 calc(50% - 0.375rem);
    }

    .cookie-btn-customize {
        flex: 1 1 100%;
    }
}

/* Desktop Large (> 1200px) */
@media (min-width: 1200px) {
    .cookie-banner-content {
        padding: 2rem 1rem;
    }

    .cookie-banner-actions .btn {
        flex: 0 1 auto;
        min-width: 160px;
    }
}

/* ============================================
   ACCESSIBILITÀ
   ============================================ */

/* Focus visibile per tastiera */
.cookie-banner button:focus,
.cookie-banner a:focus,
.cookie-settings-floating:focus,
.form-check-input:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cookie-banner {
        border-top-width: 6px;
    }

    .cookie-banner-actions .btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cookie-banner {
        animation: none;
    }

    .cookie-banner-actions .btn,
    .cookie-settings-floating {
        transition: none;
    }

    .cookie-btn-accept:hover,
    .cookie-btn-reject:hover,
    .cookie-btn-customize:hover {
        transform: none;
    }

    .cookie-settings-floating:hover {
        transform: scale(1.05);
    }
}

/* Dark mode support (opzionale) */
@media (prefers-color-scheme: dark) {
    .cookie-banner {
        background: #1a1a1a;
        border-top-color: #0d6efd;
    }

    .cookie-banner-title {
        color: #f8f9fa;
    }

    .cookie-banner-body p {
        color: #dee2e6;
    }

    .cookie-banner-small {
        color: #adb5bd;
    }

    .cookie-close {
        color: #adb5bd;
    }

    .cookie-close:hover,
    .cookie-close:focus {
        color: #f8f9fa;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .cookie-banner,
    .cookie-settings-floating {
        display: none !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.cookie-banner .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Classe per nascondere elementi se JS è disabilitato */
.no-js .cookie-banner,
.no-js .cookie-settings-floating {
    display: none !important;
}
    /* Stili sezione test */
    .cookie-test-result {
        max-height: 300px;
        overflow: auto;
        font-family: 'Courier New', Courier, monospace;
        font-size: 0.9rem;
        line-height: 1.4;
        white-space: pre-wrap;
        word-wrap: break-word;
    }
    .cookie-test-result.no-consent {
        color: #856404;
        background-color: #fff3cd !important;
        border-color: #ffc107 !important;
    }
    .cookie-test-result.has-consent {
        color: #155724;
        background-color: #d4edda !important;
        border-color: #28a745 !important;
    }
    .cookie-test-result.error {
        color: #721c24;
        background-color: #f8d7da !important;
        border-color: #dc3545 !important;
    }