/* ══════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --text-muted: #7a7a9a;
  --primary: #6c63ff;
  --primary-h: #574fd6;
  --ouvert: #22c55e;
  --ferme: #ef4444;
  --deplacement: #f59e0b;
  --aucun: #6b7280;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s ease;
}

html,
body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

/* ══════════════════════════════════════════
   PAGE CONNEXION
   ══════════════════════════════════════════ */
.page-connexion {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 16px;
  background: linear-gradient(135deg, #0f0f13 0%, #1a1a2e 100%);
}

.page-connexion .container {
  width: 100%;
  max-width: 480px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  color: var(--primary);
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-login {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label,
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.2);
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:hover {
  background: var(--primary-h);
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--ferme);
}

.btn-danger:hover {
  background: #c53030;
}

/* ══════════════════════════════════════════
   PAGE ADMIN
   ══════════════════════════════════════════ */
.page-admin {
  min-height: 100vh;
  background: var(--bg);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.admin-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  gap: 24px;
}

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

.admin-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.statut-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.statut-btn {
  padding: 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.statut-btn:hover {
  transform: translateY(-2px);
}

.statut-btn.active-ouvert {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--ouvert);
  color: var(--ouvert);
}

.statut-btn.active-ferme {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--ferme);
  color: var(--ferme);
}

.statut-btn.active-deplacement {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--deplacement);
  color: var(--deplacement);
}

.statut-btn.active-aucun {
  background: rgba(107, 114, 128, 0.15);
  border-color: var(--aucun);
  color: var(--aucun);
}

/* ══════════════════════════════════════════
   PAGE STATUT (TV / Affichage public)
   ══════════════════════════════════════════ */
.page-statut {
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.statut-fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 4vh 4vw;
  gap: 4vh;
  text-align: center;
  overflow: hidden;
}


.statut-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vh;
  width: 100%;
  max-width: 100%;
}

.statut-content > * {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* Titre SERVICE INFORMATIQUE */
.statut-title,
.page-statut h1,
.page-statut h2 {
  font-size: clamp(2.5rem, 6vw, 5rem) !important;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center !important;
  width: 100% !important;
  margin: 0 auto !important;
  line-height: 1.2;
}

.statut-divider {
  width: 15vw;
  height: 6px;
  border-radius: 3px;
  margin: 0 auto;
}

/* ══════════════════════════════════════════
   BADGE STATUT — TV
   ══════════════════════════════════════════ */
.page-statut .statut-badge {
  display: inline-block;
  padding: 4vh 6vw;
  font-size: clamp(3rem, 10vw, 9rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  border-radius: 24px;
  border-width: 3px;
  border-style: solid;
  text-transform: uppercase;
  text-align: center;
  margin: 0 auto;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
}

/* Couleurs par statut */
.page-statut .statut-badge.ouvert {
  color: var(--ouvert);
  border-color: var(--ouvert);
  background: rgba(34, 197, 94, 0.1);
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.3);
}

.page-statut .statut-badge.ferme {
  color: var(--ferme);
  border-color: var(--ferme);
  background: rgba(239, 68, 68, 0.1);
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.3);
}

.page-statut .statut-badge.deplacement {
  font-size: clamp(2rem, 6.5vw, 6rem);
  padding: 4vh 4vw;
  letter-spacing: 0.02em;
  color: var(--deplacement);
  border-color: var(--deplacement);
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.3);
}

.page-statut .statut-badge.aucun {
  color: var(--aucun);
  border-color: var(--aucun);
  background: rgba(107, 114, 128, 0.1);
}

/* Statut seul (sans message ni QR) = plus grand */
.statut-content:not(:has(#messageBox:not(.hidden))):not(:has(#statutQrWrapper:not(.hidden))) .statut-badge {
  font-size: clamp(5rem, 15vw, 12rem);
  padding: 6vh 8vw;
}

/* Exception : DEPLACEMENT seul reste contrôlé (mot long, 11 lettres) */
.statut-content:not(:has(#messageBox:not(.hidden))):not(:has(#statutQrWrapper:not(.hidden))) .statut-badge.deplacement {
  font-size: clamp(3rem, 9vw, 7.5rem);
  padding: 6vh 5vw;
  letter-spacing: 0.02em;
  max-width: 88vw;
}

/* ══════════════════════════════════════════
   MESSAGE STATUT
   ══════════════════════════════════════════ */
.statut-message-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3vh 4vw;
  max-width: 80vw;
  margin: 0 auto;
}

.statut-message {
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  color: var(--text);
  line-height: 1.5;
  text-align: center;
}

.statut-message-box.hidden {
  display: none;
}

/* ══════════════════════════════════════════
   QR CODE — PAGE STATUT
   ══════════════════════════════════════════ */
.statut-qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  margin: 2vh auto 0;
  padding: 3vh;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
}

.statut-qr-wrapper #statutQrCanvas {
  display: flex;
  align-items: center;
  justify-content: center;
}

.statut-qr-wrapper #statutQrCanvas img,
.statut-qr-wrapper #statutQrCanvas canvas {
  width: clamp(150px, 20vw, 320px) !important;
  height: clamp(150px, 20vw, 320px) !important;
  display: block;
  border-radius: 12px;
  margin: 0 auto;
}

.statut-qr-label {
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: var(--text-muted);
  text-align: center;
}

/* ══════════════════════════════════════════
   FOOTER STATUT
   ══════════════════════════════════════════ */
.statut-footer {
  position: fixed;
  bottom: 2vh;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  color: var(--text-muted);
  opacity: 0.6;
}

/* ══════════════════════════════════════════
   APERÇU QR (admin)
   ══════════════════════════════════════════ */
.qr-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
}

.qr-preview-box #qrPreviewCanvas img,
.qr-preview-box #qrPreviewCanvas canvas {
  display: block;
  border-radius: 4px;
}

.qr-preview-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
}

/* ══════════════════════════════════════════
   TOGGLE SWITCH
   ══════════════════════════════════════════ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 0;
  padding: 12px 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  left: calc(100% - 22px);
  background: #fff;
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
  user-select: none;
}

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 20px;
}

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

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
  .admin-header {
    padding: 12px 16px;
  }

  .admin-header h1 {
    font-size: 1rem;
  }

  .admin-content {
    padding: 16px;
  }

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

  .statut-title,
  .page-statut h1,
  .page-statut h2 {
    font-size: 1.8rem !important;
  }

  .page-statut .statut-badge {
    padding: 14px 28px;
    font-size: clamp(1.8rem, 8vw, 4rem);
  }

  .page-statut .statut-badge.deplacement {
    font-size: clamp(1.4rem, 6.5vw, 3rem);
    padding: 14px 20px;
  }

  .statut-message {
    font-size: 1.1rem;
    padding: 16px 20px;
  }

  .statut-content {
    gap: 20px;
    padding: 0 16px;
  }

  .statut-qr-wrapper #statutQrCanvas img,
  .statut-qr-wrapper #statutQrCanvas canvas {
    width: 180px !important;
    height: 180px !important;
  }

  .modal {
    padding: 24px;
  }

  .form-login {
    padding: 24px;
  }
}
