/**
 * MySO Cookie Banner CSS - v1.0.3 (optimisations mobile, accessibilite, tactile)
 * Couleurs MySO 3.0 : Forest #3d5a3d / Sage #7d9a78 / Terracotta #c67b5c / Cream #faf8f5 / Sand #e8e2d9
 */

.myso-cookie-banner {
    position: fixed;
    background: #ffffff;
    border-top: 4px solid #c67b5c;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    color: #2d3029;
}

/* Position bottom (defaut) */
.myso-cookie-banner.myso-pos-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Position top */
.myso-cookie-banner.myso-pos-top {
    top: 0;
    left: 0;
    right: 0;
    border-top: none;
    border-bottom: 4px solid #c67b5c;
    padding: 24px;
}

/* Position modal (centree) */
.myso-cookie-banner.myso-pos-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 600px;
    width: 90%;
    border: 1px solid #e8e2d9;
    border-top: 4px solid #c67b5c;
    padding: 32px;
    border-radius: 8px;
    max-height: 85vh;
    overflow-y: auto;
}

.myso-cookie-banner.myso-pos-modal::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(45, 48, 41, 0.7);
    z-index: -1;
}

.myso-cookie-content {
    max-width: 1200px;
    margin: 0 auto;
}

.myso-cookie-title {
    color: #3d5a3d;
    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 12px;
}

.myso-cookie-text {
    color: #2d3029;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 8px;
}

.myso-cookie-link-inline {
    color: #c67b5c;
    text-decoration: underline;
    font-weight: 600;
}

.myso-cookie-link-inline:hover,
.myso-cookie-link-inline:focus {
    color: #3d5a3d;
}

.myso-cookie-link {
    margin: 0 0 20px;
    font-size: 13px;
}

.myso-cookie-link a {
    color: #c67b5c;
    text-decoration: underline;
}

.myso-cookie-link a:hover,
.myso-cookie-link a:focus {
    color: #3d5a3d;
}

.myso-cookie-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

/* Boutons - taille tactile minimum 44x44 (recommandation Apple/Google) */
.myso-btn {
    padding: 12px 24px;
    min-height: 44px;
    min-width: 44px;
    border: 0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    font-family: inherit;
    touch-action: manipulation; /* Eviter le delai de 300ms tactile */
    -webkit-tap-highlight-color: transparent;
}

/* Focus visible pour accessibilite clavier */
.myso-btn:focus-visible {
    outline: 3px solid #c67b5c;
    outline-offset: 2px;
}

.myso-btn-accept {
    background: #3d5a3d;
    color: #ffffff;
}

.myso-btn-accept:hover,
.myso-btn-accept:focus {
    background: #2d4a2d;
}

.myso-btn-reject {
    background: #ffffff;
    color: #2d3029;
    border: 2px solid #5c5f55;
}

.myso-btn-reject:hover,
.myso-btn-reject:focus {
    background: #faf8f5;
    border-color: #2d3029;
}

.myso-btn-customize {
    background: #ffffff;
    color: #c67b5c;
    border: 2px solid #c67b5c;
}

.myso-btn-customize:hover,
.myso-btn-customize:focus {
    background: #c67b5c;
    color: #ffffff;
}

.myso-btn-save {
    background: #c67b5c;
    color: #ffffff;
}

.myso-btn-save:hover,
.myso-btn-save:focus {
    background: #b06a4a;
}

.myso-btn-back {
    background: transparent;
    color: #5c5f55;
    border: 1px solid #e8e2d9;
}

.myso-btn-back:hover,
.myso-btn-back:focus {
    background: #faf8f5;
}

/* Vue personnalisation */
.myso-cookie-categories {
    background: #faf8f5;
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.myso-category {
    border-bottom: 1px solid #e8e2d9;
    padding: 12px 0;
}

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

.myso-category-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: bold;
    color: #3d5a3d;
    margin: 0;
    min-height: 44px;
}

.myso-category-label input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: #c67b5c;
    flex-shrink: 0;
}

.myso-category-label input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.myso-cat-name {
    font-size: 14px;
}

.myso-cat-desc {
    color: #5c5f55;
    font-size: 12px;
    line-height: 1.4;
    margin: 6px 0 0 34px;
}

.myso-cookie-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.myso-cookie-version {
    color: #7d9a78;
    font-size: 11px;
    margin: 16px 0 0;
    text-align: right;
    font-style: italic;
}

/* RESPONSIVE - Mobile (compact pour ne pas bouffer l'ecran) */
@media (max-width: 768px) {
    /* Bandeau compact bottom - hauteur reduite */
    .myso-cookie-banner.myso-pos-bottom,
    .myso-cookie-banner.myso-pos-top {
        padding: 12px 14px;
        max-height: 40vh;
        /* Respect zone safe iPhone (encoche/barre tactile) */
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    /* Titre plus petit et compact */
    .myso-cookie-title {
        font-size: 16px;
        margin-bottom: 6px;
    }

    /* Texte plus court et compact */
    .myso-cookie-text {
        font-size: 13px;
        line-height: 1.4;
        margin-bottom: 6px;
    }

    /* Lien "En savoir plus" sur la meme ligne pour gagner de la place */
    .myso-cookie-link {
        font-size: 12px;
        margin: 0 0 10px;
    }

    /* Boutons en grille 3 colonnes pour les 3 actions principales */
    #myso-cookie-actions-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin: 8px 0;
    }

    /* Le bouton "Personnaliser" prend toute la largeur sur la 2eme ligne */
    #myso-cookie-actions-main .myso-btn-customize {
        grid-column: 1 / -1;
    }

    /* Boutons compacts mais accessibles (44px min recommandation Apple/Google) */
    .myso-btn {
        padding: 10px 14px;
        min-height: 44px;
        font-size: 13px;
        letter-spacing: 0.2px;
        width: 100%;
    }

    /* Version compacte de la mention version politique */
    .myso-cookie-version {
        font-size: 10px;
        margin-top: 8px;
    }

    /* VUE PERSONNALISER : passe en plein ecran sur mobile */
    .myso-cookie-banner #myso-cookie-actions-custom[style*="block"] {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #ffffff;
        z-index: 99999;
        padding: 16px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Quand vue Personnaliser ouverte, cacher le contenu compact */
    .myso-cookie-banner #myso-cookie-actions-custom[style*="block"] ~ * {
        display: none;
    }

    /* Categories en mode plein ecran */
    .myso-cookie-categories {
        padding: 12px;
        margin-bottom: 12px;
    }

    .myso-cat-name {
        font-size: 14px;
    }

    .myso-cat-desc {
        font-size: 12px;
        margin-left: 34px;
    }

    /* Boutons de la vue Personnaliser */
    .myso-cookie-buttons {
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: 8px;
        position: sticky;
        bottom: 0;
        background: #ffffff;
        padding-top: 12px;
        padding-bottom: env(safe-area-inset-bottom, 12px);
        margin: 0 -16px -16px;
        padding-left: 16px;
        padding-right: 16px;
        border-top: 1px solid #e8e2d9;
    }
}

/* TRES PETITS ECRANS (320-380px = iPhone SE, vieux Android) */
@media (max-width: 380px) {
    .myso-cookie-banner.myso-pos-bottom,
    .myso-cookie-banner.myso-pos-top {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .myso-cookie-title {
        font-size: 15px;
    }

    .myso-cookie-text {
        font-size: 12px;
    }

    .myso-btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 42px;
    }
}

/* PAGE POLITIQUE DE CONFIDENTIALITE */
.myso-privacy-page {
    max-width: 900px;
    margin: 30px auto;
    padding: 0 20px;
    color: #2d3029;
    line-height: 1.6;
}

.myso-privacy-page h1 {
    color: #3d5a3d;
    font-family: Georgia, serif;
    font-size: 32px;
    border-bottom: 3px solid #c67b5c;
    padding-bottom: 12px;
    margin-bottom: 24px;
    line-height: 1.2;
}

.myso-privacy-page h2 {
    color: #7d9a78;
    font-size: 22px;
    margin-top: 32px;
    margin-bottom: 12px;
    line-height: 1.3;
}

.myso-privacy-page h3 {
    color: #c67b5c;
    font-size: 18px;
    margin-top: 24px;
    line-height: 1.3;
}

.myso-privacy-meta {
    background: #faf8f5;
    border-left: 4px solid #7d9a78;
    padding: 16px 20px;
    margin: 20px 0 30px;
    font-size: 13px;
    color: #5c5f55;
    word-break: break-word;
}

.myso-privacy-meta strong {
    color: #2d3029;
}

/* TABLEAUX RESPONSIVE */
.myso-privacy-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
    border: 1px solid #e8e2d9;
    border-radius: 4px;
}

.myso-privacy-page table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 14px;
    margin: 16px 0;
}

.myso-privacy-page table th {
    background: #3d5a3d;
    color: #ffffff;
    padding: 10px;
    text-align: left;
    white-space: nowrap;
}

.myso-privacy-page table td {
    padding: 10px;
    border-bottom: 1px solid #e8e2d9;
    vertical-align: top;
}

.myso-privacy-page ul,
.myso-privacy-page ol {
    padding-left: 24px;
}

.myso-privacy-page ul li,
.myso-privacy-page ol li {
    margin-bottom: 8px;
}

.myso-privacy-page a {
    color: #c67b5c;
    text-decoration: underline;
}

.myso-privacy-page a:hover,
.myso-privacy-page a:focus {
    color: #3d5a3d;
}

.myso-privacy-history {
    background: #faf8f5;
    border-left: 4px solid #c67b5c;
    padding: 16px 20px;
    margin-top: 40px;
    font-size: 13px;
}

/* MOBILE - Page politique */
@media (max-width: 768px) {
    .myso-privacy-page {
        padding: 0 16px;
        margin: 20px auto;
    }
    .myso-privacy-page h1 {
        font-size: 24px;
    }
    .myso-privacy-page h2 {
        font-size: 19px;
        margin-top: 24px;
    }
    .myso-privacy-page h3 {
        font-size: 16px;
    }
    /* Tableaux scrollables horizontalement sur mobile */
    .myso-privacy-page table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        font-size: 13px;
    }
    .myso-privacy-page table th,
    .myso-privacy-page table td {
        min-width: 140px;
        padding: 8px;
    }
    .myso-privacy-page table td {
        white-space: normal;
    }
    /* Citation des emails sur mobile - toujours lisibles */
    .myso-privacy-page code {
        word-break: break-all;
        font-size: 11px;
    }
}

/* TRES PETITS ECRANS (320-380px) */
@media (max-width: 380px) {
    .myso-privacy-page h1 {
        font-size: 22px;
    }
    .myso-cookie-title {
        font-size: 16px;
    }
    .myso-btn {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* IMPRESSION */
@media print {
    .myso-cookie-banner {
        display: none !important;
    }
    .myso-privacy-page {
        max-width: 100%;
        color: #000;
    }
    .myso-privacy-page h1,
    .myso-privacy-page h2,
    .myso-privacy-page h3 {
        color: #000;
        page-break-after: avoid;
    }
    .myso-privacy-page table {
        page-break-inside: avoid;
    }
}

/* PREFERENCE REDUCED MOTION (accessibilite) */
@media (prefers-reduced-motion: reduce) {
    .myso-cookie-banner,
    .myso-btn {
        transition: none !important;
    }
}
