/* ==========================================================================
   1. BASE & TYPOGRAPHIE
   ========================================================================== */
* {
    box-sizing: border-box;
}

body {
    position: relative; /* Ajout crucial pour servir de point de repère aux liens */
    font-family: 'Segoe UI', 'sans-serif';
    
    max-width: 900px;
    margin: 0 auto;
    background: #f4f7f6;
    padding: 15px;
    display: block;
    min-height: 100vh;
}

h1, h2, h3 {
    margin-top: 0;
}

/* Centrage du titre et de la tagline (Accueil) */
.header-area {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 40px;
}

.header-area h1 {
    color: #007bff;
    font-size: 2.5em;
    margin: 0;
}

.tagline {
    color: #555;
    font-size: 1.1em;
    margin-top: 10px;
    text-align: center;
}

a {
    text-decoration: none;
    transition: 0.2s;
}

/* ==========================================================================
   2. MISE EN PAGE & CONTENEURS
   ========================================================================== */
.card,
.hero,
.login-card,
.recap-container {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    margin-top: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Masquage du lien public sous admin.php si vide */
.card.share-link {
    display: none;             /* Force le masquage même si .card dit d'afficher */
    background: #e9ecef;       /* Utilise le gris au lieu du blanc */
    border: 1px dashed #6c757d;
}

/* Bloc blanc principal (ajusté pour index.php) */
.hero {
    padding: 40px;
    border-radius: 20px;
    max-width: 800px;
    margin: 40px auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.login-card {
    max-width: 380px;
    margin: 40px auto;
    text-align: center;
}

/* Conteneur de récapitulatif (index.php?id=1) */
.recap-container {
    display: none;             /* Caché par défaut, affiché via JS ou PHP */
    margin-top: 20px;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   3. FORMULAIRES & STEPPER (sondage)
   ========================================================================== */
/* Style pour la description du sondage (index.php) */
.poll-description {
    background: #fff;
    color: #444;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto 15px auto; /* Centre horizontalement et ajoute une marge en bas */
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    text-align: center; 
}
.step {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.step.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

label {
    display: block;
    margin-top: 15px;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    margin-bottom: 5px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
}

/* Options radio personnalisées avec survol bleu */
.option-label {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #eee;
    margin-bottom: 10px;
    border-radius: 10px;
    cursor: pointer;
    gap: 12px; /* 👈 espace direct entre les éléments */
}
.option-label:hover {
    border-color: #2196f3;
    background: #f5faff;
}

.option-label input:checked + span {
    font-weight: 600;
    color: #1565c0;
}

.option-label input[type="radio"] {
    margin-right: 15px;
    transform: scale(1.2);
    flex-shrink: 0;
}

/* ==========================================================================
   4. BOUTONS
   ========================================================================== */
/* Base commune pour tous les éléments cliquables */
button,
.btn-main,
.btn-nav,
.btn-vote,
.btn-save,
.btn-action,
.btn-submit {
    background: #007bff;
    font-size: 0.85em;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 8px;
    transition: 0.2s;
    display: inline-block;
    text-align: center;
}

/* Spécificités pour les balises <button> uniquement */
button {
    width: auto;
    padding: 16px;
    color: white;
    border-radius: 10px;
}

button:hover,
.btn-action:hover,
.btn-submit:hover {
    opacity: 0.85;
}

/* Bouton principal pour les formulaires (register / reset) */
.btn-submit { 
    width: 100%; 
    padding: 12px; 
    margin-top: 15px; 
    color: white;
    font-size: 1rem;
}

/* Boutons de navigation du sondage */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.btn-main-supp {
    background:#6c757d;
}
.btn-nav {
    padding: 12px 25px;
    margin-top: 20px;
}

.btn-next {
    background: #007bff;
    color: white;
    float: right;
}

.btn-next:hover {
    background: #0056b3;
}

.btn-prev, .btn-cancel {
    background: #6c757d;
    color: white;
    float: left;
}
.btn-del {
    background: #ffc107; 
    color: #212529;
    float: left;
}
/* Assure que les boutons flottants ne cassent pas le layout */
.step::after {
    content: "";
    display: table;
    clear: both;
}

/* Bouton Voter (index.php) */
.btn-vote {
    background: #007bff;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    width: auto;
}
/* Bouton copier le lien (admins.php) */
.btn-copy-style {
    background: #6c757d;
    color: white;
    padding: 6px 12px;
    font-size: 0.8rem;
    width: auto;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}
#poll_url_link {
    word-break: break-all;
    overflow-wrap: break-word;
    color: #0056b3;
    text-decoration: underline;
    font-size: 0.95em;
    display: inline-block;
    margin-top: 10px;
}

#poll_url_link:hover {
    color: #003d7a;
}

/* ==========================================================================
   LISTE DES QUESTIONS (STYLE ALIGNÉ À DROITE)
   ========================================================================== */
.q-row {
    display: flex;
    flex-direction: row;      /* Côte à côte */
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.q-text {
    flex: 1;                  /* Le texte prend toute la place libre */
}

.q-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;           /* Empêche les boutons d'être écrasés */
}

.btn-edit, .btn-purge, .btn-delete {
    width: 85px;              /* LARGEUR FIXE : les 3 boutons sont identiques */
    text-align: center;
    padding: 8px 0;
    font-size: 0.85rem;
}

.btn-purge { background: #ffc107; color: #212529; }
.btn-delete { background: #6c757d;} 

/* Admin Footer (index.php) */
.admin-footer {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 40px;
}

.btn-admin {
    font-size: 0.85em;
    color: #999;
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 20px;
    background: white;
}

.btn-admin:hover {
    background: #eee;
    color: #333;
}

/* Masquer le bloc questions par défaut */
#questions_container_block {
    display: none;
}

/* ==========================================================================
   5. TABLEAUX & RÉSULTATS
   ========================================================================== */
/* On centre les petites icônes pour gagner en clarté */
.cell-center {
    text-align: center;
    width: 40px;
}

th, td {
    border: 1px solid #eee;
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

/* Barres de résultats */
.bar-container {
    background-color: #eee;
    border-radius: 4px;
    margin: 5px 0 15px 0;
    height: 12px;
    width: 100%;
}

.bar-fill {
    background-color: #007bff;
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.bar-label {
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
}

/* Progress bar du sondage */
.progress-bar {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    margin-bottom: 30px;
}

.progress-fill {
    height: 100%;
    background: #007bff;
    width: 0%;
    border-radius: 4px;
    transition: 0.3s;
}

/* Badge participants */
.voters-badge {
    background: #e7f3ff;
    color: #007bff;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9em;
    line-height: 1.4;
    display: inline-block;
}

/* Commentaires */
.comment-scroll {
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.85em;
    background: #fdfdfd;
    padding: 5px;
}

.comment-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 10px 15px;
    margin-bottom: 10px;
    position: relative;
}

.comment-user {
    display: block;
    font-weight: bold;
    font-size: 0.85em;
    color: #007bff;
    margin-bottom: 4px;
}

.comment-text {
    font-size: 0.95em;
    color: #333;
    line-height: 1.4;
}
/* Section des commentaires dans les résultats */
.comments-header {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
}

.comments-list {
    max-height: 150px;
    overflow-y: auto;
    padding-right: 5px; 
}

.comment-line {
    margin-bottom: 8px;
    border-left: 3px solid #007bff;
    padding-left: 10px;
    font-size: 0.85em;
    line-height: 1.4;
}

.comment-line strong {
    color: #333;
}

.comment-line .user-vote {
    color: #888;
    font-style: italic;
}

.comment-line .comment-text {
    color: #555;
    display: block; 
    margin-top: 2px;
}
/* ==========================================================================
   6. NAVIGATION & LIENS SPÉCIFIQUES
   ========================================================================== */
.accueil-link,
.admin-link {
    position: absolute;
    top: 10px;
    font-size: 0.8em;
    color: #6c757d;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 5px;
    background: white;
    z-index: 10;
}

.accueil-link {
    left: 15px;
}

.admin-link {
    right: 15px;
}

.admin-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Évite que les boutons ne sortent de l'écran */
}

.logout-link {
    color: #dc3545 !important;
    border: 2px solid #dc3545 !important;
}

/* Lien pour voir les résultats (index.php) */
.results-link {
    font-size: 0.9em;
    color: #007bff;
    text-decoration: underline;
    font-weight: bold;
    transition: color 0.2s; 
}

.results-link:hover {
    color: #0056b3; 
    text-decoration: none; 
}
.btn-navig {
    color: #6c757d;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    border: 1px solid #6c757d;
    padding: 5px 10px;
    border-radius: 6px;
    margin-right: 10px;
    display: inline-block;
}

.btn-navig:hover {
    background-color: #6c757d;
    color: white;
}
/*Class pour ajout espace au dessous ou en dessous */
.mt-10 {
    margin-top: 10px;
}
.mbt-10 {
    margin-bottom: 10px;
}
/* Poll Cards (index.php) */
.poll-card {
    background: #fff;
    border: 1px solid #ddd;
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: inherit;
}

.poll-card:hover {
    border-color: #007bff;
    background: #f0f7ff;
    transform: translateX(5px);
}

.poll-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: #000;
}

.poll-info span {
    font-size: 0.85em;
    color: #666;
}
.poll-closed {
    opacity: 0.65;
}

.poll-closed .btn-vote {
    background: #ccc !important;
    color: #555;
}

/* Features (index.php) */
.features {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.feat {
    flex: 1;
    text-align: center;
}

.feat strong {
    display: block;
    margin: 10px 0 5px 0;
    color: #333;
}

.feat p {
    font-size: 0.9em;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

.icon {
    font-size: 1.5em;
}

/* ==========================================================================
   7. MESSAGES & MODALES
   ========================================================================== */

.msg, .error {
    background: #d4edda;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
}

.success {
    background: #d4edda;
    color: #155724;
}

.error {
    background: #f8d7da;
    color: #721c24;
}

/* Modale Image Cliquable */
#imageModal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

#modalImg {
    max-width: 95%;
    max-height: 90%;
}

.poll-image {
    max-width: 250px;
    cursor: zoom-in;
    border-radius: 10px;
    border: 1px solid #ddd;
    margin-bottom: 15px;
    display: block;
}
/* Message de succès après enregistrement */
#success-message {
    background: #d4edda;
    color: #155724;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #c3e6cb;
    animation: slideDown 0.5s ease-out; 
}

#success-message strong {
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

/* ==========================================================================
   8. AUTHENTICATION & FORM HELPERS (Nouveaux ajouts)
   ========================================================================== */
.error-msg { 
    color: #d32f2f; 
    background: #ffebee; 
    padding: 10px; 
    border-radius: 5px; 
    margin-bottom: 15px; 
    border: 1px solid #ffcdd2; 
    font-size: 0.9em;
    text-align: left;
}

.success-box { 
    background: #e8f5e9; 
    color: #2e7d32; 
    padding: 20px; 
    border-radius: 10px; 
    border: 1px solid #c8e6c9; 
    text-align: center; 
    margin-bottom: 15px;
}

.password-hint { 
    display: block; 
    color: #666; 
    font-size: 0.75em; 
    margin-top: 5px; 
    line-height: 1.3; 
    margin-bottom: 10px; 
    text-align: left;
}

.footer-actions {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.footer-links {
    margin-top: 25px;
    border-top: 1px solid #eee;
    padding-top: 15px;
    text-align: center;
}
/* ==========================================================================
   9. TABLEAUX et ONGLETS (ADMIN)
   ========================================================================== */
.table-responsive {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    text-align: center; /* centrage horizontal */
}
/* On définit le centrage  pour les colonnes de droite */
.table-responsive th:nth-child(n+2):nth-child(-n+4),
.table-responsive td:nth-child(n+2):nth-child(-n+4) {
    text-align: center;
    vertical-align: middle;
}

/* Force le nom du fichier à aller à la ligne */
.filename {
    display: block;
    word-break: break-all; /* Coupe le texte n'importe où */
    font-size: 0.85rem;
    line-height: 1.2;
}

.filename { /* Nom du fichier de sauvegarde long */
    display: block;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

/* Fixer la largeur des colonnes d'action */
.col-status { width: 120px; text-align: center; }
.col-actions { width: 180px; text-align: right; }

/* Conteneur des onglets */
.tab-content {
    border: 1px solid #ddd;
    padding: 20px;
    border-radius: 0 8px 8px 8px;
    background: #fff;
    display: none;
}

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

.tabs-header { 
    display: flex; 
    gap: 5px; 
    margin-top: 20px;
}
/* Ciblage spécifique pour les onglets dans le header */
/* 1. Style de base (Inactif) */
.tabs-header .btn-navig {
    background-color: transparent;
    margin-right: 5px;
    /*margin-bottom: -1px;*/
    border: 1px solid #6c757d; /* */
    transition: 0.2s;
}

/* 2. Survol (Inactif uniquement) */
.tabs-header .btn-navig:hover {
    background-color: #6c757d; /* */
    color: white;
}

/* Paramétrage du sondage (2 colonnes) */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
}

/* 3. L'onglet ACTIF : Simplifié et désactivé */
.tabs-header .btn-navig.active {
    background-color: #ffffff !important;
    border: none !important;
    border-radius: 8px 8px 0 0;
    padding-bottom: 7px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    color: #6c757d !important;
    
    /* Désactivation complète du clic et du survol */
    pointer-events: none; 
    cursor: default;
}

/*Gestion des tags options de réponse */
.tags-input-container {
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    background: white;
}

.tag {
    background: #007bff;
    color: white;
    padding: 3px 8px;
    margin: 2px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    font-size: 14px;
}

.tag .remove-tag {
    margin-left: 8px;
    cursor: pointer;
    font-weight: bold;
}

#tag-input-field {
    border: none;
    outline: none;
    flex: 1;
    min-width: 150px;
    padding: 5px;
}
/* Badges de statut */

.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.badge-green {
    background: #d4edda;
    color: #155724;
}

.badge-red {
    background: #f8d7da;
    color: #721c24;
}
/*
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}
.badge-green { background: #e6fffa; color: #2dcc70; border: 1px solid #c3f3e1; }
.badge-red { background: #fff5f5; color: #e53e3e; border: 1px solid #fed7d7; }

/* Style des liens d'action dans le tableau */
.action-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #4a5568;
    background: #edf2f7;
    transition: 0.2s;
    margin-left: 5px;
}

.action-link:hover {
    background: #e2e8f0;
    color: #2d3748;
}

.action-link.view {
    background: #ebf8ff;
    color: #3182ce;
}

.action-link.view:hover {
    background: #bee3f8;
}

/* ==========================================================================
   10. MEDIA QUERIES (Mobile)
   ========================================================================== */
@media (max-width: 600px) {
.q-row {
        flex-direction: column; /* On empile verticalement */
        align-items: stretch;   /* Le texte et les boutons prennent 100% de large */
    }
    
    .q-actions {
        width: 100%;            /* Le groupe de boutons prend toute la largeur */
    }
    
    .btn-edit, .btn-purge, .btn-delete {
        flex: 1;                /* Ils se partagent la ligne 1/3 chacun */
        width: auto;            /* On annule les 85px pour remplir l'écran */
    }
  .poll-card, .features {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    .btn-next, .btn-prev {
        float: none;
        width: 100%;
        margin-bottom: 10px;
    }
    .hero {
        padding: 20px;
        margin-top: 20px;
    }
    .admin-link, .accueil-link {
        position: static;
        display: block;
        margin: 10px auto;
        width: fit-content;
    }
.admin-actions {
        justify-content: center; /* Centre les boutons sur mobile */
        width: 100%;
    }
/*Paramétrages des sondages sur une colonne */ 
    .settings-grid {
        display: block !important; /* Désactive la grille */
    }

    .settings-grid > div {
        width: 100%;
        margin-bottom: 15px; /* Recrée l'espace entre les champs */
    }

    .settings-grid > div:last-child {
        margin-bottom: 0;
    }
}
