:root {
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --primary-color: #4f46e5; /* neutre — écrasé par branding.js (TENANT_PRIMARY_COLOR) */
    --primary-hover: #4338ca; /* dérivé assombri — recalculé par branding.js */
    --primary-faint: rgba(79, 70, 229, 0.05); /* fond léger — recalculé par branding.js */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
}

/* Mode admin : viewport plus large pour exploiter l'écran desktop.
   Les vues participant et projecteur restent en 600px (mobile-friendly). */
body.admin-mode #app {
    max-width: 1280px;
}

@media (min-width: 1024px) {
    /* Layout 2 colonnes pour la "Gestion globale" : infos à gauche, actions à droite */
    body.admin-mode .global-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        align-items: start;
    }
    /* Grille de cartes pour les questions */
    body.admin-mode .questions-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
        gap: 16px;
    }
    /* Liste émargements : conserver le layout vertical mais densifier
       (les rows sont déjà flex en interne, on profite juste de la largeur) */
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    width: 90px;
    height: 90px;
    margin: 0 auto 12px auto;
    display: block;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(209, 21, 102, 0.25);
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    color: #1e1b4b; /* navy neutre (indigo très foncé) */
}

p.subtitle {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--surface-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin-bottom: 12px;
}

/* :hover gated par @media (hover: hover) pour éviter l'effet "sticky hover"
   sur mobile : iOS Safari et Android Chrome simulent un hover après un tap
   qui reste collé jusqu'à un tap ailleurs. Sur un vote en plusieurs questions,
   ça donnait un bouton déjà pré-coloré sur Q2 = suggestion involontaire. */
@media (hover: hover) {
    .btn:hover {
        background-color: var(--primary-color);
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(209, 21, 102, 0.2);
    }
}

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

.btn-primary {
    background-color: #1e1b4b; /* Navy */
    border-color: #1e1b4b;
    color: white;
}

@media (hover: hover) {
    .btn-primary:hover {
        background-color: #2b2766;
        border-color: #2b2766;
        color: white;
    }
}

.btn-success { background-color: var(--success-color); border-color: var(--success-color); color: white; }
@media (hover: hover) {
    .btn-success:hover { background-color: #2ea043; border-color: #2ea043; }
}

.question-text {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Results Bars */
.result-item {
    margin-bottom: 1rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background-color: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%; /* Dynamic */
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Admin lists */
.admin-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.admin-question:last-child {
    border-bottom: none;
}
.admin-controls button {
    padding: 6px 12px;
    margin-left: 8px;
    font-size: 0.9rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}
.badge.active { background-color: rgba(35, 134, 54, 0.2); color: #3fb950; }
.badge.closed { background-color: rgba(218, 54, 51, 0.2); color: #ff7b72; }
.badge.draft { background-color: rgba(139, 148, 158, 0.2); color: #8b949e; }

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
    margin: 40px auto;
    display: block;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.status-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.input-field {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.05rem;
    font-family: inherit;
    background-color: #f8fafc;
    color: var(--text-primary);
}

@media (max-width: 600px) {
    .admin-question {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }
    .admin-controls {
        justify-content: center;
        width: 100%;
    }
    .admin-controls button {
        margin: 4px;
    }
}

/* Onglets admin */
.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
    overflow-x: auto;
}
.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
    .tab-btn:hover {
        color: var(--primary-color);
    }
}
.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.admin-logout-btn {
    margin-left: auto;
    align-self: center;
    width: auto;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    margin-bottom: 8px;
    flex-shrink: 0;
}
@media (hover: hover) {
    .admin-logout-btn:hover {
        color: var(--text-primary);
        background-color: var(--bg-color);
        border-color: var(--text-secondary);
        transform: none;
        box-shadow: none;
    }
}

/* Modal de question */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--surface-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal-content h3 {
    margin-bottom: 16px;
    color: #1e1b4b;
}
.modal-content label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
}
.modal-content textarea {
    resize: vertical;
    min-height: 70px;
}
.choice-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.choice-row input {
    flex: 1;
    margin-bottom: 0;
}
.choice-row .remove-choice {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    flex-shrink: 0;
}
.choice-row .remove-choice:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.modal-actions .btn {
    margin-bottom: 0;
}

/* Carte question (vue Gérer) */
.question-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--surface-color);
}
.question-card-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
}
.question-card-text {
    font-weight: 600;
    flex: 1;
}
.question-card-choices {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}
.question-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.question-card-actions button {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    cursor: pointer;
}
@media (hover: hover) {
    .question-card-actions button:hover {
        background: var(--bg-color);
    }
}
.question-card-actions button.action-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.question-card-actions button.action-danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}
