/* Variables */
:root {
    --primary:    #8ED2C1;
    --secondary:  #E096A4;
    --accent:     #FFE8C6;
    --bg:         #FEF7E5;
    --text:       #4B5563;
    --border:     #E5E7EB;
    --radius-card: 12px;
    --radius-btn:  8px;
    --shadow:     0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Lato', Inter, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    color: var(--text);
}

h1 em, h2 em {
    font-style: normal;
    color: var(--secondary);
}

/* Layout */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.site-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text);
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
}

.site-title img {
    height: 36px;
    width: auto;
}

.header-user-count {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
}
.header-user-count svg {
    flex-shrink: 0;
}

.site-title em {
    font-style: normal;
    color: var(--secondary);
}

/* Typographie */
p { line-height: 1.6; margin-bottom: 1rem; }
h1 { font-size: 1.8rem; margin-bottom: 1rem; }
a { color: var(--primary); }

/* Boutons */
button, .btn {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.6em 1.4em;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow);
    transition: opacity 0.15s;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

button:hover { opacity: 0.9; }

button[id="btn-reveal"]   { background: var(--secondary); }
button[id="btn-revote"]   { background: var(--secondary); }
button[id="btn-new-vote"] { background: var(--text); }
button[id="btn-reset"]    { background: #ccc; color: var(--text); }

/* Formulaire */
form { margin: 1.5rem 0; }

label {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

select:disabled { opacity: 0.4; cursor: not-allowed; }

select {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    padding: 0.4em 0.8em;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    background: #fff;
    color: var(--text);
}

/* QR code & lien */
img[alt="QR code"] {
    display: block;
    margin: 1rem 0;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    max-width: 350px;
}

/* Compteur participants */
#user-count {
    font-weight: 700;
    color: var(--primary);
}

/* Cartes de vote */
ul.card-list, ul#card-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 0;
}

.card-btn {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.8em 1.4em;
    background: var(--accent);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    margin: 0;
}

.card-btn:hover { border-color: var(--primary); }

.card-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Tableau votes admin */
.votes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}
.votes-table thead th {
    text-align: left;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    padding: 0 0.5rem 0.5rem;
    border-bottom: 2px solid var(--border);
}
.votes-table tbody tr {
    border-bottom: 1px solid var(--border);
}
.votes-table tbody tr:last-child {
    border-bottom: none;
}
.votes-card {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.55rem 0.5rem;
    width: 3rem;
}
.votes-nb {
    padding: 0.55rem 0.5rem;
    width: 2rem;
    text-align: right;
}
.votes-bar-cell {
    padding: 0.55rem 0.5rem;
    width: 100%;
}
.votes-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.votes-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}

tr.no-votes .votes-card,
tr.no-votes .votes-nb  { color: #bbb; }
tr.has-votes .votes-card { color: var(--text); }
tr.has-votes .votes-nb strong { color: var(--primary); font-size: 1.15rem; }

/* Aperçu du deck */
#deck-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0 1.25rem;
    padding-top: 0.5rem;
}

.card-toggle {
    cursor: pointer;
    position: relative;
    display: inline-block;
}
.card-toggle input[type=checkbox] {
    display: none;
}

/* Badge ✓ / ✗ en coin */
.card-toggle::after {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    background: #4ade80;
    color: #fff;
    font-weight: 700;
    transition: background 0.15s, content 0.15s;
    pointer-events: none;
}
.card-toggle:has(input:not(:checked))::after {
    content: '✕';
    background: #f87171;
}

/* Hover : préview de ce que fera le clic */
.card-toggle:has(input:checked):hover::after {
    content: '✕';
    background: #f87171;
}
.card-toggle:has(input:not(:checked)):hover::after {
    content: '✓';
    background: #4ade80;
}

.card-toggle input[type=checkbox]:not(:checked) + .card-preview {
    opacity: 0.4;
}

.card-preview {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.4em 0.9em;
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    color: var(--text);
    transition: opacity 0.15s, box-shadow 0.15s;
}
.card-toggle:hover .card-preview {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* Header right zone */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    align-self: center;
}

/* Share bar */
.share-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 12px;
    margin-bottom: 0.5rem;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 0.45em 0.9em;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--primary);
    font-family: 'Lato', sans-serif;
    transition: background 0.15s;
}
.btn-copy:hover { background: #e8f7f3; }
.copy-icon { font-size: 1.1rem; flex-shrink: 0; }

.btn-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 0.45em 0.6em;
    cursor: pointer;
    color: var(--text);
    transition: background 0.15s;
    flex-shrink: 0;
}
.btn-qr:hover { background: #e8f7f3; color: var(--primary); }

.user-count { margin: 0.25rem 0 1rem; font-size: 0.95rem; }

/* Modale QR */
.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.qr-modal-box {
    position: relative;
    background: #fff;
    border-radius: 1.2rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    max-width: 90vw;
}
.qr-modal-img {
    width: min(85vw, 350px);
    height: auto;
    display: block;
    margin: 0 auto 1rem;
}
.qr-modal-url {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 1.2rem;
    word-break: break-all;
}
.qr-modal-close {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-card);
    padding: 0.5em 1.5em;
    cursor: pointer;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
}

/* Selector deck inline */
.deck-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
}

/* Section votes admin */
#votes { margin-top: 1.5rem; }

/* Composant votes_admin */
div[id="votes_admin"] {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1rem 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

/* Attente */
#voting p:first-child { color: var(--text); font-style: italic; }
