/* ========================================
   CERCP Check-In PWA — Styles
   ======================================== */

:root {
  --bleu: #1a2a4a;
  --bleu-clair: #2c4a7c;
  --dore: #c9a84c;
  --dore-clair: #e8d5a0;
  --vert: #16a34a;
  --vert-clair: #dcfce7;
  --rouge: #dc2626;
  --rouge-clair: #fee2e2;
  --orange: #d97706;
  --orange-clair: #fef3c7;
  --gris: #6b7280;
  --gris-clair: #f3f4f6;
  --gris-border: #e5e7eb;
  --blanc: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gris-clair);
  color: #1f2937;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   ECRANS
   ======================================== */
.screen {
  display: none;
  min-height: 100dvh;
  padding-bottom: 80px;
}
.screen.active {
  display: block;
}

/* ========================================
   LOGIN
   ======================================== */
#login-screen {
  display: none;
  background: linear-gradient(135deg, var(--bleu) 0%, var(--bleu-clair) 100%);
  min-height: 100dvh;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}
#login-screen.active {
  display: flex;
}

.login-card {
  background: var(--blanc);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  background: var(--bleu);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo svg {
  width: 40px;
  height: 40px;
  fill: var(--dore);
}

.login-card h1 {
  font-size: 1.25rem;
  color: var(--bleu);
  margin-bottom: 0.25rem;
}
.login-card p {
  font-size: 0.85rem;
  color: var(--gris);
  margin-bottom: 2rem;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 1.5rem;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--gris-border);
  background: var(--blanc);
  transition: all 0.15s;
}
.pin-dot.filled {
  background: var(--bleu);
  border-color: var(--bleu);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}
.pin-btn {
  height: 60px;
  border: none;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  background: var(--gris-clair);
  color: var(--bleu);
}
.pin-btn:active {
  background: var(--bleu);
  color: var(--blanc);
  transform: scale(0.95);
}
.pin-btn.action {
  font-size: 0.9rem;
  background: transparent;
  color: var(--gris);
}
.pin-btn.action.submit {
  background: var(--bleu);
  color: var(--blanc);
}

.login-error {
  color: var(--rouge);
  font-size: 0.85rem;
  margin-top: 1rem;
  min-height: 1.2rem;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  background: var(--bleu);
  color: var(--blanc);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}
.header-badge {
  background: var(--dore);
  color: var(--bleu);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}

/* ========================================
   STATS
   ======================================== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 1rem 1.25rem;
}
.stat-card {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--bleu);
}
.stat-label {
  font-size: 0.7rem;
  color: var(--gris);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.stat-card.checked .stat-value { color: var(--vert); }
.stat-card.pending .stat-value { color: var(--orange); }

/* ========================================
   SCANNER
   ======================================== */
.scan-section {
  padding: 1rem 1.25rem;
}
.scan-container {
  background: var(--blanc);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.scan-header {
  padding: 1rem;
  text-align: center;
  font-weight: 600;
  color: var(--bleu);
  border-bottom: 1px solid var(--gris-border);
}
#qr-reader {
  width: 100%;
  aspect-ratio: 1;
  max-height: 400px;
}
#qr-reader video {
  border-radius: 0 !important;
}

/* ========================================
   RESULTAT CHECK-IN
   ======================================== */
.result-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}
.result-overlay.show {
  display: flex;
}

.result-card {
  background: var(--blanc);
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.result-icon.success { background: var(--vert-clair); color: var(--vert); }
.result-icon.warning { background: var(--orange-clair); color: var(--orange); }
.result-icon.error { background: var(--rouge-clair); color: var(--rouge); }

.result-card h2 {
  font-size: 1.35rem;
  color: var(--bleu);
  margin-bottom: 0.25rem;
}
.result-card .result-subtitle {
  font-size: 0.85rem;
  color: var(--gris);
  margin-bottom: 1rem;
}

.result-details {
  background: var(--gris-clair);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
  text-align: left;
}
.result-details .detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}
.detail-row .label {
  color: var(--gris);
}
.detail-row .value {
  font-weight: 600;
  color: var(--bleu);
}

.restaurant-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.5rem;
}
.restaurant-badge.yes {
  background: var(--dore-clair);
  color: #92600a;
}
.restaurant-badge.no {
  background: var(--gris-clair);
  color: var(--gris);
}

.result-btn {
  margin-top: 1.5rem;
  padding: 0.85rem 2rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bleu);
  color: var(--blanc);
  width: 100%;
}
.result-btn:active { opacity: 0.9; }

/* ========================================
   NAV BAR
   ======================================== */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--blanc);
  border-top: 1px solid var(--gris-border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  font-size: 0.65rem;
  color: var(--gris);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s;
}
.nav-item.active {
  color: var(--bleu);
}
.nav-item svg {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}
.nav-item.active svg { fill: var(--bleu); }

/* ========================================
   FORMULAIRE AJOUT INVITE
   ======================================== */
.form-section {
  padding: 1rem 1.25rem;
}
.form-card {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.form-card h2 {
  font-size: 1.1rem;
  color: var(--bleu);
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--gris-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--blanc);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--bleu);
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}
.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--bleu);
}
.form-check label {
  font-size: 0.85rem;
  color: #374151;
}

.btn-submit {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bleu);
  color: var(--blanc);
  margin-top: 0.5rem;
}
.btn-submit:active { opacity: 0.9; }
.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-success {
  background: var(--vert-clair);
  color: var(--vert);
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
  font-weight: 600;
  margin-top: 1rem;
  display: none;
}

/* ========================================
   LOGOUT
   ======================================== */
.logout-section {
  padding: 2rem 1.25rem;
  text-align: center;
}
.btn-logout {
  padding: 0.7rem 2rem;
  border: 2px solid var(--rouge);
  border-radius: 10px;
  background: transparent;
  color: var(--rouge);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-logout:active { background: var(--rouge-clair); }

/* ========================================
   LOADING
   ======================================== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gris-border);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   TOAST
   ======================================== */
.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 300;
  animation: fadeIn 0.2s;
  max-width: 90%;
}
.toast.success { background: var(--vert); color: var(--blanc); }
.toast.error { background: var(--rouge); color: var(--blanc); }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ========================================
   GUEST LIST
   ======================================== */
.guest-item {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.guest-item:active { background: var(--gris-clair); }

.guest-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.guest-status-dot.checked { background: var(--vert); }
.guest-status-dot.pending { background: var(--gris-border); }

.guest-info {
  flex: 1;
  min-width: 0;
}
.guest-info .guest-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--bleu);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guest-info .guest-meta {
  font-size: 0.75rem;
  color: var(--gris);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.guest-badge-sm {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.guest-badge-sm.restaurant { background: var(--dore-clair); color: #92600a; }
.guest-badge-sm.email-sent { background: var(--vert-clair); color: var(--vert); }

.guest-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--gris);
  padding: 0.5rem;
}

.guest-empty {
  text-align: center;
  color: var(--gris);
  padding: 3rem 1rem;
  font-size: 0.9rem;
}
