/* Styles partages : console d'administration, vote mobile, tableau de resultats. */

:root {
  --blue: #0070ad;
  --blue-dark: #12476e;
  --blue-soft: #e8f2f9;
  --teal: #12abdb;
  --green: #2e7d32;
  --green-soft: #e8f5e9;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --red: #c62828;
  --red-soft: #fdecea;
  --ink: #16242e;
  --ink-2: #4a5c68;
  --ink-3: #7b8b96;
  --line: #d8e2e9;
  --line-soft: #eaf0f4;
  --bg: #f4f7f9;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 36, 46, .06), 0 4px 16px rgba(22, 36, 46, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body { overscroll-behavior-y: contain; }

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--blue); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.wrap-narrow { max-width: 680px; margin: 0 auto; padding: 1rem; }

.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.mono { font-family: "Cascadia Mono", Consolas, "SF Mono", monospace; font-size: .85em; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: .35rem; align-items: center; }
.spacer { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ------------------------------------------------------------------ Cartes */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card + .card { margin-top: 1rem; }
.card-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin: -1rem -1rem 1rem; padding: .75rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfdfe;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-head h2, .card-head h3 { margin: 0; }

/* --------------------------------------------------------------- Controles */

button, .btn {
  font: inherit; font-weight: 600;
  padding: .55rem 1rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button:hover, .btn:hover { background: #f2f7fa; border-color: #b9ccd9; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(0, 112, 173, .35); outline-offset: 1px;
}

.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #005b8e; border-color: #005b8e; }
.btn-danger { background: #fff; border-color: #e0b4b0; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef4f8; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; border-radius: 7px; }
.btn-lg { padding: .85rem 1.3rem; font-size: 1.05rem; border-radius: 11px; }
.btn-block { width: 100%; }

input[type=text], input[type=number], input[type=password], input[type=url], select, textarea {
  font: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  max-width: 100%;
}
input[type=number] { width: 5.5rem; }
textarea { resize: vertical; min-height: 4rem; }
label { font-weight: 600; font-size: .85rem; color: var(--ink-2); display: block; margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 500; font-size: .92rem; color: var(--ink); }
.check input { width: 1.05rem; height: 1.05rem; margin-top: .22rem; flex: none; }

/* ------------------------------------------------------------------ Tables */

table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 700; }
tbody tr:hover { background: #fafcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }

/* ------------------------------------------------------------------ Badges */

.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: var(--line-soft); color: var(--ink-2); white-space: nowrap;
}
.badge-jury { background: var(--blue-soft); color: var(--blue-dark); }
.badge-public { background: #f3ecfb; color: #6a3fa0; }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-off { background: var(--red-soft); color: var(--red); }

.pill-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--line-soft); color: var(--ink-2); font-weight: 700; font-size: .85rem;
}
.pill-rank.r1 { background: #fdf0c9; color: #8a6400; }
.pill-rank.r2 { background: #eceff1; color: #5a6b76; }
.pill-rank.r3 { background: #f7e6d8; color: #8a5420; }

/* ----------------------------------------------------------------- Alertes */

.alert { padding: .7rem .9rem; border-radius: 9px; font-size: .92rem; border: 1px solid; }
.alert-info { background: var(--blue-soft); border-color: #bcdcee; color: var(--blue-dark); }
.alert-ok { background: var(--green-soft); border-color: #bfe0c1; color: var(--green); }
.alert-warn { background: var(--amber-soft); border-color: #f0d6a8; color: var(--amber); }
.alert-err { background: var(--red-soft); border-color: #f1c4c0; color: var(--red); }

/* ------------------------------------------------------------------ Onglets */

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 1rem; }
.tab {
  padding: .55rem .9rem; border: none; background: none; cursor: pointer;
  font-weight: 600; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -2px;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--ink); background: #eef4f8; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ------------------------------------------------------- Barre superieure */

.topbar {
  background: var(--blue-dark); color: #fff;
  padding: .6rem 1rem;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 1.05rem; margin: 0; color: #fff; }
.topbar .muted { color: #a9c7dc; }
.topbar button, .topbar .btn {
  background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff;
}
.topbar button:hover, .topbar .btn:hover { background: rgba(255, 255, 255, .22); }

/* ============================================ Interface de vote (mobile) === */

.vote-body { background: var(--bg); padding-bottom: 7.5rem; }

.vote-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue-dark); color: #fff;
  padding: .55rem .9rem .6rem;
  box-shadow: 0 2px 10px rgba(18, 71, 110, .25);
}
.vote-head .line1 { display: flex; align-items: baseline; gap: .5rem; font-size: .78rem; color: #a9c7dc; }
.vote-head .team { font-size: 1.3rem; font-weight: 700; margin-top: .1rem; }
.vote-head .sub { font-size: .8rem; color: #bcd6e7; }

.timer-bar { height: 6px; background: rgba(255, 255, 255, .18); border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.timer-fill { height: 100%; width: 100%; background: var(--teal); transition: width .25s linear, background-color .3s; }
.timer-fill.warn { background: #f5a623; }
.timer-fill.crit { background: #ff5b5b; }
.timer-text { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer-text.warn { color: #ffd38a; }
.timer-text.crit { color: #ffb3b3; animation: pulse .9s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.crit-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem; margin-bottom: .75rem; box-shadow: var(--shadow); }
.crit-card.answered { border-color: #b7dcc0; }
.crit-name { font-weight: 650; font-size: 1.02rem; display: flex; gap: .4rem; align-items: center; }
.crit-desc { font-size: .83rem; color: var(--ink-3); margin: .15rem 0 .65rem; }

.scale { display: grid; gap: .4rem; grid-auto-flow: column; grid-auto-columns: 1fr; }
.scale.wrap-scale { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(3rem, 1fr)); }
.scale button {
  padding: .7rem .2rem; font-size: 1.1rem; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink-2);
  min-height: 3rem; touch-action: manipulation;
}
.scale button.sel { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(0, 112, 173, .3); }
.scale-labels { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-3); margin-top: .35rem; }
.scale-hint { font-size: .8rem; color: var(--blue-dark); margin-top: .4rem; min-height: 1.1rem; font-weight: 600; }

.votebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: #fff; border-top: 1px solid var(--line);
  padding: .65rem .9rem calc(.65rem + env(safe-area-inset-bottom));
  box-shadow: 0 -3px 14px rgba(22, 36, 46, .1);
}

.team-chip {
  padding: .45rem .7rem; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; font-size: .9rem; text-align: left; width: 100%;
  display: flex; align-items: center; gap: .5rem;
}
.team-chip.done { background: var(--green-soft); border-color: #bfe0c1; color: var(--green); }
.team-chip.current { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(0, 112, 173, .18); }

.big-ok { font-size: 3rem; line-height: 1; }

/* ======================================== Tableau de resultats (projection) */

.board { background: #0d2436; color: #fff; min-height: 100vh; }
.board .card { background: #16344b; border-color: #1f4a69; color: #fff; box-shadow: none; }
.board .card-head { background: #1a3c56; border-color: #1f4a69; }
.board th { color: #8fb4ce; }
.board td { border-color: #1f4a69; }
.board tbody tr:hover { background: #1b3e59; }
.board h1, .board h2, .board h3 { color: #fff; }
.board .muted { color: #8fb4ce; }
.board .score { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------- QR a l'ecran/print */

.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; }
.qr-box svg { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto; }
.qr-url { font-family: "Cascadia Mono", Consolas, monospace; font-size: .72rem; word-break: break-all; color: var(--ink-3); margin-top: .5rem; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .qr-box { break-inside: avoid; border: 1px solid #999; box-shadow: none; }
  .card { box-shadow: none; }
}

@media (max-width: 600px) {
  .wrap, .wrap-narrow { padding: .75rem; }
  h1 { font-size: 1.2rem; }
  .card { padding: .8rem; }
  .card-head { margin: -.8rem -.8rem .8rem; padding: .6rem .8rem; }
}
