/* ═════════════════════════════════════════════════════════════════
   Guignols Debate — Mobile-first CSS (thème sombre show TV)
   ═════════════════════════════════════════════════════════════════ */

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

:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-surface: #1e2a4a;
  --accent-red: #e94560;
  --accent-blue: #0f3460;
  --accent-green: #2ecc71;
  --accent-yellow: #f1c40f;
  --accent-orange: #e67e22;
  --text-primary: #eee;
  --text-secondary: #aab;
  --text-muted: #778;
  --border-color: #2a2a4a;
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f1c40f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --max-width: 800px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-red); text-decoration: none; }
a:hover { opacity: 0.85; }

/* ─── Navbar ───────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent-red);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary) !important;
}

.logo { font-size: 1.5rem; }
.brand-text { background: linear-gradient(135deg, var(--accent-red), var(--accent-yellow)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.9rem;
}

.nav-link {
  color: var(--text-secondary) !important;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.nav-link:hover { color: var(--text-primary) !important; background: var(--bg-card); }

.nav-user {
  color: var(--accent-yellow);
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--accent-yellow);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--accent-red) !important;
  color: white !important;
  padding: 0.4rem 1rem !important;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
}

/* ─── Container ────────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
  width: 100%;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.card-header {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Phase Banner ──────────────────────────────────────────── */
.phase-banner {
  text-align: center;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-weight: 700;
  font-size: 1.1rem;
}
.phase-voting { background: linear-gradient(135deg, #2d1b69, #1a1a3e); border: 2px solid #7c3aed; }
.phase-debate { background: linear-gradient(135deg, #3e1a1a, #2d1b1b); border: 2px solid var(--accent-red); }
.phase-break { background: linear-gradient(135deg, #1a3e2d, #1b2d1b); border: 2px solid var(--accent-green); }
.phase-waiting { background: linear-gradient(135deg, #3e3e1a, #2d2d1b); border: 2px solid var(--accent-yellow); }

/* ─── Debate Header (2 celebrities) ─────────────────────────── */
.debate-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 0;
}

.debate-celeb {
  text-align: center;
  flex: 1;
}
.debate-celeb .avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 0.5rem;
  border: 3px solid var(--border-color);
}
.debate-celeb .name {
  font-weight: 700;
  font-size: 1rem;
}
.debate-celeb .votes-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.debate-celeb.active .avatar {
  border-color: var(--accent-red);
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
}

.debate-vs {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.debate-theme {
  text-align: center;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-style: italic;
  color: var(--accent-yellow);
  font-size: 1.05rem;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

/* ─── Round Card (3 sentences to vote) ──────────────────────── */
.round-card {
  margin-bottom: 1.2rem;
}

.round-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.round-speaker {
  font-weight: 700;
  color: var(--accent-red);
}
.round-number {
  background: var(--bg-surface);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

.sentence-card {
  display: block;
  padding: 1rem;
  margin-bottom: 0.6rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-surface);
  font-family: var(--font);
}

.sentence-card:active { transform: scale(0.98); }

.sentence-approve { border-left: 5px solid var(--accent-green); }
.sentence-refute { border-left: 5px solid var(--accent-red); }
.sentence-neutral { border-left: 5px solid var(--accent-yellow); }

.sentence-card.voted-approve { border-color: var(--accent-green); background: rgba(46, 204, 113, 0.15); }
.sentence-card.voted-refute { border-color: var(--accent-red); background: rgba(231, 76, 60, 0.15); }
.sentence-card.voted-neutral { border-color: var(--accent-yellow); background: rgba(241, 196, 15, 0.15); }
.sentence-card.winner { border-width: 3px; box-shadow: 0 0 15px rgba(46, 204, 113, 0.3); }

.sentence-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.3rem;
}
.label-approve { background: var(--accent-green); color: #000; }
.label-refute { background: var(--accent-red); color: #fff; }
.label-neutral { background: var(--accent-yellow); color: #000; }

.vote-count {
  float: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ─── Winning round display ─────────────────────────────────── */
.round-winner {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-green);
  background: rgba(46, 204, 113, 0.08);
  position: relative;
}

.round-winner .trophy {
  position: absolute;
  top: -10px;
  right: 10px;
  font-size: 1.5rem;
}

.round-winner .winning-text {
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* ─── Voting list (celebrities/themes) ───────────────────────── */
.vote-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.vote-item-info { flex: 1; }
.vote-item-name { font-weight: 600; font-size: 0.95rem; }
.vote-item-desc { font-size: 0.8rem; color: var(--text-muted); }
.vote-item-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-right: 0.8rem;
  white-space: nowrap;
}

.vote-btn {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.vote-btn:active { transform: scale(0.95); }
.vote-btn-up { background: var(--accent-green); color: #000; }
.vote-btn-up:hover { background: #27ae60; }
.vote-btn-voted { background: var(--accent-yellow); color: #000; }
.vote-btn-voted:hover { background: #d4ac0d; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  max-width: 400px;
  margin: 2rem auto;
}

.form-card h2 {
  text-align: center;
  margin-bottom: 1.2rem;
  font-size: 1.3rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-red);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-red { background: var(--accent-red); color: white; }
.btn-red:hover { background: #d63851; }
.btn-green { background: var(--accent-green); color: #000; }
.btn-green:hover { background: #27ae60; }

.form-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

/* ─── Add new form (inline) ─────────────────────────────────── */
.add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.add-form input {
  flex: 1;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
}
.add-form button {
  padding: 0.6rem 1rem;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ─── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}

/* ─── Flash messages ────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 70px;
  right: 1rem;
  z-index: 200;
  max-width: 350px;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 3s forwards;
}

.flash-success { background: var(--accent-green); color: #000; }
.flash-error { background: var(--danger); color: #fff; }
.flash-info { background: var(--accent-blue); color: #fff; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(50px); } }

/* ─── Leaderboard / Top picks ────────────────────────────────── */
.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}

.leaderboard-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.rank-1 { background: gold; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #000; }

.leaderboard-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.leaderboard-votes { color: var(--text-muted); font-size: 0.8rem; }

/* ─── Loading spinner ───────────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 0.3s;
}
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Timer / Countdown ──────────────────────────────────────── */
.timer {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: monospace;
  font-size: 1rem;
  color: var(--accent-yellow);
  background: rgba(241, 196, 15, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: 0.5rem 0.8rem; }
  .brand-text { display: none; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    flex-direction: column;
    padding: 0.5rem;
    border-bottom: 2px solid var(--accent-red);
    gap: 0.3rem;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 0.5rem; width: 100%; }
  .nav-user { width: 100%; text-align: center; }

  .debate-header { gap: 0.5rem; }
  .debate-celeb .avatar { width: 60px; height: 60px; font-size: 2rem; }
  .debate-celeb .name { font-size: 0.85rem; }
  .debate-vs { font-size: 1.2rem; }

  .sentence-card { font-size: 0.9rem; padding: 0.8rem; }
  .add-form { flex-direction: column; }
  .vote-item { flex-wrap: wrap; gap: 0.5rem; }
  .vote-item-count { margin-left: auto; }

  .container { padding: 0.7rem; }
  .form-card { margin: 1rem; }
}

/* ─── History page ──────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.history-item {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── Summary / Results ─────────────────────────────────────── */
.summary-round {
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent-blue);
  background: var(--bg-surface);
}

.summary-speaker { font-weight: 700; color: var(--accent-red); }
.summary-text { font-style: italic; margin: 0.3rem 0; font-size: 0.9rem; }
.summary-type { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Sparkle separators ────────────────────────────────────── */
.separator {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.5rem 0;
  letter-spacing: 0.5rem;
}

/* ─── Chat bubbles ──────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.chat-bubble {
  max-width: 88%;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  position: relative;
  word-wrap: break-word;
}

.chat-bubble-left {
  align-self: flex-start;
  background: linear-gradient(135deg, #1a2a5e, #2a3a7e);
  border: 1px solid #3a5a9e;
  border-bottom-left-radius: 4px;
}

.chat-bubble-right {
  align-self: flex-end;
  background: linear-gradient(135deg, #5e1a2a, #7e2a3a);
  border: 1px solid #9e3a4a;
  border-bottom-right-radius: 4px;
}

.chat-speaker {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.chat-speaker-left { color: #6a9aff; }
.chat-speaker-right { color: #ff6a7a; }

.chat-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  font-style: italic;
}

.chat-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-round-tag {
  font-size: 0.65rem;
  background: rgba(255,255,255,0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

/* Vote choices inside chat bubble */
.chat-votes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 0.8rem;
}

.chat-vote-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  text-align: left;
  font-family: var(--font);
  width: 100%;
}
.chat-vote-btn:active { transform: scale(0.97); }
.chat-vote-btn:hover { background: rgba(255,255,255,0.1); }
.chat-vote-btn.voted { opacity: 0.6; cursor: default; }

.chat-vote-icon { font-size: 1.2rem; flex-shrink: 0; }
.chat-vote-text { flex: 1; }
.chat-vote-count { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
