/* ============================================================
   DAMScreen — Design system DAM Marine
   Variables, composants réutilisables, responsive.
   ============================================================ */

:root {
  /* Couleurs DAM Marine (bleu marine sobre) */
  --navy-900: #081c36;
  --navy-800: #0b2545;
  --navy-700: #13315c;
  --navy-600: #1d4e89;
  --blue-500: #2f6db3;
  --blue-100: #dbe7f3;
  --accent: #2f9e8f;
  --accent-dark: #23786d;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe5ec;
  --text: #1a2332;
  --text-muted: #5b6b7f;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --success: #1e7d4f;
  --success-bg: #e7f5ee;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(8, 28, 54, 0.08), 0 4px 16px rgba(8, 28, 54, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* --- En-tête d'application --------------------------------- */
.app-header {
  background: var(--navy-800);
  color: #fff;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.3px;
}

/* Logo DAM sur fond marine : pastille blanche pour la lisibilité */
.app-header .brand .brand-logo {
  height: 34px;
  background: #fff;
  padding: 5px 9px;
  border-radius: 7px;
  display: block;
}

.app-header .user-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--blue-100);
}

/* --- Conteneurs --------------------------------------------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 17px;
  color: var(--navy-800);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

/* --- Boutons ------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
  min-height: 44px; /* zone tactile confortable */
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--navy-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a53125; }

.btn-ghost {
  background: transparent;
  color: var(--navy-600);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--blue-100); }

.btn-lg { font-size: 17px; padding: 16px 30px; }
.btn-sm { font-size: 13px; padding: 7px 14px; min-height: 34px; }

/* --- Formulaires --------------------------------------------- */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(47, 109, 179, 0.15);
}

/* --- Messages ------------------------------------------------- */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}

.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

.hidden { display: none !important; }

/* --- Affichage du code de session ----------------------------- */
.session-code {
  font-size: clamp(52px, 12vw, 96px);
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--navy-800);
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin: 8px 0;
  user-select: all;
}

.session-code-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  margin: 0;
}

/* --- Saisie du code (viewer) ----------------------------------- */
.code-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}

.code-inputs input {
  width: clamp(40px, 11vw, 58px);
  height: clamp(54px, 14vw, 72px);
  text-align: center;
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--navy-800);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-inputs input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(47, 109, 179, 0.18);
}

/* --- Tableaux -------------------------------------------------- */
.table-wrap { overflow-x: auto; }

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

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Badges ------------------------------------------------------ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-ended { background: #eef1f5; color: var(--text-muted); }
.badge-expired { background: #fdf3e7; color: #ad6800; }

/* --- Statistiques (admin) ---------------------------------------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-tile .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--navy-800);
}

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

/* --- Page centrée (login / viewer) -------------------------------- */
.centered-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.centered-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  animation: fadeIn 0.25s ease;
}

.centered-card .brand-block {
  text-align: center;
  margin-bottom: 26px;
}

.centered-card .brand-block .brand-logo-lg {
  height: 46px;
  max-width: 100%;
  margin-bottom: 14px;
}

.centered-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--navy-800);
}

.centered-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* --- Animations ---------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.pulse { animation: pulse 1.6s ease-in-out infinite; }

/* Indicateur "en direct" */
.live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  animation: pulse 1.6s ease-in-out infinite;
}

.muted { color: var(--text-muted); font-size: 13px; }
