/* ============================================================
   Cookie MX — Feuille de style frontend
   Author: RFDEV
   ============================================================ */

:root {
    --cmx-primary:       #1a56db;
    --cmx-primary-hover: #1648c0;
    --cmx-text:          #111827;
    --cmx-text-muted:    #6b7280;
    --cmx-bg:            #ffffff;
    --cmx-border:        #e5e7eb;
    --cmx-success:       #059669;
    --cmx-danger:        #dc2626;
    --cmx-radius:        8px;
    --cmx-shadow:        0 4px 32px rgba(0, 0, 0, 0.18);
    --cmx-z:             99999;
}

/* ============================================================
   BANDEAU FOOTER
   ============================================================ */

#cookiemx-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--cmx-z);
    background: #1e2937;
    color: #ffffff;
    padding: 16px 24px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

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

#cookiemx-banner.cookiemx-hidden {
    display: none;
}

.cookiemx-banner-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.cookiemx-banner-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.cookiemx-banner-icon {
    flex-shrink: 0;
    color: #f9c74f;
    line-height: 0;
}

.cookiemx-banner-icon svg {
    width: 38px;
    height: 38px;
}

.cookiemx-banner-text strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #ffffff;
    line-height: 1.3;
}

.cookiemx-banner-text p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #d1d5db;
}

.cookiemx-banner-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.cookiemx-privacy-link {
    font-size: 12px;
    color: #93c5fd;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}

.cookiemx-privacy-link:hover {
    color: #bfdbfe;
    text-decoration: underline;
}

.cookiemx-banner-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ============================================================
   BOUTONS
   ============================================================ */

.cookiemx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--cmx-radius);
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.cookiemx-btn:focus-visible {
    outline: 3px solid rgba(26, 86, 219, 0.5);
    outline-offset: 2px;
}

/* Primaire — bleu plein */
.cookiemx-btn-primary {
    background: var(--cmx-primary);
    color: #ffffff;
    border-color: var(--cmx-primary);
}
.cookiemx-btn-primary:hover {
    background: var(--cmx-primary-hover);
    border-color: var(--cmx-primary-hover);
}

/* Secondaire — gris foncé (dans bandeau) */
.cookiemx-btn-secondary {
    background: #374151;
    color: #ffffff;
    border-color: #374151;
}
.cookiemx-btn-secondary:hover {
    background: #1f2937;
    border-color: #1f2937;
}

/* Outline — transparent (dans bandeau) */
.cookiemx-btn-outline {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.6);
}
.cookiemx-btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}

/* Pleine largeur */
.cookiemx-btn-full {
    width: 100%;
    display: flex;
}

/* ============================================================
   BOUTON FLOTTANT (FAB)
   ============================================================ */

#cookiemx-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: calc(var(--cmx-z) - 1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--cmx-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(26, 86, 219, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    padding: 0;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

#cookiemx-fab:hover {
    background: var(--cmx-primary-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(26, 86, 219, 0.55);
}

#cookiemx-fab:focus-visible {
    outline: 3px solid rgba(26, 86, 219, 0.5);
    outline-offset: 3px;
}

#cookiemx-fab svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}

/* ============================================================
   MODALE
   ============================================================ */

.cookiemx-modal {
    position: fixed;
    inset: 0;
    z-index: var(--cmx-z);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.cookiemx-modal.cookiemx-hidden {
    display: none;
}

.cookiemx-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.cookiemx-modal-container {
    position: relative;
    background: var(--cmx-bg);
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--cmx-shadow);
    overflow: hidden;
    animation: cmxModalIn 0.25s ease;
}

@keyframes cmxModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* En-tête modale */
.cookiemx-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--cmx-border);
    flex-shrink: 0;
    gap: 12px;
}

.cookiemx-modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--cmx-text);
    line-height: 1.3;
}

.cookiemx-modal-header .cookiemx-privacy-link {
    color: var(--cmx-primary);
    font-size: 12px;
    white-space: nowrap;
}

/* ============================================================
   ONGLETS
   ============================================================ */

.cookiemx-modal-tabs {
    display: flex;
    border-bottom: 2px solid var(--cmx-border);
    flex-shrink: 0;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    gap: 0;
}

.cookiemx-modal-tabs::-webkit-scrollbar {
    display: none;
}

.cookiemx-tab {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cmx-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.cookiemx-tab.active {
    color: var(--cmx-primary);
    border-bottom-color: var(--cmx-primary);
    font-weight: 700;
}

.cookiemx-tab:hover:not(.active) {
    color: var(--cmx-text);
}

/* ============================================================
   CORPS DE LA MODALE
   ============================================================ */

.cookiemx-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    overscroll-behavior: contain;
}

.cookiemx-modal-body > p:first-child {
    margin: 0 0 16px;
    font-size: 14px;
    color: var(--cmx-text);
    line-height: 1.6;
}

.cookiemx-tab-content {
    display: none;
}

.cookiemx-tab-content.active {
    display: block;
}

/* ============================================================
   CATÉGORIES DE COOKIES
   ============================================================ */

.cookiemx-category {
    border: 1px solid var(--cmx-border);
    border-radius: var(--cmx-radius);
    margin-bottom: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.cookiemx-category:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.cookiemx-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    background: #f9fafb;
    cursor: default;
    gap: 12px;
}

.cookiemx-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cookiemx-category-title strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--cmx-text);
    line-height: 1.3;
}

.cookiemx-chevron {
    font-size: 10px;
    color: var(--cmx-text-muted);
}

.cookiemx-category-desc {
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.65;
    color: var(--cmx-text-muted);
    border-top: 1px solid var(--cmx-border);
}

.cookiemx-category-desc a {
    color: var(--cmx-primary);
    text-decoration: none;
}

.cookiemx-category-desc a:hover {
    text-decoration: underline;
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.cookiemx-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.cookiemx-toggle input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    pointer-events: none;
}

.cookiemx-toggle label {
    display: inline-block;
    width: 48px;
    height: 26px;
    background: #d1d5db;
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.25s;
    position: relative;
    flex-shrink: 0;
}

.cookiemx-toggle label::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.cookiemx-toggle input:checked + label {
    background: var(--cmx-primary);
}

.cookiemx-toggle input:checked + label::after {
    transform: translateX(22px);
}

.cookiemx-toggle-disabled label {
    background: #9ca3af;
    cursor: not-allowed;
}

.cookiemx-toggle input:disabled:checked + label {
    background: #9ca3af;
}

.cookiemx-toggle input:focus-visible + label {
    outline: 3px solid rgba(26, 86, 219, 0.4);
    outline-offset: 2px;
}

/* ============================================================
   TABLEAU COOKIES
   ============================================================ */

.cookiemx-modal-body h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--cmx-text);
    margin: 20px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cookiemx-modal-body h3:first-child {
    margin-top: 0;
}

.cookiemx-cookies-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 4px;
}

.cookiemx-cookies-table th {
    text-align: left;
    padding: 7px 10px;
    background: #f3f4f6;
    color: var(--cmx-text-muted);
    font-weight: 700;
    border: 1px solid var(--cmx-border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cookiemx-cookies-table td {
    padding: 7px 10px;
    border: 1px solid var(--cmx-border);
    color: var(--cmx-text);
    vertical-align: top;
    line-height: 1.5;
}

.cookiemx-cookies-table td:first-child {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    color: #7c3aed;
    white-space: nowrap;
    background: #faf5ff;
}

/* ============================================================
   PIED DE MODALE
   ============================================================ */

.cookiemx-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--cmx-border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
}

.cookiemx-modal-footer-row {
    display: flex;
    gap: 10px;
}

.cookiemx-modal-footer-row .cookiemx-btn {
    flex: 1;
}

/* Boutons secondaire / outline dans la modale (fond blanc) */
.cookiemx-modal-footer .cookiemx-btn-secondary,
.cookiemx-modal-footer .cookiemx-btn-outline {
    background: #ffffff;
    border-color: var(--cmx-border);
    color: var(--cmx-text);
}

.cookiemx-modal-footer .cookiemx-btn-secondary:hover,
.cookiemx-modal-footer .cookiemx-btn-outline:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* ============================================================
   BADGES (onglet Mes données)
   ============================================================ */

.cookiemx-badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.cookiemx-badge-yes {
    background: #d1fae5;
    color: #065f46;
}

.cookiemx-badge-no {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================================
   UTILITAIRES
   ============================================================ */

.cookiemx-hidden {
    display: none !important;
}

#cookiemx-config {
    display: none !important;
}

/* ============================================================
   RESPONSIVE — Tablette (≤ 900px)
   ============================================================ */

@media (max-width: 900px) {
    .cookiemx-banner-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .cookiemx-banner-actions {
        align-items: stretch;
    }

    .cookiemx-banner-buttons {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .cookiemx-banner-buttons .cookiemx-btn {
        flex: 1 1 calc(33.333% - 8px);
        min-width: 100px;
    }
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 600px)
   ============================================================ */

@media (max-width: 600px) {
    #cookiemx-banner {
        padding: 14px 16px;
    }

    .cookiemx-banner-content {
        gap: 10px;
    }

    .cookiemx-banner-icon svg {
        width: 30px;
        height: 30px;
    }

    .cookiemx-banner-text strong {
        font-size: 14px;
    }

    .cookiemx-banner-text p {
        font-size: 12px;
    }

    .cookiemx-banner-buttons {
        flex-direction: column;
        gap: 7px;
    }

    .cookiemx-banner-buttons .cookiemx-btn {
        flex: none;
        width: 100%;
    }

    /* Modale plein écran sur mobile */
    .cookiemx-modal {
        padding: 0;
        align-items: flex-end;
    }

    .cookiemx-modal-container {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: cmxModalInMobile 0.3s ease;
    }

    @keyframes cmxModalInMobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0);    }
    }

    .cookiemx-modal-header {
        padding: 16px 18px 12px;
    }

    .cookiemx-modal-header h2 {
        font-size: 15px;
    }

    .cookiemx-modal-body {
        padding: 16px 18px;
    }

    .cookiemx-modal-footer {
        padding: 12px 18px;
    }

    .cookiemx-tab {
        padding: 10px 13px;
        font-size: 12px;
    }

    .cookiemx-cookies-table {
        font-size: 11px;
    }

    .cookiemx-cookies-table th,
    .cookiemx-cookies-table td {
        padding: 6px 8px;
    }

    #cookiemx-fab {
        bottom: 14px;
        left: 14px;
        width: 44px;
        height: 44px;
    }

    #cookiemx-fab svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================================
   RESPONSIVE — Très petit mobile (≤ 360px)
   ============================================================ */

@media (max-width: 360px) {
    .cookiemx-modal-footer-row {
        flex-direction: column;
    }
}
