/* ============================================================
   WebPME E-Vote - Styles principaux
   Design : Dark premium, tons navy/crimson, typographie Spacemono
   ============================================================ */

/* --- Variables --- */
:root {
  --bg-base:       #0d0d1a;
  --bg-surface:    #13132b;
  --bg-elevated:   #1a1a38;
  --bg-card:       #1e1e3f;
  --bg-input:      #111128;

  --accent:        #e94560;
  --accent-hover:  #c73450;
  --accent-glow:   rgba(233,69,96,0.2);
  --accent-soft:   rgba(233,69,96,0.1);

  --blue:          #4a9eff;
  --blue-soft:     rgba(74,158,255,0.12);
  --green:         #2dd4a0;
  --green-soft:    rgba(45,212,160,0.12);
  --yellow:        #f5c518;
  --yellow-soft:   rgba(245,197,24,0.12);
  --orange:        #ff8c42;

  --text-primary:  #f0f0f8;
  --text-secondary:#8888aa;
  --text-muted:    #55556a;
  --text-on-accent:#ffffff;

  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.15);
  --border-accent: rgba(233,69,96,0.4);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.5);
  --shadow-accent: 0 0 24px rgba(233,69,96,0.25);

  --font-body:  system-ui, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  --font-mono:  'Cascadia Code', 'Source Code Pro', ui-monospace, SFMono-Regular, 'Menlo', 'Monaco', 'Consolas', monospace;
  
  --sidebar-w: 260px;
  --topbar-h:  64px;
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

/* ============================================================
   LAYOUT AUTH (login, register)
   ============================================================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(233,69,96,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 100%, rgba(74,158,255,0.05) 0%, transparent 60%),
    var(--bg-base);
}

.auth-box {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.auth-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-accent);
}

.auth-logo-text .app-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.auth-logo-text .app-tagline {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* ============================================================
   LAYOUT APP (sidebar + main)
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
}

.sidebar-logo-text {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  line-height: 1.3;
}

.sidebar-logo-text span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav a i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.sidebar-nav a:hover i,
.sidebar-nav a.active i {
  color: var(--accent);
}

.sidebar-nav a.active {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.sidebar-user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-token {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sidebar-credits {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-mono);
}

.sidebar-credits i { font-size: 12px; }

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-title span {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 14px;
  margin-left: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 32px;
  flex: 1;
}

/* ============================================================
   COMPOSANTS
   ============================================================ */

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--accent-hover); color: white; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-card); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger {
  background: rgba(220,53,69,0.15);
  color: #ff6b7a;
  border: 1px solid rgba(220,53,69,0.3);
}
.btn-danger:hover { background: rgba(220,53,69,0.25); color: #ff6b7a; }

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(45,212,160,0.3);
}
.btn-success:hover { background: rgba(45,212,160,0.2); color: var(--green); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* --- Formulaires --- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%238888aa' d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  appearance: none;
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--accent); font-size: 15px; }

/* --- Alertes / Flash --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.alert i { margin-top: 1px; flex-shrink: 0; }

.alert-success {
  background: var(--green-soft);
  border: 1px solid rgba(45,212,160,0.3);
  color: var(--green);
}

.alert-error {
  background: rgba(233,69,96,0.1);
  border: 1px solid var(--border-accent);
  color: #ff7a8a;
}

.alert-warning {
  background: var(--yellow-soft);
  border: 1px solid rgba(245,197,24,0.3);
  color: var(--yellow);
}

.alert-info {
  background: var(--blue-soft);
  border: 1px solid rgba(74,158,255,0.3);
  color: var(--blue);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-success  { background: var(--green-soft);  color: var(--green);  border: 1px solid rgba(45,212,160,0.3); }
.badge-danger   { background: rgba(233,69,96,0.1); color: var(--accent); border: 1px solid var(--border-accent); }
.badge-warning  { background: var(--yellow-soft);  color: var(--yellow); border: 1px solid rgba(245,197,24,0.3); }
.badge-info     { background: var(--blue-soft);    color: var(--blue);   border: 1px solid rgba(74,158,255,0.3); }
.badge-secondary{ background: var(--bg-elevated);  color: var(--text-secondary); border: 1px solid var(--border); }

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th {
  background: var(--bg-elevated);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }

table tr:hover td { background: var(--bg-elevated); color: var(--text-primary); }

.td-strong { color: var(--text-primary) !important; font-weight: 500; }
.td-mono   { font-family: var(--font-mono); font-size: 13px; }

/* --- Stats cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color var(--transition);
}

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

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon.red    { background: var(--accent-soft);  color: var(--accent); }
.stat-icon.blue   { background: var(--blue-soft);    color: var(--blue); }
.stat-icon.green  { background: var(--green-soft);   color: var(--green); }
.stat-icon.yellow { background: var(--yellow-soft);  color: var(--yellow); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Progress bar --- */
.progress {
  background: var(--bg-elevated);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.progress-bar.accent  { background: var(--accent); }
.progress-bar.green   { background: var(--green); }
.progress-bar.blue    { background: var(--blue); }
.progress-bar.yellow  { background: var(--yellow); }

/* --- Vote result bars --- */
.vote-result-item {
  margin-bottom: 16px;
}

.vote-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.vote-result-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.vote-result-count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Vote choice selector --- */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.choice-card {
  position: relative;
}

.choice-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 16px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.choice-label i {
  font-size: 28px;
  color: var(--text-muted);
}

.choice-label span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.choice-card input:checked + .choice-label {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-accent);
}

.choice-card input:checked + .choice-label i,
.choice-card input:checked + .choice-label span {
  color: var(--accent);
}

.choice-card.yes input:checked + .choice-label   { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 20px rgba(45,212,160,0.2); }
.choice-card.yes input:checked + .choice-label i,
.choice-card.yes input:checked + .choice-label span { color: var(--green); }

.choice-card.no input:checked + .choice-label   { border-color: var(--accent); }

.choice-card.abstain input:checked + .choice-label { border-color: var(--yellow); background: var(--yellow-soft); box-shadow: 0 0 20px rgba(245,197,24,0.2); }
.choice-card.abstain input:checked + .choice-label i,
.choice-card.abstain input:checked + .choice-label span { color: var(--yellow); }

.choice-label:hover {
  border-color: var(--border-hover);
  background: var(--bg-card);
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* --- Code display --- */
.code-tag {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--blue);
  letter-spacing: 0.5px;
}

.access-code-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--blue);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- QR code container --- */
.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: white;
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

#qr-canvas {
  display: block;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  justify-content: center;
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all var(--transition);
}

.pagination a:hover { border-color: var(--border-hover); color: var(--text-primary); }
.pagination span.current { background: var(--accent); color: white; border-color: var(--accent); }

/* --- Modal confirmation --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal-backdrop.active { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title i { color: var(--yellow); }
.modal-body { color: var(--text-secondary); font-size: 14px; line-height: 1.6; margin-bottom: 24px; }
.modal-footer { display: flex; gap: 12px; justify-content: flex-end; }

/* --- Hamburger mobile --- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* --- Misc --- */
.text-muted    { color: var(--text-muted) !important; }
.text-accent   { color: var(--accent); }
.text-green    { color: var(--green); }
.text-blue     { color: var(--blue); }
.text-yellow   { color: var(--yellow); }
.text-mono     { font-family: var(--font-mono); }
.text-sm       { font-size: 13px; }
.text-xs       { font-size: 11px; }
.text-center   { text-align: center; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.mb-8          { margin-bottom: 8px; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.mb-0          { margin-bottom: 0; }
.w-100         { width: 100%; }
.flex-1        { flex: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content { margin-left: 0; }

  .sidebar-toggle { display: block; }

  .topbar { padding: 0 16px; }

  .page-content { padding: 16px; }

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

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .choice-grid { grid-template-columns: 1fr; }

  .auth-box { padding: 28px 20px; }

  .card { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-accent {
  0%, 100% { box-shadow: var(--shadow-accent); }
  50%       { box-shadow: 0 0 32px rgba(233,69,96,0.4); }
}

.fade-in { animation: fadeIn 0.3s ease both; }

.btn-primary { animation: pulse-accent 3s ease infinite; }
.btn-primary:hover { animation: none; }

/* Loader */
.loader {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* Print */
@media print {
  .sidebar, .topbar, .topbar-actions, .btn, .no-print { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; }
}

/* ============================================================
   THÈME CLAIR
   ============================================================ */
body.theme-light {
  --bg-base:       #f0f2f5;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f8f9fa;
  --bg-card:       #ffffff;
  --bg-input:      #ffffff;

  --text-primary:  #1a1a2e;
  --text-secondary:#4a4a6a;
  --text-muted:    #9090aa;

  --border:        rgba(0,0,0,0.1);
  --border-hover:  rgba(0,0,0,0.2);
  --border-accent: rgba(233,69,96,0.3);

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 2px 12px rgba(0,0,0,0.1);
  --shadow-lg:  0 4px 24px rgba(0,0,0,0.12);
}

body.theme-light .sidebar { border-right-color: rgba(0,0,0,0.1); }
body.theme-light .topbar  { border-bottom-color: rgba(0,0,0,0.1); }
body.theme-light .form-control { color: var(--text-primary); }
body.theme-light .sidebar-nav a { color: var(--text-secondary); }
body.theme-light .table-wrapper { border-color: rgba(0,0,0,0.1); }
body.theme-light table th { background: #f0f2f5; }
body.theme-light .code-tag { background: #f0f2f5; color: #2563eb; }
body.theme-light .access-code-box { background: #f0f2f5; color: #2563eb; }
body.theme-light .sidebar-credits { background: rgba(233,69,96,0.06); }

/* Bouton thème dans la sidebar */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  margin-top: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--border-hover); color: var(--text-primary); }
.theme-toggle i { font-size: 14px; color: var(--yellow); }

/* ============================================================
   MOBILE — CORRECTIONS GÉNÉRALES
   ============================================================ */
@media (max-width: 768px) {

  /* Auth box */
  .auth-box { padding: 24px 16px; border-radius: var(--radius-lg); }
  .auth-title { font-size: 18px; }

  /* Tables horizontalement scrollables */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 540px; }
  table th, table td { padding: 10px 12px; font-size: 12px; }

  /* Topbar */
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 15px; }

  /* Page content */
  .page-content { padding: 12px; }

  /* Grilles 2 colonnes → 1 colonne */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns:2fr 1fr"],
  div[style*="grid-template-columns:1fr 2fr"],
  div[style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr !important;
  }

  /* Stats grid */
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }

  /* Boutons dans les actions */
  .topbar-actions { gap: 6px; }
  .topbar-actions .badge { display: none; }

  /* Cards */
  .card { padding: 14px; }
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Choice grid vote ballot */
  .choice-grid { grid-template-columns: 1fr !important; }
  .choice-label { flex-direction: row; padding: 16px; justify-content: flex-start; gap: 16px; }
  .choice-label i { font-size: 22px; }

  /* Pagination */
  .pagination a, .pagination span { width: 30px; height: 30px; font-size: 12px; }

  /* Form row */
  .form-row { grid-template-columns: 1fr !important; }

  /* Sidebar footer user info */
  .sidebar-user-name { font-size: 11px; }
  .sidebar-user-token { font-size: 9px; }

  /* Access code box */
  .access-code-box { font-size: 12px; letter-spacing: 1px; }

  /* QR code */
  #qr-container img { max-width: 160px !important; height: auto !important; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .btn-lg { padding: 11px 18px; font-size: 14px; }
}

/* Anti-flash thème clair (appliqué avant JS) */
html.theme-light-pending body,
html.theme-light-pending .sidebar,
html.theme-light-pending .topbar {
  background: #f0f2f5;
}
