/**
 * RGPD Cookie Consent — Plugins-WP.fr
 * Version: 1.3.1 — RGAA 4.1 — sans border-radius (convention Plugins-WP.fr)
 * © 2025 Plugins-WP.fr — une marque Cercle Carré
 */

/* ── Variables ───────────────────────────────────────────── */
.rgpd-cc-banner,
.rgpd-cc-modal-content {
    --rgpd-bg:     #ffffff;
    --rgpd-btn:    #1E3A5F;
    --rgpd-text:   #1f2937;
    --rgpd-border: #e5e7eb;
    --rgpd-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    /* RGAA 10.7 : couleur de focus uniforme */
    --rgpd-focus:  #005FCC;
}

/* ── Utilitaire AT ───────────────────────────────────────── */
/* RGAA 1.3 / 3.3 : texte réservé aux lecteurs d'écran */
.rgpd-sr-only,
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Reset ───────────────────────────────────────────────── */
.rgpd-cc-banner *,
.rgpd-cc-modal * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Bannière principale ─────────────────────────────────── */
.rgpd-cc-banner {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 999999;
    background-color: var(--rgpd-bg);
    color: var(--rgpd-text);   /* #1f2937 sur #fff = 14.7:1 ✓ RGAA 3.2 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* RGAA 10.7 : focus visible sur la bannière entière */
.rgpd-cc-banner:focus {
    outline: none;
}

.rgpd-cc-bottom {
    bottom: 0;
    box-shadow: var(--rgpd-shadow);
}

.rgpd-cc-top {
    top: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.rgpd-cc-center {
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.rgpd-cc-center .rgpd-cc-container {
    max-width: 600px;
    margin: 20px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    background-color: var(--rgpd-bg);
    position: relative;
    z-index: 2;
}

.rgpd-cc-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1;
}

.rgpd-cc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ── Contenu texte ───────────────────────────────────────── */
.rgpd-cc-content {
    margin-bottom: 16px;
}

.rgpd-cc-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--rgpd-text);   /* 14.7:1 ✓ */
}

/* RGAA 3.2 : on supprime opacity pour garantir le contraste */
.rgpd-cc-text {
    color: var(--rgpd-text);
    margin-bottom: 12px;
}

/* ── Liens ───────────────────────────────────────────────── */
/* RGAA 6.1 : intitulé explicite dans le HTML */
/* RGAA 10.6 : lien distinguable sans la couleur seule → underline */
.rgpd-cc-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.rgpd-cc-links a {
    color: var(--rgpd-btn);
    text-decoration: underline;
    font-size: 13px;
}

.rgpd-cc-links a:hover {
    text-decoration: none;
}

.rgpd-cc-links a:focus,
.rgpd-cc-links a:focus-visible {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 2px;
}

/* ── Boutons ─────────────────────────────────────────────── */
.rgpd-cc-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.rgpd-cc-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    /* Pas de border-radius — convention Plugins-WP.fr */
    transition: background-color 0.2s, opacity 0.2s;
}

/* RGAA 10.7 : focus visible 3px conforme sur tous les boutons */
.rgpd-cc-btn:focus,
.rgpd-cc-btn:focus-visible {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 3px;
}

/* RGAA 3.2 : #fff sur --rgpd-btn (#1E3A5F) = 10.3:1 ✓ */
.rgpd-cc-btn-accept,
.rgpd-cc-btn-save {
    background-color: var(--rgpd-btn);
    color: #fff;
}

.rgpd-cc-btn-accept:hover,
.rgpd-cc-btn-save:hover {
    opacity: 0.88;
}

/* RGAA 3.2 : #1f2937 sur #fff = 14.7:1 ✓ */
.rgpd-cc-btn-reject {
    background-color: transparent;
    color: var(--rgpd-text);
    border: 2px solid var(--rgpd-border);
}

.rgpd-cc-btn-reject:hover {
    background-color: #f3f4f6;
}

/* RGAA 3.2 : var(--rgpd-btn) sur #fff, avec bordure visible */
.rgpd-cc-btn-customize {
    background-color: transparent;
    color: var(--rgpd-btn);
    border: 2px solid var(--rgpd-btn);
}

.rgpd-cc-btn-customize:hover {
    background-color: rgba(30,58,95,0.06);
}

/* ── Panneau préférences ─────────────────────────────────── */
.rgpd-cc-preferences {
    padding: 16px 0;
    border-top: 1px solid var(--rgpd-border);
    margin-top: 16px;
}

.rgpd-cc-category {
    padding: 12px 0;
    border-bottom: 1px solid var(--rgpd-border);
}

.rgpd-cc-category:last-child {
    border-bottom: none;
}

.rgpd-cc-category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

/* RGAA 3.2 : #1f2937 sur #fff = 14.7:1 ✓ */
.rgpd-cc-category-name {
    font-weight: 600;
    color: var(--rgpd-text);
}

/* RGAA 3.2 : #374151 sur #fff = 10.7:1 ✓ */
.rgpd-cc-required {
    font-size: 12px;
    color: #374151;
}

/* RGAA 3.2 : #374151 sur #fff = 10.7:1 ✓ (remplace #6b7280 qui était 4.6:1) */
.rgpd-cc-category-desc {
    font-size: 13px;
    color: #374151;
    margin-left: 52px;
}

/* ── Toggle switch RGAA ──────────────────────────────────── */
/*
 * RGAA 7.1 : l'input natif (checkbox) reste accessible aux AT.
 * Il est visuellement masqué mais PAS opacity:0 + pointer-events:none
 * pour conserver le focus natif du navigateur.
 * Le slider est aria-hidden="true".
 *
 * RGAA 10.7 : focus visible via :focus-visible sur l'input,
 * transmis visuellement au slider parent via le sélecteur :has().
 */
.rgpd-cc-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

/* Input caché visuellement, mais focusable */
.rgpd-cc-switch input {
    position: absolute;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

/* Slider décoratif — aria-hidden dans le HTML */
.rgpd-cc-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #9ca3af;   /* gris — non coché */
    transition: background-color 0.25s;
    pointer-events: none;
}

.rgpd-cc-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* État coché */
.rgpd-cc-switch input:checked + .rgpd-cc-slider {
    background-color: var(--rgpd-btn);
}

.rgpd-cc-switch input:checked + .rgpd-cc-slider::before {
    transform: translateX(20px);
}

/* RGAA 10.7 : focus visible sur le switch */
.rgpd-cc-switch input:focus-visible + .rgpd-cc-slider {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 2px;
}

/* Fallback pour navigateurs sans :focus-visible */
.rgpd-cc-switch input:focus + .rgpd-cc-slider {
    box-shadow: 0 0 0 3px rgba(0,95,204,0.35);
}

/* Slider décoratif pour les cookies essentiels (toujours actif) */
.rgpd-cc-toggle-wrap {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.rgpd-cc-slider--on {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #9ca3af;
    opacity: 0.55;
    cursor: not-allowed;
}

.rgpd-cc-slider--on::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transform: translateX(20px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Bouton flottant ─────────────────────────────────────── */
/*
 * Règles défensives avec !important pour résister aux thèmes WordPress
 * qui écrasent les styles des boutons (border-radius, overflow, couleur SVG…)
 */
.rgpd-cc-manage-floating {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    background-color: var(--rgpd-btn, #1E3A5F) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 0 !important;       /* convention Plugins-WP.fr + neutralise les thèmes */
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;      /* évite que le thème clip le SVG */
    line-height: 1 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18) !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    z-index: 99998 !important;
    text-indent: 0 !important;
    letter-spacing: 0 !important;
}

.rgpd-cc-manage-floating:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.22) !important;
}

/* RGAA 10.7 : focus visible */
.rgpd-cc-manage-floating:focus,
.rgpd-cc-manage-floating:focus-visible {
    outline: 3px solid var(--rgpd-focus) !important;
    outline-offset: 3px !important;
}

/* SVG à l'intérieur du bouton flottant — défensif contre display:none des thèmes */
.rgpd-cc-manage-floating svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    stroke: currentColor !important;   /* hérite color:#fff du bouton */
    fill: none !important;
    overflow: visible !important;
    pointer-events: none !important;
}

/* Bouton shortcode */
.rgpd-cc-manage-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background-color: #f3f4f6;
    color: #374151;
    border: 2px solid #d1d5db;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.2s;
}

.rgpd-cc-manage-btn:hover {
    background-color: #e5e7eb;
}

.rgpd-cc-manage-btn:focus,
.rgpd-cc-manage-btn:focus-visible {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 3px;
}

/* ── Modal ───────────────────────────────────────────────── */
.rgpd-cc-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rgpd-cc-modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
}

.rgpd-cc-modal-content {
    position: relative;
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--rgpd-bg);
    color: var(--rgpd-text);
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.rgpd-cc-modal-content .rgpd-cc-title {
    padding-right: 36px;
    margin-bottom: 16px;
}

/* RGAA 7.3 : bouton fermer visible et accessible */
.rgpd-cc-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: 2px solid transparent;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.rgpd-cc-modal-close:hover {
    color: var(--rgpd-text);
}

.rgpd-cc-modal-close:focus,
.rgpd-cc-modal-close:focus-visible {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 2px;
    color: var(--rgpd-text);
}

/* ── Liens modal ─────────────────────────────────────────── */
.rgpd-cc-modal-links {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    padding-top: 16px;
    border-top: 1px solid var(--rgpd-border);
    flex-wrap: wrap;
}

.rgpd-cc-modal-links a {
    color: var(--rgpd-btn);
    text-decoration: underline;
    font-size: 13px;
}

.rgpd-cc-modal-links a:hover {
    text-decoration: none;
}

.rgpd-cc-modal-links a:focus,
.rgpd-cc-modal-links a:focus-visible {
    outline: 3px solid var(--rgpd-focus);
    outline-offset: 2px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .rgpd-cc-container {
        padding: 16px;
    }

    .rgpd-cc-buttons {
        flex-direction: column;
    }

    .rgpd-cc-btn {
        width: 100%;
        text-align: center;
    }

    .rgpd-cc-category-desc {
        margin-left: 0;
        margin-top: 8px;
    }

    .rgpd-cc-manage-floating {
        bottom: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
    }
}

/* ── RGAA : réduire les animations si demandé ────────────── */
@media (prefers-reduced-motion: reduce) {
    .rgpd-cc-bottom,
    .rgpd-cc-top,
    .rgpd-cc-center .rgpd-cc-container,
    .rgpd-cc-modal-content {
        animation: none !important;
    }

    .rgpd-cc-slider,
    .rgpd-cc-slider::before,
    .rgpd-cc-manage-floating,
    .rgpd-cc-btn {
        transition: none !important;
    }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes rgpd-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@keyframes rgpd-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

@keyframes rgpd-fade-in {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1);    }
}

@keyframes rgpd-fade-out {
    from { opacity: 1; transform: translateY(0);   }
    to   { opacity: 0; transform: translateY(16px); }
}

.rgpd-cc-bottom { animation: rgpd-slide-up   0.3s ease-out; }
.rgpd-cc-top    { animation: rgpd-slide-down  0.3s ease-out; }

.rgpd-cc-center .rgpd-cc-container,
.rgpd-cc-modal-content {
    animation: rgpd-fade-in 0.25s ease-out;
}

[hidden] { display: none !important; }
