/***************************************
 * COOKIE MANAGER STYLES
 * Calqué sur le module d'accessibilité (access.css) :
 * mêmes variables de thème, mêmes patterns dark/high-contrast.
 ***************************************/

/* ==== Bouton flottant ==== */
/* Empilé AU-DESSUS du bouton accessibilité qui occupe bottom:0 left:0 (60x60) */
.cookie-manager-button {
    position: fixed;
    bottom: 60px;
    left: 0;
    width: 60px;
    height: 60px;
    border: none;
    background: #000;
    color: #fff;
    cursor: pointer;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--shadow-color, rgba(0, 0, 0, 0.1));
    transition:
        transform 0.3s linear,
        background 0.3s linear;
    border-top: 3px solid rgb(0, 0, 0);
    border-right: 3px solid rgb(0, 0, 0);
    user-select: none;
}

[data-theme="dark"] .cookie-manager-button {
    border-top: 3px solid #22c55e;
    border-right: 3px solid #22c55e;
}

.cookie-manager-button:hover {
    background: var(--secondary-color, #16a34a);
}

.cookie-manager-button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -6px;
}

/* Suit la translation du bouton accessibilité quand son panneau est ouvert */
body:has(.accessibility-modal.active) .cookie-manager-button {
    transform: translateX(300px);
}

/* Pastille "consentement attendu" (uniquement quand une catégorie soumise à
   consentement est active et qu'aucun choix n'a encore été enregistré) */
.cm-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #ff715b;
    border: 2px solid #fff;
    border-radius: 50%;
    display: none;
}

.cm-indicator.active {
    display: block;
}

/* ==== Panneau latéral ==== */
.cookie-manager-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Au-dessus de la popup promotionnelle (9999) */
    z-index: 10000;
    pointer-events: none;
    /* Fermé : hors de l'ordre de tabulation (même pattern que le widget accessibilité) */
    visibility: hidden;
    transition: visibility 0s linear 0.4s;
}

.cookie-manager-modal.active {
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
}

.cm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.3s linear;
    pointer-events: none;
}

.cookie-manager-modal.active .cm-overlay {
    opacity: 1;
    pointer-events: auto;
}

.cm-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 360px;
    max-width: 92vw;
    background: #f7f7f7;
    border-right: 2px solid var(--primary-color, #22c55e);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s linear;
    z-index: 10001;
    color: var(--text-color, #1f2937);
}

[data-theme="dark"] .cm-panel {
    background: #1f2937;
}

.cookie-manager-modal.active .cm-panel {
    transform: translateX(0);
}

.cm-header {
    position: relative;
    padding-right: 2rem;
    margin-bottom: 0.75rem;
}

#cm-title {
    font-size: 20px;
    color: var(--text-color, #1f2937);
}

.cm-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color, #1f2937);
    line-height: 1;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.cm-close:hover {
    transform: scale(1.15);
}

.cm-intro {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--text-color, #1f2937);
}

/* ==== Catégories ==== */
.cm-category {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: 0.75rem 0;
}

.cm-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.cm-category-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color, #1f2937);
}

.cm-locked {
    font-size: 0.8rem;
    font-weight: 600;
    color: #15803d;
    white-space: nowrap;
}

[data-theme="dark"] .cm-locked {
    color: #4ade80;
}

.cm-category-desc {
    font-size: 0.85rem;
    margin: 0.25rem 0 0;
    color: var(--text-color, #1f2937);
}

/* ==== Switch (button role="switch") ==== */
.cm-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    /* Cible tactile confortable */
    min-height: 44px;
}

.cm-switch-track {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    border-radius: 24px;
    /* Gris foncé : contraste >= 3:1 avec le fond (WCAG 1.4.11) */
    background: #6b7280;
    transition: background 0.2s linear;
    flex-shrink: 0;
}

.cm-switch[aria-checked="true"] .cm-switch-track {
    background: #15803d;
}

.cm-switch-thumb {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s linear;
}

.cm-switch[aria-checked="true"] .cm-switch-thumb {
    transform: translateX(26px);
}

/* L'état n'est pas porté que par la couleur : libellé On/Off à côté du switch */
.cm-switch-state {
    font-size: 0.85rem;
    min-width: 2.2em;
    text-align: left;
}

.cm-switch:focus-visible {
    outline: 3px solid #1766a3;
    outline-offset: 2px;
}

/* ==== Liste détaillée des cookies/stockages ==== */
.cm-details {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.cm-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color, #1f2937);
}

.cm-details table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.cm-details th,
.cm-details td {
    text-align: left;
    padding: 3px 4px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-color, #1f2937);
    font-weight: normal;
}

.cm-details th {
    font-weight: 600;
}

.cm-empty {
    font-style: italic;
}

/* ==== Boutons d'action ==== */
/* Même poids visuel pour Accept / Reject / Save (exigence CNIL :
   refuser doit être aussi simple qu'accepter) */
.cm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.cm-btn {
    padding: 0.55rem 1.1rem;
    border-radius: 20px;
    cursor: pointer;
    border: 2px solid #063e63;
    background: #fff;
    color: #063e63;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
}

.cm-btn:hover {
    background: #063e63;
    color: #fff;
}

.cm-btn:focus-visible {
    outline: 3px solid #1766a3;
    outline-offset: 2px;
}

[data-theme="dark"] .cm-btn {
    background: transparent;
    border-color: #7fb7d9;
    color: #f9fafb;
}

[data-theme="dark"] .cm-btn:hover {
    background: #7fb7d9;
    color: #111827;
}

.cm-privacy-link {
    margin-top: 1rem;
    font-size: 0.85rem;
}

.cm-privacy-link a {
    color: #1766a3;
    text-decoration: underline;
}

[data-theme="dark"] .cm-privacy-link a {
    color: #7fb7d9;
}

/* ==== Bannière de consentement ==== */
/* N'apparaît que si au moins une catégorie soumise à consentement est active
   dans la configuration ET qu'aucun choix valide n'est enregistré. */
.cm-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9500;
    background: #fff;
    border-top: 2px solid var(--primary-color, #22c55e);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    padding: 1rem 1.5rem;
    display: none;
    color: var(--text-color, #1f2937);
}

.cm-banner.active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

[data-theme="dark"] .cm-banner {
    background: #1f2937;
}

.cm-banner p {
    margin: 0;
    flex: 1 1 300px;
    font-size: 0.9rem;
}

.cm-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ==== Façades click-to-load pour futurs contenus embarqués ==== */
.cm-facade {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--light-bg, #f9fafb);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 2rem 1rem;
    text-align: center;
    min-height: 200px;
}

.cm-facade p {
    font-size: 0.9rem;
    margin: 0;
}

/* ==== Contraste élevé ==== */
[data-contrast="high"] .cm-panel,
[data-contrast="high"] .cm-banner {
    background: #fff;
    border-color: #000;
}

[data-contrast="high"] .cm-btn {
    border-color: #000;
    color: #000;
}

[data-contrast="high"] .cm-btn:hover {
    background: #000;
    color: #fff;
}

[data-contrast="high"] .cm-switch-track {
    background: #000;
}

/* Mobile : les deux boutons flottants restent empilés à gauche ;
   panneau pleine hauteur déjà géré par max-width:92vw */
@media (max-width: 480px) {
    .cm-banner {
        padding: 0.75rem 1rem;
    }

    .cm-actions,
    .cm-banner-actions {
        width: 100%;
    }

    .cm-btn {
        flex: 1 1 auto;
    }
}
