/* =========================================================
   Votons - Front CSS
   ========================================================= */

/* ---------------------------------------------------------
   Variables
   --------------------------------------------------------- */
:root {
    --cfdt-orange: #FF7900;
    --cfdt-orange-dark: #e06600;
    --cfdt-orange-soft: #fff7ed;
    --cfdt-orange-border: #ffd2a6;

    --cfdt-text: #111827;
    --cfdt-text-soft: #4b5563;
    --cfdt-text-muted: #6b7280;

    --cfdt-bg: #ffffff;
    --cfdt-bg-soft: #fafafa;
    --cfdt-bg-panel: #f8fafc;

    --cfdt-border: #e5e7eb;
    --cfdt-border-strong: #d1d5db;

    --cfdt-success-bg: #e6f5e6;
    --cfdt-success-border: #33aa33;
    --cfdt-success-text: #2d662d;

    --cfdt-error-bg: #fff3f2;
    --cfdt-error-border: #cc0000;
    --cfdt-error-text: #991b1b;

    --cfdt-neutral-bg: #f3f4f6;
    --cfdt-neutral-border: #9ca3af;
    --cfdt-neutral-text: #4b5563;

    --cfdt-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
    --cfdt-shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
    --cfdt-shadow-lg: 0 6px 18px rgba(0, 0, 0, 0.08);

    --cfdt-radius-sm: 6px;
    --cfdt-radius-md: 10px;
    --cfdt-radius-lg: 12px;
}

/* ---------------------------------------------------------
   Sécurité d'affichage
   --------------------------------------------------------- */
[hidden] {
    display: none !important;
}

/* ---------------------------------------------------------
   Bloc principal
   --------------------------------------------------------- */
.cfdtvote-form,
form[id^="cfdtvote-form-"] {
    background: var(--cfdt-bg);
    border: 2px solid #e0e0e0;
    padding: 20px;
    margin: 20px auto;
    width: 100%;
    max-width: none;
    border-radius: var(--cfdt-radius-lg);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    box-shadow: var(--cfdt-shadow-sm);
    box-sizing: border-box;
    color: var(--cfdt-text);
}

/* ---------------------------------------------------------
   Titres
   --------------------------------------------------------- */
.cfdtvote-form h2,
.cfdtvote-form h3 {
    color: var(--cfdt-orange);
    font-weight: 700;
    margin: 0 0 10px;
    border-bottom: 4px solid #f2f2f2;
    padding-bottom: 6px;
}

/* ---------------------------------------------------------
   Zone haute / grilles génériques
   --------------------------------------------------------- */
.cfdtvote-form-top {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.cfdtvote-questions {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cfdtvote-token-step,
.cfdtvote-identity-summary,
.cfdtvote-vote-step,
.cfdtvote-election-meta,
.cfdtvote-election-summary {
    margin-bottom: 20px;
}

/* ---------------------------------------------------------
   Groupes de champs
   --------------------------------------------------------- */
.cfdtvote-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.cfdtvote-input-group label {
    display: block;
    margin-top: 0;
    font-weight: 700;
    color: #333;
    width: 100%;
}

/* ---------------------------------------------------------
   Champs
   --------------------------------------------------------- */
.cfdtvote-form input[type="text"],
.cfdtvote-form input[type="number"],
.cfdtvote-form input[type="url"],
.cfdtvote-form input[type="date"],
.cfdtvote-form select,
.cfdtvote-form textarea {
    width: 100%;
    padding: 10px;
    margin-top: 0;
    border: 1px solid #ccc;
    border-radius: var(--cfdt-radius-sm);
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
    background: #fff;
    color: var(--cfdt-text);
}

.cfdtvote-form input[type="text"]:focus,
.cfdtvote-form input[type="number"]:focus,
.cfdtvote-form input[type="url"]:focus,
.cfdtvote-form input[type="date"]:focus,
.cfdtvote-form select:focus,
.cfdtvote-form textarea:focus {
    outline: none;
    border-color: var(--cfdt-orange);
    box-shadow: 0 0 0 3px rgba(255, 121, 0, 0.15);
}

/* ---------------------------------------------------------
   Boutons
   --------------------------------------------------------- */
.cfdtvote-form button,
.cfdtvote-form input[type="submit"] {
    background-color: var(--cfdt-orange);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--cfdt-radius-sm);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform .08s ease, opacity .15s ease;
    margin-top: 5px;
}

.cfdtvote-form button:hover,
.cfdtvote-form input[type="submit"]:hover {
    background-color: var(--cfdt-orange-dark);
}

.cfdtvote-form button:active,
.cfdtvote-form input[type="submit"]:active {
    transform: translateY(1px);
}

.cfdtvote-form button:disabled,
.cfdtvote-form input[type="submit"]:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ---------------------------------------------------------
   Checkbox / radio
   --------------------------------------------------------- */
.cfdtvote-form label {
    color: #333;
}

.cfdtvote-form input[type="checkbox"],
.cfdtvote-form input[type="radio"] {
    margin-right: 8px;
}

/* ---------------------------------------------------------
   Réponses / messages
   --------------------------------------------------------- */
.cfdtvote-form .cfdtvote-response,
.cfdtvote-token-response {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--cfdt-radius-sm);
    background-color: #f9f9f9;
    border-left: 4px solid var(--cfdt-orange);
    font-size: 16px;
    line-height: 1.45;
}

/* Masquer les blocs de message vides pour éviter les barres fantômes */
.cfdtvote-form .cfdtvote-response:empty,
.cfdtvote-token-response:empty {
    display: none;
}

.cfdtvote-form .cfdtvote-response.cfdtvote-error,
.cfdtvote-token-response.cfdtvote-error {
    background: var(--cfdt-error-bg);
    border-left-color: var(--cfdt-error-border);
    color: var(--cfdt-error-text);
}

.cfdtvote-form .cfdtvote-response.cfdtvote-success,
.cfdtvote-token-response.cfdtvote-success {
    background: var(--cfdt-success-bg);
    border-left-color: var(--cfdt-success-border);
    color: var(--cfdt-success-text);
}

.cfdtvote-section-lock-message,
.cfdtvote-question-lock-message,
.cfdtvote-election-section-lock-message,
.cfdtvote-election-exclusion-message,
.cfdtvote-election-status-message,
.cfdtvote-question-exclusion-message {
    margin: 12px 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--cfdt-error-bg);
    border-left: 4px solid var(--cfdt-error-border);
    color: var(--cfdt-error-text);
    font-weight: 600;
}

/* ---------------------------------------------------------
   Tableau
   --------------------------------------------------------- */
.cfdtvote-form table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.cfdtvote-form table th,
.cfdtvote-form table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: top;
}

.cfdtvote-form table th {
    background-color: #f2f2f2;
    color: var(--cfdt-orange);
}

.cfdtvote-form table.cfdtvote-results-table {
    border: 3px solid var(--cfdt-orange);
}

/* ---------------------------------------------------------
   Résultats
   --------------------------------------------------------- */
.cfdtvote-result-ok {
    background-color: var(--cfdt-success-bg);
    border-left: 5px solid var(--cfdt-success-border);
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--cfdt-radius-sm);
    color: var(--cfdt-success-text);
    font-weight: 700;
}

.cfdtvote-result-ko {
    background-color: #fbeaea;
    border-left: 5px solid #cc0000;
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--cfdt-radius-sm);
    color: #aa0000;
    font-weight: 700;
}

.cfdtvote-result-neutral {
    background-color: var(--cfdt-neutral-bg);
    border-left: 5px solid var(--cfdt-neutral-border);
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--cfdt-radius-sm);
    color: var(--cfdt-neutral-text);
    font-weight: 700;
}

.cfdtvote-result-card {
    margin-top: 20px;
}

.cfdtvote-result-card-status {
    margin: 12px 0 18px;
}

.cfdtvote-result-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 14px;
}

.cfdtvote-result-card-grid > div {
    background: var(--cfdt-bg-soft);
    border: 1px solid var(--cfdt-border);
    border-radius: var(--cfdt-radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cfdtvote-result-card-label {
    font-size: 0.9rem;
    color: var(--cfdt-text-muted);
    font-weight: 600;
}

.cfdtvote-result-card-grid strong {
    font-size: 1.1rem;
    color: var(--cfdt-text);
}

.cfdtvote-result-card-compact .cfdtvote-result-card-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
}

/* ---------------------------------------------------------
   Bloc récapitulatif identité
   --------------------------------------------------------- */
.cfdtvote-identity-summary,
.cfdtvote-election-summary,
.cfdtvote-election-meta {
    background: var(--cfdt-bg-panel);
    border: 1px solid var(--cfdt-border);
    border-radius: var(--cfdt-radius-lg);
    padding: 16px;
}

.cfdtvote-identity-comment {
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--cfdt-orange-soft);
    border-left: 4px solid var(--cfdt-orange);
    border-radius: var(--cfdt-radius-sm);
}

.cfdtvote-identity-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 12px;
}

.cfdtvote-identity-item {
    background: #ffffff;
    border: 1px solid var(--cfdt-border);
    border-radius: var(--cfdt-radius-md);
    padding: 12px;
}

.cfdtvote-identity-label {
    display: block;
    font-size: 0.92rem;
    color: var(--cfdt-text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.cfdtvote-identity-value {
    font-size: 1rem;
    color: var(--cfdt-text);
}

/* ---------------------------------------------------------
   Questions classiques
   --------------------------------------------------------- */
.cfdtvote-form fieldset {
    position: relative;
    margin: 0 0 14px 0;
    padding: 18px 16px 16px;
    border: 2px solid #f0f0f0;
    border-radius: var(--cfdt-radius-lg);
    background: #fffdf8;
    box-shadow: var(--cfdt-shadow-md);
    overflow: hidden;
    transition: box-shadow .2s ease, border-color .2s ease, opacity .2s ease;
}

.cfdtvote-form fieldset::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: rgba(255, 121, 0, 0.35);
}

.cfdtvote-form fieldset:hover {
    border-color: var(--cfdt-orange-border);
    box-shadow: var(--cfdt-shadow-lg);
}

.cfdtvote-form fieldset legend {
    display: inline-block;
    margin: 0 0 12px 0;
    padding: 4px 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--cfdt-orange);
    background: #fff;
    border: 1px solid var(--cfdt-orange-border);
    border-radius: 8px;
    line-height: 1.2;
    border-bottom: 0 !important;
}

.cfdtvote-input-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr));
    gap: 14px;
}

.cfdtvote-form fieldset label {
    margin-top: 0;
}

.cfdtvote-question-disabled,
.cfdtvote-question-prelocked {
    opacity: 0.7;
    background: #f8f8f8 !important;
    border-color: #e2e2e2 !important;
    box-shadow: none !important;
}

.cfdtvote-question-disabled::before,
.cfdtvote-question-prelocked::before {
    background: rgba(120, 120, 120, 0.25);
}

.cfdtvote-question-disabled input[type="number"],
.cfdtvote-question-prelocked input[type="number"] {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

.cfdtvote-form-section-locked {
    opacity: 0.95;
}

.cfdtvote-sum-hint {
    font-size: 13px;
    margin-top: 8px;
    line-height: 1.35;
}

.cfdtvote-sum-hint.sum-ok {
    color: #16a34a;
    font-weight: 600;
}

.cfdtvote-sum-hint.sum-ko {
    color: #b91c1c;
    font-weight: 600;
}

/* ---------------------------------------------------------
   Élections / candidats
   Hiérarchie visuelle :
   1. identité forte
   2. fiche profil lisible
   3. zone d’action séparée
   --------------------------------------------------------- */
.cfdtvote-election-candidate-block {
    background: linear-gradient(180deg, #fffefb 0%, #ffffff 100%);
    border-color: #f2e8da;
}

/* Structure générale du candidat :
   photo à gauche, contenu à droite */
.cfdtvote-candidate-card {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    width: 100%;
}

/* Colonne photo */
.cfdtvote-candidate-photo-wrap {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.cfdtvote-candidate-photo {
    width: 148px;
    height: 148px;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--cfdt-border);
    background: #fff;
    box-shadow: var(--cfdt-shadow-md);
}

/* Si aucune photo n'est affichée, la fiche repasse automatiquement sur une seule colonne */
.cfdtvote-candidate-card:not(:has(.cfdtvote-candidate-photo-wrap:not([hidden]))) {
    grid-template-columns: minmax(0, 1fr);
}

/* Colonne principale */
.cfdtvote-candidate-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    width: 100%;
}

/* Nom du candidat : élément dominant visuel */
.cfdtvote-candidate-name {
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: 0.1px;
    color: var(--cfdt-orange);
}

/* Métadonnées en badges premium */
.cfdtvote-candidate-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
}

.cfdtvote-candidate-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #e7eaf0;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 0.95rem;
    color: var(--cfdt-text-soft);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cfdtvote-candidate-meta-item .cfdtvote-identity-label {
    display: inline;
    margin-bottom: 0;
    font-size: 0.82rem;
    color: var(--cfdt-text-muted);
    font-weight: 700;
}

.cfdtvote-candidate-meta-item strong {
    color: var(--cfdt-text);
    font-weight: 700;
}

/* Description : vraie fiche profil */
.cfdtvote-candidate-description {
    width: 100%;
    color: var(--cfdt-text-soft);
    line-height: 1.65;
    background: #fffdfa;
    border: 1px solid #efe7db;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Zone de décision : panneau distinct */
.cfdtvote-candidate-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 170px);
    gap: 16px 18px;
    align-items: start;
    width: 100%;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid var(--cfdt-border);
    border-radius: 14px;
    box-shadow: var(--cfdt-shadow-sm);
    box-sizing: border-box;
}

.cfdtvote-candidate-controls .cfdtvote-input-group {
    margin: 0;
    gap: 8px;
}

.cfdtvote-candidate-controls .cfdtvote-input-group label {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--cfdt-text-soft);
}

.cfdtvote-candidate-position-select,
.cfdtvote-candidate-allocation-input {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 46px;
    font-weight: 600;
    box-sizing: border-box;
}

.cfdtvote-candidate-help {
    grid-column: 1 / -1;
    font-size: 0.92rem;
    color: var(--cfdt-text-muted);
    line-height: 1.5;
    padding: 12px 14px;
    background: #fffaf3;
    border: 1px dashed var(--cfdt-orange-border);
    border-radius: 12px;
    box-sizing: border-box;
}

.cfdtvote-candidate-help strong {
    color: var(--cfdt-orange-dark);
}

/* ---------------------------------------------------------
   Récapitulatif de répartition
   --------------------------------------------------------- */
.cfdtvote-election-title {
    margin-bottom: 10px;
}

.cfdtvote-election-description {
    color: var(--cfdt-text-soft);
    line-height: 1.55;
}

.cfdtvote-election-summary .cfdtvote-identity-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.cfdtvote-election-confirmation-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--cfdt-orange-soft);
    border: 1px solid var(--cfdt-orange-border);
    border-left: 4px solid var(--cfdt-orange);
    border-radius: var(--cfdt-radius-md);
    color: var(--cfdt-text);
    line-height: 1.45;
}

.cfdtvote-election-confirmation-box.cfdtvote-warning {
    background: #fff7ed;
}

.cfdtvote-election-confirmation-box.cfdtvote-error {
    background: var(--cfdt-error-bg);
    border-color: #f5b5b5;
    border-left-color: var(--cfdt-error-border);
    color: var(--cfdt-error-text);
}

/* ---------------------------------------------------------
   Utilitaires
   --------------------------------------------------------- */
.cfdtvote-copy-email-btn {
    margin-bottom: 4px;
}

/* ---------------------------------------------------------
   Responsive intermédiaire
   --------------------------------------------------------- */
@media (max-width: 1100px) {
    .cfdtvote-candidate-card {
        grid-template-columns: 130px minmax(0, 1fr);
        gap: 18px;
    }

    .cfdtvote-candidate-card:not(:has(.cfdtvote-candidate-photo-wrap:not([hidden]))) {
        grid-template-columns: minmax(0, 1fr);
    }

    .cfdtvote-candidate-photo {
        width: 128px;
        height: 128px;
    }

    .cfdtvote-candidate-controls {
        grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px);
    }

    .cfdtvote-candidate-help {
        grid-column: 1 / -1;
    }
}

/* ---------------------------------------------------------
   Mobile / tablette
   --------------------------------------------------------- */
@media (max-width: 900px) {
    .cfdtvote-input-grid,
    .cfdtvote-identity-grid,
    .cfdtvote-election-summary .cfdtvote-identity-grid {
        grid-template-columns: 1fr;
    }

    .cfdtvote-result-card-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .cfdtvote-candidate-card {
        grid-template-columns: 1fr;
    }

    .cfdtvote-candidate-photo-wrap {
        justify-content: flex-start;
    }

    .cfdtvote-candidate-photo {
        width: 108px;
        height: 108px;
    }

    .cfdtvote-candidate-controls {
        grid-template-columns: 1fr;
    }

    .cfdtvote-candidate-help {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .cfdtvote-form,
    form[id^="cfdtvote-form-"] {
        padding: 16px;
    }

    .cfdtvote-form-top {
        grid-template-columns: 1fr;
    }

    .cfdtvote-form table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .cfdtvote-form button,
    .cfdtvote-form input[type="submit"] {
        width: 100%;
    }

    .cfdtvote-candidate-allocation-input,
    .cfdtvote-candidate-position-select {
        max-width: none;
    }
}

@media (max-width: 560px) {
    .cfdtvote-result-card-grid,
    .cfdtvote-result-card-compact .cfdtvote-result-card-grid {
        grid-template-columns: 1fr;
    }

    .cfdtvote-candidate-photo {
        width: 90px;
        height: 90px;
    }
}