/* @category: base */
/* ==========================================
   Template: Default (Flexisite Survey)
   ========================================== */

/* Reset indispensable pour le Flexbox et l'Embed (Limité au sondage) */
.poll-survey *, .poll-survey *::before, .poll-survey *::after { box-sizing: border-box; }
/*.poll-survey h2, .poll-survey h3 { text-align: center; margin: 20px 0; } */


/* [TITRE CENTRE] H1/H2 du sondage toujours centre, y compris layouts
   gauche/droite (le template ne centre que h2/h3). */
.poll-survey .poll-embed-title { text-align: center; margin: 20px 0; }

/* Le sondage occupe toute la largeur de son conteneur (iframe
   embed.html, page d'accueil, etc.), à toute taille d'écran — pas
   seulement sur mobile, et sans limite de largeur. Scopé via
   :not(:has(.gallery-preview)) : .gallery-preview est la classe que
   poll_templates.php ajoute à chaque carte de démo, donc cette règle
   ne se déclenche jamais sur la page galerie, quelle que soit sa
   profondeur d'imbrication réelle (contrairement à une vérification
   par "enfant direct de body", trop fragile). */
body:has(.poll-survey):not(:has(.gallery-preview)) { padding: 0 !important; margin: 0 !important; }
.poll-survey:not(.gallery-preview) .poll-container { max-width: 100% !important; }

/* Variables de couleurs du thème par défaut */
.poll-template-default {
    --poll-primary-color: #007bff;
    --poll-primary-hover: #0056b3;
    --poll-secondary-color: #e57373;
    --poll-success-color: #2e7d32;
    --poll-success-bg: #e8f5e9;
    --poll-error-color: #c62828;
    --poll-error-bg: #ffebee;
    
    --poll-text-color: #333;
    --poll-muted-color: #666;
    --poll-bg-light: #f9f9f9;
    --poll-bg-hover: #f0f0f0;
    --poll-bg-bar: #eee;
    
    --poll-border-color: #ddd;
    --poll-border-dark: #ccc;
    
    --poll-bg-main: #ffffff;
    --poll-box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Conteneur principal avec fond et ombre (carte) */
.poll-survey .poll-container {
    flex: 1 1 100%;

    max-width: 700px;
    margin: 0 auto;
    text-align: center;
    background: var(--poll-bg-main);
    color: var(--poll-text-color);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--poll-box-shadow);
}

.poll-survey .poll-cover { width: 100%; max-width: 700px; display: block; margin: 0 auto 20px auto; border-radius: 8px; }
.poll-survey .poll-note { color: var(--poll-text-color); font-size: 1em; margin-bottom: 20px; padding: 0 10px; text-align: left; line-height: 1.5; }

.poll-survey .poll-instruction { color: var(--poll-muted-color); font-style: italic; margin-bottom: 20px; text-align: center; }
.poll-survey .poll-msg-success { color: var(--poll-success-color); font-weight: bold; background: var(--poll-success-bg); padding: 10px; border-radius: 5px; margin-bottom: 15px; }
.poll-survey .poll-msg-error { color: var(--poll-error-color); font-weight: bold; background: var(--poll-error-bg); padding: 10px; border-radius: 5px; margin-bottom: 15px; }
.poll-survey .poll-helper-text { font-size: 0.9em; color: var(--poll-muted-color); text-align: center; margin-top: 5px; }

.poll-survey .poll-options-container { text-align: left; display: inline-block; width: 100%; max-width: 500px; }
.poll-survey .poll-option-label { display: block; margin-bottom: 10px; font-weight: normal; cursor: pointer; padding: 8px; border-radius: 4px; transition: background 0.2s; color: var(--poll-text-color); }
.poll-survey .poll-option-label:hover { background: var(--poll-bg-hover); }

.poll-survey .poll-question-block { margin-bottom: 20px; text-align: left; display: inline-block; width: 100%; max-width: 500px; }
.poll-survey .poll-question-title { display: block; margin-bottom: 6px; font-weight: bold; color: var(--poll-text-color); }
.poll-survey .poll-radio-label { margin-right: 20px; font-weight: normal; cursor: pointer; color: var(--poll-text-color); }
.poll-survey .poll-range { width: 100%; max-width: 400px; vertical-align: middle; }
.poll-survey .poll-range-value { font-weight: bold; margin-left: 10px; color: var(--poll-text-color); }

.poll-survey .sortable-poll { list-style: none; padding: 0; max-width: 500px; margin: 0 auto; }
.poll-survey .sortable-item { display: flex; align-items: center; padding: 10px 15px; margin-bottom: 8px; background: var(--poll-bg-light); border: 1px solid var(--poll-border-color); border-radius: 5px; cursor: grab; user-select: none; color: var(--poll-text-color); touch-action: none; }
.poll-survey .sortable-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.05); border-color: var(--poll-muted-color); }
.poll-survey .sortable-handle { font-size: 20px; margin-right: 15px; color: var(--poll-muted-color); }
.poll-survey .sortable-text { flex: 1; text-align: left; }

.poll-survey .rang-badge { background: var(--poll-primary-color); color: #fff; border-radius: 50%; width: 28px; height: 28px; min-width: 28px; line-height: 28px; text-align: center; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; flex-shrink: 0; font-weight: bold; font-size: 0.9em; }


.poll-survey .poll-submit-btn { 
    background: var(--poll-primary-color); 
    color: #fff; 
    border: none; 
    padding: 10px 30px; 
    height: auto;        
    line-height: 1.2;    
    font-size: 1.1em; 
    border-radius: 5px; 
    cursor: pointer; 
    margin: 10px auto 0; /* Centré horizontalement */
    transition: background 0.2s; 
    box-sizing: border-box;
    display: block; /* Force le centrage même dans un layout Left/Right */
}

.poll-survey .poll-submit-btn:hover { background: var(--poll-primary-hover); }
.poll-survey .poll-nav-links { margin-top: 30px; display: flex; justify-content: space-between; max-width: 700px; margin-left: auto; margin-right: auto; }
.poll-survey .poll-nav-links a { text-decoration: underline; color: var(--poll-muted-color); font-size: 0.9em; }
.poll-survey .poll-nav-links a:hover { color: var(--poll-text-color); }

/* --- Results --- */
.poll-survey .poll-result-row { margin-bottom: 18px; color: var(--poll-text-color); text-align: left; }
.poll-survey .poll-result-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.poll-survey .poll-result-sub { display: flex; justify-content: space-between; font-size: 0.9em; color: var(--poll-muted-color); margin-bottom: 4px; }
.poll-survey .poll-bar-container { background: var(--poll-bg-bar); border-radius: 4px; height: 14px; overflow: hidden; }
.poll-survey .poll-bar-container-split { background: var(--poll-bg-bar); border-radius: 4px; height: 14px; overflow: hidden; display: flex; }
.poll-survey .poll-bar-fill { background: var(--poll-secondary-color); height: 100%; }
.poll-survey .poll-bar-fill-yes { background: #66bb6a; height: 100%; }
.poll-survey .poll-bar-fill-no { background: var(--poll-secondary-color); height: 100%; }

.poll-survey .poll-result-rank-item { margin-bottom: 12px; display: flex; align-items: center; width: 100%; text-align: left; }
.poll-survey .poll-result-rank-text { flex: 1; color: var(--poll-text-color); text-align: left; }
.poll-survey .poll-result-rank-avg { color: var(--poll-muted-color); font-size: 0.9em; }

.poll-survey .poll-stats-title { margin-top: 35px; color: var(--poll-text-color); }
.poll-survey .poll-stats-subtitle { margin-top: 25px; color: var(--poll-text-color); }
.poll-survey .poll-stats-daily-row { display: flex; align-items: center; margin-bottom: 4px; }
.poll-survey .poll-stats-daily-date { width: 90px; flex-shrink: 0; font-size: 0.85em; color: var(--poll-muted-color); }
.poll-survey .poll-stats-daily-bar-container { flex: 1; background: var(--poll-bg-bar); border-radius: 3px; height: 10px; overflow: hidden; margin-right: 8px; }
.poll-survey .poll-stats-daily-bar-fill { background: var(--poll-secondary-color); height: 100%; }
.poll-survey .poll-stats-daily-count { font-size: 0.85em; color: var(--poll-muted-color); width: 30px; text-align: right; }
.poll-survey .poll-stats-table-wrap { overflow-x: auto; }
.poll-survey .poll-stats-table { width: 100%; border-collapse: collapse; font-size: 0.9em; color: var(--poll-text-color); }
.poll-survey .poll-stats-table th { border-bottom: 2px solid var(--poll-border-dark); text-align: center; }
.poll-survey .poll-stats-table th:first-child { text-align: left; }
.poll-survey .poll-stats-table td { border-bottom: 1px solid var(--poll-border-color); padding: 4px 6px 4px 0; text-align: center; }
.poll-survey .poll-stats-table td:first-child { text-align: left; }

/* Option "Autre" dans le formulaire de vote */
.poll-survey .poll-option-other { display: flex; align-items: center; gap: 5px; }
.poll-survey .poll-other-input { flex: 1; max-width: 200px; }

/* Boutons de tri mobile (Cachés sur desktop) */
.poll-survey .sort-btns { display: none; flex-direction: column; margin-left: 10px; }
.poll-survey .sort-btns button { background: var(--poll-bg-hover); border: 1px solid var(--poll-border-color); border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 1em; line-height: 1; margin: 1px 0; }

/* Sur écrans tactiles / mobiles : on cache le handle et on affiche les boutons */
@media (hover: none) and (pointer: coarse) {
    .poll-survey .sortable-handle { display: none; }
    .poll-survey .sort-btns { display: flex; }
}

/* --- Bannière de Succès Vote --- */
.poll-survey .poll-success-banner {
    background: var(--poll-success-bg);
    color: var(--poll-success-color);
    border: 2px solid var(--poll-success-color);
    padding: 25px 15px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.15);
}
.poll-survey .poll-success-banner h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: bold;
}

/* On atténue le formulaire en dessous pour bien montrer que c'est terminé */
.poll-survey .poll-success-banner ~ form {
    opacity: 0.5;
    transition: opacity 0.3s;
    pointer-events: none;
}
.poll-survey .poll-success-banner ~ form:hover {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================
   Layouts (Gauche / Droite / Haut)
   ========================================== */

.poll-survey.poll-layout-top .poll-col { width: 100%; }

.poll-survey.poll-layout-left .poll-container, 
.poll-survey.poll-layout-right .poll-container { 
    display: flex !important; 
    flex-wrap: wrap; 
    gap: 30px; 
    align-items: flex-start; 
    text-align: left; 
}

.poll-survey.poll-layout-left .poll-col-cover { flex: 1 1 300px; max-width: 40%; }
.poll-survey.poll-layout-left .poll-col-form { flex: 1 1 300px; }

.poll-survey.poll-layout-right .poll-col-cover { order: 2; flex: 1 1 300px; max-width: 40%; }
.poll-survey.poll-layout-right .poll-col-form { order: 1; flex: 1 1 300px; }

/* Sur mobile (PORTRAIT UNIQUEMENT), on revient à l'affichage normal (haut) */
/* On utilise orientation: portrait pour que le mode paysage garde l'affichage côte à côte */
@media (max-width: 768px) and (orientation: portrait) {
    .poll-survey #bloc_100 { padding: 0 !important; width: 100% !important; display: block !important; }

    /* 2. Réduction des marges du sondage pour utiliser toute la largeur */
    .poll-survey .poll-container {
        max-width: 100% !important; 
        padding: 15px !important;   
        margin: 0 !important;       
    }
    .poll-survey .poll-cover { margin-bottom: 15px; }

    /* 3. Forçage de l'empilement (colonne) et suppression de l'espace vide (gap) */
    .poll-survey.poll-layout-left .poll-container, 
    .poll-survey.poll-layout-right .poll-container { 
        flex-direction: column; 
        gap: 0 !important;
    }
    .poll-survey.poll-layout-left .poll-col-cover, 
    .poll-survey.poll-layout-right .poll-col-cover { 
        order: 1; 
        max-width: 100%; 
        width: 100%;
        flex: 0 0 auto !important; 
    }
    .poll-survey.poll-layout-left .poll-col-form, 
    .poll-survey.poll-layout-right .poll-col-form { 
        order: 2; 
        max-width: 100%; 
        width: 100%;
        flex: 0 0 auto !important;
    }
}
