/* ============================================================
   MADEA HOUSE — Système de Consentement
   Modale CGV + Bannière cookies RGPD
   Utilise les variables CSS du design system
   ============================================================ */

/* ── Variables locales (cohérentes avec style.css) ──────── */
:root {
    --cn-accent:       #8B7355;
    --cn-primary:      #F4E4C1;
    --cn-dark:         #2c2416;
    --cn-gray:         #6b7280;
    --cn-light:        #FAF8F3;
    --cn-border:       #e8e3da;
    --cn-shadow:       0 8px 40px rgba(44, 36, 22, 0.18), 0 2px 8px rgba(44, 36, 22, 0.08);
    --cn-radius:       16px;
    --cn-ease:         cubic-bezier(0.4, 0, 0.2, 1);
    --cn-spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Prévenir le scroll quand un dialogue est ouvert ────── */
body.consent-modal-open,
body.cookie-panel-open {
    overflow: hidden;
}


/* ============================================================
   1. MODALE CGV / CGU
   ============================================================ */

.cgv-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s var(--cn-ease), visibility 0.28s var(--cn-ease);
}

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

/* Backdrop */
.cgv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(44, 36, 22, 0.62);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Dialogue */
.cgv-dialog {
    position: relative;
    background: #fff;
    border-radius: var(--cn-radius);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--cn-shadow);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.38s var(--cn-spring);
    overflow: hidden;
}

.cgv-modal.active .cgv-dialog {
    transform: translateY(0) scale(1);
}

/* Animation shake (refus impossible) */
@keyframes cgvShake {
    0%, 100% { transform: translateX(0) scale(1); }
    20%       { transform: translateX(-7px) scale(1); }
    40%       { transform: translateX(7px) scale(1); }
    60%       { transform: translateX(-4px) scale(1); }
    80%       { transform: translateX(4px) scale(1); }
}

.cgv-dialog.cgv-shake {
    animation: cgvShake 0.4s ease;
}

/* En-tête */
.cgv-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 28px 28px 20px;
    border-bottom: 1px solid var(--cn-border);
}

.cgv-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--cn-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cn-accent);
    flex-shrink: 0;
}

.cgv-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--cn-dark);
    margin: 0 0 4px;
    line-height: 1.25;
}

.cgv-subtitle {
    font-size: 13.5px;
    color: var(--cn-gray);
    margin: 0;
    line-height: 1.45;
}

/* Corps */
.cgv-body {
    padding: 24px 28px;
}

.cgv-intro {
    font-size: 14px;
    color: var(--cn-gray);
    line-height: 1.7;
    margin: 0 0 20px;
}

.cgv-intro strong {
    color: var(--cn-dark);
    font-weight: 600;
}

/* Liens documents légaux */
.cgv-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.cgv-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--cn-light);
    color: var(--cn-accent);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s var(--cn-ease), transform 0.2s var(--cn-ease), color 0.2s var(--cn-ease);
}

.cgv-link:hover,
.cgv-link:focus-visible {
    background: var(--cn-primary);
    color: var(--cn-dark);
    transform: translateX(4px);
    outline: none;
}

.cgv-link-external {
    margin-left: auto;
    opacity: 0.45;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.cgv-link:hover .cgv-link-external {
    opacity: 0.7;
}

/* Checkbox d'acceptation */
.cgv-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--cn-border);
    transition: border-color 0.22s var(--cn-ease), background 0.22s var(--cn-ease);
}

.cgv-checkbox-label:hover {
    border-color: var(--cn-accent);
    background: var(--cn-light);
}

/* Masquer la checkbox native */
.cgv-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Checkbox custom */
.cgv-checkbox-custom {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--cn-border);
    background: #fff;
    position: relative;
    margin-top: 1px;
    transition: background 0.2s, border-color 0.2s;
}

.cgv-checkbox:checked + .cgv-checkbox-custom {
    background: var(--cn-accent);
    border-color: var(--cn-accent);
}

.cgv-checkbox:checked + .cgv-checkbox-custom::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    width: 6px;
    height: 11px;
    border: 2.5px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.cgv-checkbox:focus-visible + .cgv-checkbox-custom {
    outline: 3px solid rgba(139, 115, 85, 0.35);
    outline-offset: 2px;
}

.cgv-checkbox-text {
    font-size: 14px;
    color: var(--cn-dark);
    line-height: 1.55;
}

.cgv-checkbox-text a {
    color: var(--cn-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cgv-checkbox-text a:hover {
    color: var(--cn-dark);
}

/* Pied de dialogue */
.cgv-footer {
    padding: 18px 28px 24px;
    display: flex;
    justify-content: flex-end;
    background: var(--cn-light);
    border-top: 1px solid var(--cn-border);
}

/* Bouton Continuer */
.cgv-btn-confirm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 32px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    min-width: 160px;
    min-height: 48px;
    background: var(--cn-accent);
    color: #fff;
    transition: background 0.22s var(--cn-ease), transform 0.18s var(--cn-ease), box-shadow 0.22s var(--cn-ease), opacity 0.2s;
}

.cgv-btn-confirm:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.cgv-btn-confirm:not(:disabled):hover {
    background: var(--cn-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(44, 36, 22, 0.22);
}

.cgv-btn-confirm:not(:disabled):active {
    transform: translateY(0);
}

.cgv-btn-confirm:focus-visible {
    outline: 3px solid rgba(139, 115, 85, 0.45);
    outline-offset: 3px;
}


/* ============================================================
   2. BANNIÈRE DE CONSENTEMENT COOKIES
   ============================================================ */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 8500;
    transform: translateY(110%);
    transition: transform 0.45s var(--cn-ease);
    /* Safe area iOS */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.cookie-banner.visible {
    transform: translateY(0);
}

.cookie-banner-inner {
    background: rgba(26, 20, 12, 0.96);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(244, 228, 193, 0.13);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 28px;
    flex-wrap: wrap;
}

.cookie-banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 200px;
}

.cookie-banner-icon {
    font-size: 26px;
    line-height: 1;
    flex-shrink: 0;
}

.cookie-banner-text {
    flex: 1;
}

.cookie-banner-text strong {
    display: block;
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    margin-bottom: 3px;
}

.cookie-banner-text p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    margin: 0;
    line-height: 1.5;
}

.cookie-banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Boutons bannière */
.cookie-btn {
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    min-height: 40px;
    border: none;
    transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.cookie-btn:focus-visible {
    outline: 2px solid rgba(244, 228, 193, 0.6);
    outline-offset: 2px;
}

.cookie-btn-customize {
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 9px 10px;
}

.cookie-btn-customize:hover {
    color: #fff;
    text-decoration: none;
}

.cookie-btn-reject {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.cookie-btn-reject:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.cookie-btn-accept {
    background: var(--cn-primary);
    color: var(--cn-dark);
    font-weight: 700;
}

.cookie-btn-accept:hover {
    background: #e8d4a8;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(244, 228, 193, 0.35);
}

.cookie-btn-accept:active {
    transform: translateY(0);
}


/* ============================================================
   3. PANNEAU DE PERSONNALISATION
   ============================================================ */

/* Overlay */
.cookie-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 22, 0.52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 8700;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s var(--cn-ease), visibility 0.28s var(--cn-ease);
}

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

/* Panneau — Desktop : modal centré */
.cookie-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -44%);
    width: min(560px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 48px));
    background: #fff;
    border-radius: var(--cn-radius);
    box-shadow: var(--cn-shadow);
    z-index: 8800;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.28s var(--cn-ease),
        visibility 0.28s var(--cn-ease),
        transform 0.35s var(--cn-spring);
}

.cookie-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

/* En-tête */
.cookie-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--cn-border);
    flex-shrink: 0;
}

.cookie-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cn-accent);
}

.cookie-panel-title h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--cn-dark);
    margin: 0;
}

.cookie-panel-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--cn-light);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cn-gray);
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
    flex-shrink: 0;
}

.cookie-panel-close:hover {
    background: var(--cn-primary);
    color: var(--cn-dark);
}

.cookie-panel-close:focus-visible {
    outline: 3px solid rgba(139, 115, 85, 0.35);
    outline-offset: 2px;
}

/* Corps */
.cookie-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.cookie-panel-intro {
    font-size: 13.5px;
    color: var(--cn-gray);
    line-height: 1.65;
    margin: 0 0 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--cn-border);
}

/* Catégories */
.cookie-category {
    padding: 18px 0;
    border-bottom: 1px solid var(--cn-border);
}

.cookie-category:last-child {
    border-bottom: none;
    padding-bottom: 4px;
}

.cookie-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cookie-category-info h3 {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--cn-dark);
    margin: 0 0 4px;
}

.cookie-category-info p {
    font-size: 13px;
    color: var(--cn-gray);
    margin: 0;
    line-height: 1.5;
}

/* Étiquette "Toujours actifs" */
.cookie-always-on {
    font-size: 12px;
    font-weight: 600;
    color: var(--cn-accent);
    background: rgba(139, 115, 85, 0.1);
    padding: 5px 11px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Toggle switch iOS-style */
.cookie-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* Masquer la checkbox native — accessible via clavier */
.cookie-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.cookie-toggle-track {
    width: 50px;
    height: 28px;
    border-radius: 14px;
    background: #d1d5db;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}

.cookie-toggle input:checked + .cookie-toggle-track {
    background: var(--cn-accent);
}

.cookie-toggle-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.22);
    transition: transform 0.25s var(--cn-spring);
}

.cookie-toggle input:checked + .cookie-toggle-track .cookie-toggle-thumb {
    transform: translateX(22px);
}

.cookie-toggle input:focus-visible + .cookie-toggle-track {
    outline: 3px solid rgba(139, 115, 85, 0.35);
    outline-offset: 2px;
}

/* Pied du panneau */
.cookie-panel-footer {
    display: flex;
    gap: 12px;
    padding: 18px 24px;
    border-top: 1px solid var(--cn-border);
    flex-shrink: 0;
    background: var(--cn-light);
    border-radius: 0 0 var(--cn-radius) var(--cn-radius);
}

.cookie-panel-btn-secondary {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    border: 2px solid var(--cn-border);
    background: #fff;
    color: var(--cn-dark);
    min-height: 46px;
    transition: border-color 0.2s, background 0.2s;
}

.cookie-panel-btn-secondary:hover {
    border-color: var(--cn-accent);
    background: var(--cn-light);
}

.cookie-panel-btn-secondary:focus-visible {
    outline: 3px solid rgba(139, 115, 85, 0.35);
    outline-offset: 2px;
}

.cookie-panel-btn-primary {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: var(--cn-accent);
    color: #fff;
    min-height: 46px;
    transition: background 0.2s, transform 0.18s, box-shadow 0.2s;
}

.cookie-panel-btn-primary:hover {
    background: var(--cn-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(44, 36, 22, 0.22);
}

.cookie-panel-btn-primary:active {
    transform: translateY(0);
}

.cookie-panel-btn-primary:focus-visible {
    outline: 3px solid rgba(139, 115, 85, 0.45);
    outline-offset: 2px;
}


/* ============================================================
   4. LIEN "GÉRER MES COOKIES" (footer, etc.)
   ============================================================ */

[data-consent="cookies"] {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}


/* ============================================================
   5. RESPONSIVE — Mobile
   ============================================================ */

@media (max-width: 600px) {

    /* CGV — bottom sheet sur mobile */
    .cgv-modal {
        align-items: flex-end;
        padding: 0;
    }

    .cgv-dialog {
        border-radius: var(--cn-radius) var(--cn-radius) 0 0;
        max-width: 100%;
        max-height: 92dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(100%);
    }

    .cgv-modal.active .cgv-dialog {
        transform: translateY(0);
    }

    .cgv-header {
        padding: 22px 18px 16px;
    }

    .cgv-body {
        padding: 18px;
    }

    .cgv-footer {
        padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .cgv-btn-confirm {
        width: 100%;
    }

    /* Bannière cookies */
    .cookie-banner-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 16px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .cookie-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .cookie-btn-accept {
        flex: 1;
    }

    /* Panneau — bottom sheet sur mobile */
    .cookie-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        transform: translateY(30px);
        border-radius: var(--cn-radius) var(--cn-radius) 0 0;
        width: 100%;
        max-width: 100%;
        max-height: 90dvh;
    }

    .cookie-panel.active {
        transform: translateY(0);
    }

    .cookie-panel-body {
        padding: 16px 18px;
    }

    .cookie-panel-header {
        padding: 18px;
    }

    .cookie-panel-footer {
        flex-direction: column;
        padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 0;
    }

    .cookie-panel-btn-primary,
    .cookie-panel-btn-secondary {
        width: 100%;
    }
}

/* Respect des préférences d'animation */
@media (prefers-reduced-motion: reduce) {
    .cgv-modal,
    .cgv-dialog,
    .cookie-banner,
    .cookie-panel,
    .cookie-panel-overlay,
    .cookie-toggle-thumb,
    .cookie-toggle-track,
    .cgv-btn-confirm,
    .cgv-link,
    .cgv-checkbox-custom {
        transition: none !important;
        animation: none !important;
    }

    .cgv-dialog.cgv-shake {
        animation: none !important;
    }
}
