@import url('https://fonts.googleapis.com/css2?family=Fascinate&family=Playwrite+DE+Grund:wght@100..400&display=swap');



:root {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-tint: #2a2a45;
    --bg: #0f1115;
    --card-bg: #1a1d24;
    --card-bg-alt: #21252e;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --success: #34d399;
    --success-tint: #10241c;
    --danger: #f87171;
    --danger-tint: #2c1518;
    --border: #2d323c;
    --radius: 14px;
    --navbar-height: 61px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

code {
    background: var(--card-bg-alt);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85em;
}

/* ===== Scrollbars personnalisées (vertical + horizontal) ===== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--card-bg-alt);
}
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: var(--card-bg-alt);
    border-radius: 10px;
}
*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
    border: 2px solid var(--card-bg-alt);
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
*::-webkit-scrollbar-corner {
    background: var(--card-bg-alt);
}

/* ===== Navbar (mobile-first : logo + burger, menu déroulant) ===== */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.navbar .brand {
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
    
    font-family: "Fascinate", system-ui;
    font-weight: 400;
    font-style: normal;
}

.nav-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.2rem;
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text);
}

.nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin-top: 12px;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.nav-links.open { display: flex; }

.nav-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 4px;
}

.nav-links a:hover { color: var(--primary); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    padding: 6px 4px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.avatar.sm { width: 26px; height: 26px; font-size: 0.9rem; }
.avatar.xs { width: 22px; height: 22px; font-size: 0.75rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.8rem; }

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    padding: 3px;
    box-sizing: border-box;
}

/* ===== Layout ===== */
.container {
    max-width: 960px;
    margin: 16px auto;
    padding: 0 12px;
}

.card {
    background: transparent;
    padding: 0px;
    margin-bottom: 18px;
}

h1 { font-size: 1rem; }
h2 { font-size: 0.9rem; }
h3 { font-size: 0.8rem; }
h1, h2, h3 { margin-top: 0; }

.muted-text { color: var(--muted); font-size: 0.9rem; }
.section-sub { margin-top: 18px; }

.auth-card { max-width: 460px; margin: 0 auto; }
.auth-switch { margin-top: 16px; }

/* ===== Boutons & formulaires ===== */
.btn {
    display: inline-block;
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    text-align: center;
}

.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #14161c; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: #0b1f16; }
.btn-danger { background: var(--danger); color: #2c0d0d; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
    margin-top: 4px;
    background: var(--card-bg-alt);
    color: var(--text);
}

textarea {
    resize: none;
    height: 44px;
    max-height: 120px;
    font-size: 1rem;
    line-height: 1.4;
    overflow-y: hidden;
    font-family: inherit;
    margin-top: 0;
}

textarea::placeholder {
    font-family: inherit;
    font-size: 1rem;
    font-weight: normal;
    letter-spacing: normal;
    color: var(--text);
    opacity: 0.5;
}
textarea:focus { outline: none; border-color: var(--primary); }


.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gif-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
    max-height: 60vh;
    overflow-y: auto;
}

.gif-results img {
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}

input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--primary); }

label { font-weight: 600; font-size: 0.9rem; color: var(--muted); }

.form-group { margin-bottom: 16px; }

.alert {
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error { background: var(--danger-tint); color: #fca5a5; border: 1px solid #4c1d1d; }
.alert-success { background: var(--success-tint); color: #6ee7b7; border: 1px solid #14532d; }

/* ===== Participants (utilisé sur la page stats / classement) ===== */
.participant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.participant-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-tint);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.participant-pill.pill-muted { background: var(--danger-tint); }

/* ===== Tableaux (scroll horizontal sur mobile) ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 460px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem; white-space: nowrap; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; }

/* ===== Sondage de vote façon WhatsApp ===== */
.poll { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }

.poll-option {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--card-bg-alt);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    font: inherit;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.poll-option:hover { border-color: var(--primary); }

.poll-option.selected {
    border-color: var(--primary);
    background: var(--primary-tint);
}

.poll-option-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.65rem;
}

.poll-option-label { 
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;

}

.poll-option-pct {
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
    margin-left: 10px;
}

.poll-option-avatars {
    flex-shrink: 0;
    margin-left: 10px;
    min-height: 22px;
    display: flex;
    align-items: center;
}

.poll-bar-bg {
    background: #33394a;
    border-radius: 999px;
    height: 5px;
    overflow: hidden;
}

.poll-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.poll-bar-oui { background: var(--success); }
.poll-bar-non { background: var(--danger); }

.poll-option-count {
    font-size: 0.65rem;
    color: var(--muted);
}

.poll-option-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    text-align: center;
    
}

.poll-voters {
    display: flex;
    align-items: center;
}

.poll-voters .avatar {
    border: 2px solid var(--card-bg-alt);
    margin-left: -8px;
}

.poll-voters .avatar:first-child { margin-left: 0; }

.poll-voters-more {
    background: #454b5c !important;
    color: #e5e7eb;
    font-weight: 700;
    font-size: 0.65rem;
}

.poll-details-btn {
    margin-top: 6px;
    padding: 5px 8px;
}

/* ===== Détail des votes (feuille modale façon WhatsApp) ===== */
.poll-details-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}

.poll-details-overlay.open {
    display: flex;
}

.poll-details-sheet {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 78vh;
    max-height: 78dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
    animation: poll-sheet-in 0.2s ease-out;
}

@keyframes poll-sheet-in {
    from { transform: translateY(24px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.poll-details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 8px;
    flex-shrink: 0;
}

.poll-details-header h2 {
    margin: 0;
}

.poll-details-close {
    background: var(--card-bg-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
}
.poll-details-close:hover { border-color: var(--primary); color: var(--primary); }

.poll-details-tabs {
    display: flex;
    gap: 6px;
    padding: 0 18px 10px;
    flex-shrink: 0;
}

.poll-details-tab {
    flex: 1;
    background: var(--card-bg-alt);
    border: 1.5px solid var(--border);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.poll-details-tab.active {
    border-color: var(--primary);
    color: var(--text);
    background: var(--primary-tint);
}

.poll-details-body {
    overflow-y: auto;
    padding: 4px 8px 18px;
}

.poll-details-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.poll-details-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 10px;
}

.poll-details-item:hover {
    background: var(--card-bg-alt);
}

.poll-details-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.poll-details-empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 20px 10px;
    text-align: center;
}

/* ===== Chat ===== */
#chat-messages {
    height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
    background: var(--card-bg-alt);
    border-radius: 10px;
    border: 1px solid var(--border);
    flex: 1;
}
.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.chat-msg.mine {
    flex-direction: row-reverse;
    text-align: right;
}

.chat-msg .bubble {
    max-width: 75%;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 8px 12px;
}

.chat-msg.mine .bubble {
    background: var(--accent, var(--primary-tint));
    color: #fff;
}
.chat-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 3px; }
.chat-msg img.embed { max-width: 200px; border-radius: 8px; margin-top: 6px; display: block; }
.chat-msg a { color: var(--primary); word-break: break-all; }

#chat-form { display: flex; gap: 8px; margin-top: 12px; }
#chat-form input { flex: 1; margin-top: 0; }

.hide-on-small { display: none; }

/* ===== Sélecteurs emoji / couleur ===== */
.emoji-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; max-height: 260px; overflow-y: auto; padding: 4px; }
.emoji-option {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer; border: 2px solid transparent;
    background: var(--card-bg-alt); overflow: hidden;
}
.emoji-option img { width: 100%; height: 100%; object-fit: contain; padding: 4px; box-sizing: border-box; }
.emoji-option.selected { border-color: var(--primary); background: var(--primary-tint); }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.color-option {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent;
}
.color-option.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--card-bg) inset; }

/* ===== Graphiques ===== */
.chart-wrap { position: relative; height: 240px; }

canvas { max-width: 100%; }

/* ===== Page chat en plein écran (accueil) ===== */
body.page-chat {
    display: flex;
    flex-direction: column;
    /* 100vh sert de repli pour les vieux navigateurs, mais inclut la barre
       d'adresse mobile qui apparaît/disparaît (Chrome Android notamment).
       100dvh (dynamic viewport height) suit la taille réelle visible. */
    height: 100vh;
    height: 100dvh;
    /* Repli JS supplémentaire via --app-height (voir header.php) pour les
       navigateurs qui ne supportent ni dvh ni un comportement correct. */
    height: var(--app-height, 100dvh);
    overflow: hidden;
}

body.page-chat .container-full {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 12px;
    position: relative;
}

/* Le sondage flotte au-dessus du chat, en chevauchant légèrement son bord supérieur */
/* Le sondage flotte au-dessus du chat : léger chevauchement visuel via l'ombre
   uniquement (pas de grande marge négative, qui finirait recouverte par le
   fond opaque de la carte chat et cacherait le bouton "Voir les votes"). */
.floating-poll {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    margin: 12px 0 10px;
    padding-bottom: 6px;
    padding-top: 6px;
}

.chat-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    overflow: hidden;
}

.chat-card h2 {
    flex-shrink: 0;
}

.chat-card #chat-messages {
    flex: 1;
    min-height: 0;
    height: auto;
}

.chat-card #chat-form {
    flex-shrink: 0;
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    width: 44px;
    aspect-ratio: 1/1;
    padding: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #14161c;
    border: none;
}

/* ===================================================== */
/* ===== À partir d'ici : styles pour écrans larges ===== */
/* ===================================================== */
@media (min-width: 680px) {
    body { font-size: 16px; }

    .navbar { padding: 12px 24px; flex-wrap: nowrap; }
    .navbar .brand { font-size: 1.2rem; }
    .nav-toggle { display: none; }

    .nav-links {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        width: auto;
        gap: 18px;
        margin:auto 0;
        
        flex-direction: row;
        align-items: stretch;
        position: relative;
        background: var(--card-bg);
        border: none;
        top: auto;
        left: auto;
        border-radius: 10px;
        box-shadow: none;
    }
    .nav-links a { padding: 0; }
    .user-chip { padding: 0; }

    .container { padding: 0 16px; margin: 30px auto; }
    .card { padding: 24px;}

    body.page-chat .container-full { padding: 0 16px; }
    .chat-card { padding-top: 0; }

    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }


    .hide-on-small { display: block; }

    .chat-msg .bubble { max-width: 70%; }
    .chat-msg img.embed { max-width: 260px; }

    .chart-wrap { height: 320px; }

    table { min-width: 0; }
    th, td { font-size: 0.9rem; white-space: normal; }
}