/* Preferenze cookie: finestra nello stile del sito Centro Didattico Omnia (Open Sans, testo #555/#666, blu #1171a3, angoli vivi).
   Le misure sono in px: Bootstrap 3 porta il rem a 10px. style.css azzera box-shadow su tutto, quindi l'ombra piena e' di fatto disattiva. */
.cookie-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(51, 51, 51, 0.72);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cookie-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cookie-modal-content {
    background-color: #ffffff;
    width: 100%;
    max-width: 640px;
    border: 1px solid #555;
    box-shadow: 10px 10px 0 #1171a3;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    outline: none;
    color: #666;
    font-family: 'Open Sans', sans-serif;
}

.cookie-modal-overlay.active .cookie-modal-content {
    transform: translateY(0);
}

.cookie-modal-header {
    padding: 28px 32px 22.4px;
    border-bottom: 2px solid #1171a3;
}

.cookie-modal-kicker {
    display: block;
    margin-bottom: 9.6px;
    font-family: 'Open Sans', sans-serif;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #777;
}

.cookie-modal-header h2 {
    margin: 0 0 9.6px 0;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.1;
    color: #555;
}

.cookie-modal-header h2 span {
    color: #1171a3;
}

.cookie-modal-header p {
    margin: 0;
    max-width: none;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
}

.cookie-modal-header a {
    color: #1171a3;
    font-weight: 600;
}

.cookie-modal-body {
    padding: 8px 32px;
    overflow-y: auto;
    flex: 1;
}

.cookie-service-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 17.6px 0;
    border-bottom: 1px solid #ddd;
}

.cookie-service-row:last-child {
    border-bottom: none;
}

.cookie-service-info {
    flex: 1;
    padding-right: 24px;
}

.cookie-service-info strong {
    display: block;
    color: #555;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.cookie-service-info p {
    margin: 0;
    max-width: none;
    font-size: 13px;
    color: #777;
    line-height: 1.45;
}

.cookie-service-toggle {
    display: flex;
    align-items: center;
    flex: none;
}

/* Interruttore */
.ios-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    margin: 0;
}

.ios-toggle input {
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: pointer;
}

.ios-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border: 1px solid #555;
    transition: 0.3s;
    border-radius: 0;
}

.ios-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    border: 1px solid #555;
    transition: 0.3s;
}

.ios-toggle input:checked + .ios-toggle-slider {
    background-color: #1171a3;
}

.ios-toggle input:focus-visible + .ios-toggle-slider {
    outline: 3px solid #1171a3;
    outline-offset: 3px;
}

.ios-toggle input:checked + .ios-toggle-slider:before {
    transform: translateX(24px);
}

.badge-always-active {
    padding: 5.6px 11.2px;
    border: 1px solid #555;
    background: #f7f7f7;
    color: #555;
    font-family: 'Open Sans', sans-serif;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cookie-modal-footer {
    padding: 20px 32px;
    background-color: #f7f7f7;
    border-top: 1px solid #555;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.cookie-btn-outline,
.cookie-btn-primary {
    padding: 13.6px 22.4px;
    border-radius: 0;
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.cookie-btn-outline {
    background: transparent;
    border: 1px solid #555;
    color: #555;
}

.cookie-btn-outline:hover {
    background: #333;
    color: #ffffff;
}

.cookie-btn-primary {
    background: #333;
    border: 1px solid #333;
    color: #ffffff;
}

.cookie-btn-primary:hover {
    background: #1171a3;
    border-color: #1171a3;
}

.cookie-btn-outline:focus-visible,
.cookie-btn-primary:focus-visible,
.cookie-modal-header a:focus-visible {
    outline: 3px solid #1171a3;
    outline-offset: 3px;
}

/* Telefono (o schermo molto basso, es. orizzontale): la finestra occupa tutto lo schermo visibile (l'overlay e' fixed, quindi
   segue la barra del browser, a differenza di 100vh) e scorre per intero: testata, servizi e pulsanti si raggiungono sempre.
   La barra dei pulsanti resta incollata in basso. */
@media (max-width: 560px), (max-height: 600px) {
    .cookie-modal-overlay { padding: 0; align-items: stretch; }
    .cookie-modal-content {
        display: block;
        max-width: none;
        height: 100%;
        max-height: none;
        border-width: 0;
        box-shadow: none !important;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        transform: none;
    }
    .cookie-modal-header { padding: 22.4px 20px 17.6px; }
    .cookie-modal-header h2 { font-size: 24px; }
    .cookie-modal-body { padding: 4px 20px; overflow: visible; }
    .cookie-service-info { padding-right: 16px; }
    .cookie-modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    }
    .cookie-modal-footer button { width: 100%; padding-inline: 8px; }
    .cookie-modal-footer .cookie-btn-primary { grid-column: 1 / -1; order: -1; }
}

@media (prefers-reduced-motion: reduce) {
    .cookie-modal-overlay, .cookie-modal-content, .ios-toggle-slider, .ios-toggle-slider:before { transition: none; }
}

/* Tema scuro (html[data-theme="dark"], impostato da includes/inc_head.php) */
html[data-theme="dark"] .cookie-modal-overlay { background-color: rgba(0, 0, 0, 0.72); }
html[data-theme="dark"] .cookie-modal-content { background-color: #1f1c1a; border-color: #ece7e1; color: #ece7e1; box-shadow: 10px 10px 0 #4a89c2; }
html[data-theme="dark"] .cookie-modal-header { border-bottom-color: #4a89c2; }
html[data-theme="dark"] .cookie-modal-kicker { color: #a8a29b; }
html[data-theme="dark"] .cookie-modal-header h2 { color: #ece7e1; }
html[data-theme="dark"] .cookie-modal-header h2 span,
html[data-theme="dark"] .cookie-modal-header a { color: #6fa8da; }
html[data-theme="dark"] .cookie-modal-header p { color: #c9c3bc; }
html[data-theme="dark"] .cookie-service-row { border-bottom-color: rgba(236, 231, 225, 0.2); }
html[data-theme="dark"] .cookie-service-info strong { color: #ece7e1; }
html[data-theme="dark"] .cookie-service-info p { color: #a8a29b; }
html[data-theme="dark"] .ios-toggle-slider { background-color: #4a443f; border-color: #ece7e1; }
html[data-theme="dark"] .ios-toggle-slider:before { background-color: #ece7e1; border-color: #ece7e1; }
html[data-theme="dark"] .ios-toggle input:checked + .ios-toggle-slider { background-color: #4a89c2; }
html[data-theme="dark"] .badge-always-active { border-color: #ece7e1; background: #151311; color: #ece7e1; }
html[data-theme="dark"] .cookie-modal-footer { background-color: #151311; border-top-color: #ece7e1; }
html[data-theme="dark"] .cookie-btn-outline { border-color: #ece7e1; color: #ece7e1; }
html[data-theme="dark"] .cookie-btn-outline:hover { background: #ece7e1; color: #151311; }
html[data-theme="dark"] .cookie-btn-primary { background: #ece7e1; border-color: #ece7e1; color: #151311; }
html[data-theme="dark"] .cookie-btn-primary:hover { background: #4a89c2; border-color: #4a89c2; color: #ffffff; }
html[data-theme="dark"] .cookie-btn-outline:focus-visible,
html[data-theme="dark"] .cookie-btn-primary:focus-visible,
html[data-theme="dark"] .cookie-modal-header a:focus-visible { outline-color: #6fa8da; }
