/* ============================================
   Quiz Server — Styles globaux
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Typographie */
h1 { font-size: 1.875rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.125rem; font-weight: 600; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.page { padding: 2rem 1rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* Formulaires */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  transition: border-color .15s;
  background: var(--surface);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 1.25rem; padding-right: 2.25rem; }
.form-error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.form-hint { color: var(--text-muted); font-size: .8rem; margin-top: .25rem; }

/* Alertes */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { font-weight: 700; font-size: 1.125rem; color: var(--primary); text-decoration: none; }
.navbar-nav { display: flex; gap: .5rem; margin-left: auto; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .75rem 1rem; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg); }

/* Badges */
.badge { display: inline-block; padding: .2rem .5rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: #fef9c3; color: var(--warning); }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 800px; }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); }

/* Progress / Timer */
.timer-bar { height: 6px; background: var(--border); border-radius: 9999px; overflow: hidden; }
.timer-fill { height: 100%; background: var(--primary); transition: width 1s linear; border-radius: 9999px; }
.timer-fill.warning { background: var(--warning); }
.timer-fill.danger { background: var(--danger); }

/* Responsive */
@media (max-width: 640px) {
  .hide-mobile { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Drag & drop */
.drag-item { cursor: grab; user-select: none; }
.drag-item.dragging { opacity: .5; }
.drag-over { border-top: 2px solid var(--primary); }

/* Spinner */
.spinner {
  display: inline-block; width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Score display */
.score-big { font-size: 3rem; font-weight: 700; color: var(--primary); text-align: center; }
.score-label { text-align: center; color: var(--text-muted); font-size: .875rem; }
.progress-ring { display: flex; align-items: center; justify-content: center; }
