/* ============================================================
   Gestion des Go-Pass : feuille de style
   ============================================================ */
:root {
  --rva-blue: #1e3a8a;
  --rva-red: #dc2626;
  --rva-gold: #d97706;
  --bg: #f8fafc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #0f172a;
}

#app { max-width: 1250px; margin: 0 auto; padding: 20px; }

/* ---------- En-tête / topbar ---------- */
.header {
  background: linear-gradient(135deg, var(--rva-blue) 0%, #1e40af 100%);
  color: white;
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.header h1 { margin: 0; font-size: 1.8rem; }
.header p { margin: 4px 0 0 0; opacity: 0.9; font-size: 0.95rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, var(--rva-blue) 0%, #1e40af 100%);
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.12);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-icon {
  width: 50px; height: 46px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon img {
  height: 40px;
  width: auto;
  max-width: 46px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 2px;
}
.brand-text h1 { margin: 0; font-size: 1.35rem; line-height: 1.2; white-space: nowrap; }
.brand-text p { margin: 2px 0 0 0; opacity: 0.85; font-size: 0.8rem; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-clock {
  font-size: 0.8rem;
  opacity: 0.9;
  text-align: right;
  background: rgba(255,255,255,0.12);
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ---------- Menu utilisateur ---------- */
.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 6px 12px 6px 6px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.user-btn:hover { background: rgba(255,255,255,0.2); }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rva-gold), #f59e0b);
  color: #0f172a;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.6);
  user-select: none;
}
.avatar-lg { width: 48px; height: 48px; font-size: 1.15rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.7rem; border: 3px solid var(--rva-blue); }
.user-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; min-width: 0; }
.user-info strong { font-size: 0.9rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info small { font-size: 0.75rem; opacity: 0.8; }
.caret { font-size: 0.7rem; opacity: 0.8; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: white;
  color: #0f172a;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  border: 1px solid #e5e7eb;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s ease;
  z-index: 50;
  overflow: hidden;
}
.user-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.dropdown-id { display: flex; flex-direction: column; min-width: 0; }
.dropdown-id strong { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-id small { color: #64748b; font-size: 0.78rem; }
.dropdown-item {
  display: block;
  padding: 12px 16px;
  color: #334155;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.dropdown-item:hover { background: #eef2ff; color: var(--rva-blue); }
.logout-item { color: var(--rva-red); }
.logout-item:hover { background: #fee2e2; color: var(--rva-red); }
.dropdown-divider { height: 1px; background: #e5e7eb; }

/* ---------- Page profil ---------- */
.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  background: white;
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.profile-head h2 { margin: 0 0 4px; font-size: 1.4rem; }
.profile-head p { margin: 2px 0; }
.profile-head .muted { font-size: 0.85rem; }

/* ---------- Navigation ---------- */
.nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nav-link {
  padding: 9px 16px;
  border-radius: 8px;
  background: white;
  color: var(--rva-blue);
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}
.nav-link:hover { background: #eef2ff; }
.nav-link.active { background: var(--rva-blue); color: white; }
.nav-spacer { flex: 1; }
.nav-user { font-size: 0.9rem; color: #334155; }
.nav-user em { font-style: normal; color: #64748b; font-size: 0.8rem; }

/* ---------- Onglets (reports) ---------- */
.nav-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.nav-tabs .tab {
  padding: 10px 18px;
  border-radius: 8px;
  background: white;
  color: var(--rva-blue);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nav-tabs .tab.active { background: var(--rva-blue); color: white; }

/* ---------- Cartes ---------- */
.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.muted { color: #94a3b8; font-size: 0.9rem; }

/* ---------- Statistiques ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid var(--rva-blue);
}
.stat-card.red { border-left-color: var(--rva-red); }
.stat-card.gold { border-left-color: var(--rva-gold); }
.stat-card.green { border-left-color: #16a34a; }
.stat-label {
  font-size: 0.82rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: #0f172a; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; margin-bottom: 4px; }
.form-group label { font-size: 0.875rem; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--rva-blue);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}
.form-actions { margin-top: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500 !important; cursor: pointer; }
.checkbox-inline input { width: auto; }

/* ---------- Boutons ---------- */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--rva-blue); color: white; }
.btn-primary:hover { background: #1e40af; }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--rva-red); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: white; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f1f5f9; font-weight: 600; color: #374151; font-size: 0.85rem; }
tr:hover { background: #f8fafc; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gold { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #e2e8f0; color: #475569; }

/* ---------- Alertes ---------- */
.flash-zone { margin-bottom: 16px; }
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ---------- Filtres ---------- */
.filter-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: end;
}
.filter-row .form-group { flex: 1; min-width: 150px; }
.filter-row .form-group label { white-space: nowrap; }

/* ---------- Graphiques en barres ---------- */
.chart-line { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.chart-label { width: 90px; font-size: 0.85rem; color: #475569; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar { height: 22px; background: #e2e8f0; border-radius: 12px; overflow: hidden; flex: 1; }
.chart-fill { height: 100%; background: linear-gradient(90deg, var(--rva-blue), #3b82f6); border-radius: 12px; transition: width 0.5s ease; }
.chart-fill.gold { background: linear-gradient(90deg, var(--rva-gold), #f59e0b); }
.chart-fill.green { background: linear-gradient(90deg, #16a34a, #4ade80); }
.chart-count { width: 90px; text-align: right; font-weight: 600; color: #334155; font-size: 0.85rem; }

/* ---------- Statuts de paiement ---------- */
.paiement-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.paiement-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.paiement-count { font-size: 1.4rem; font-weight: 700; }

/* ---------- Ticket Go-Pass (paysage — Contrôle National) ---------- */
.ticket-preview.ticket-paysage {
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 470px;
  background: rgb(255, 255, 205);
  color: #000;
  font-family: Arial, 'Segoe UI', system-ui, sans-serif;
  border: 2px solid #000;
  border-radius: 0;
  padding: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.ticket-side {
  width: 30px;
  background: var(--rva-blue);
  color: #fff;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 4px;
  flex-shrink: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.ticket-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 2px solid #000;
}
.ticket-topleft {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  flex-shrink: 0;
}
.ticket-center {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.ticket-no-row {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 4px;
}
.ticket-no-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}
.ticket-big {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--rva-blue);
  letter-spacing: 4px;
  line-height: 1.1;
}
.ticket-no { font-size: 0.88rem; font-weight: 800; margin-top: 4px; }
.ticket-valeur { font-size: 0.88rem; font-weight: 800; margin-top: 2px; }
.text-red { color: var(--rva-red); font-weight: 800; }
.ticket-controle {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--rva-red);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 5px;
  white-space: nowrap;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.ticket-rva { line-height: 1.35; font-size: 0.72rem; text-align: center; }
.ticket-rva-name { font-weight: 800; font-size: 0.8rem; }
.ticket-logo {
  display: block;
  width: 110px;
  height: 62px;
  margin: 2px auto;
  background: #fff;
  border: 1px solid var(--rva-blue);
  border-radius: 6px;
  object-fit: contain;
  padding: 2px;
}
.ticket-body {
  padding: 12px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}
.ticket-field { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.ticket-field-split { justify-content: space-between; gap: 14px; }
.tf-group { display: inline-flex; align-items: center; gap: 8px; }
.tf-label { font-weight: 800; font-size: 0.85rem; white-space: nowrap; }
.tf-value { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.ticket-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid #000;
}
.ticket-footer .ticket-field { margin: 0; }
.ticket-sign {
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---------- Modal d'aperçu ticket ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  max-width: 960px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.modal-head { display: flex; align-items: center; gap: 8px; }
.modal-head span { flex: 1; font-weight: 700; color: var(--rva-blue); }
#ticket-frame {
  width: 100%;
  height: 76vh;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

/* ---------- Permissions ---------- */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.perm-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  background: #fbfdff;
}
.perm-item:hover { background: #eef2ff; }
.perm-item input { margin-top: 4px; }
.perm-item small { color: #64748b; }

/* ---------- Audit ---------- */
.audit-diff summary { cursor: pointer; color: var(--rva-blue); font-weight: 600; font-size: 0.85rem; }
.diff-table { width: 100%; margin-top: 8px; }
.diff-table td, .diff-table th { padding: 6px 8px; font-size: 0.8rem; }
.diff-key { font-weight: 600; width: 120px; }
.diff-old { color: #991b1b; }
.diff-new { color: #166534; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Connexion ---------- */
.login-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrapper { width: 100%; max-width: 440px; padding: 20px; }
.login-header { color: white; text-align: center; margin-bottom: 20px; }
.login-logo {
  width: 150px;
  height: auto;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
}
.login-header h1 { margin: 0 0 6px; font-size: 1.5rem; }
.login-header p { margin: 0; opacity: 0.85; font-size: 0.9rem; }
.login-foot { color: rgba(255,255,255,0.7); text-align: center; font-size: 0.8rem; margin-top: 16px; }

/* ---------- Impression ---------- */
@page { size: A4 landscape; margin: 4mm; }
.print-area { display: none; }
@media print {
  .topbar, .nav, .flash-zone, .no-print { display: none !important; }
  body { background: #fff; }
  #app { max-width: none; margin: 0; padding: 0; }
  main { padding: 0; }
  .print-area { display: block !important; margin: 0; }

  /* Ticket paysage A4 */
  .ticket-preview.ticket-paysage { max-width: 100%; margin: 0; min-height: 190mm; }
  .ticket-side { width: 8mm; font-size: 10pt; letter-spacing: 1mm; }
  .ticket-top { padding: 2mm 4mm; gap: 4mm; }
  .ticket-body { padding: 3mm 4mm; }
  .ticket-big { font-size: 19pt; letter-spacing: 1mm; }
  .ticket-no, .ticket-valeur { font-size: 9pt; margin-top: 1mm; }
  .ticket-controle { font-size: 11pt; letter-spacing: 1mm; }
  .ticket-rva { font-size: 8pt; line-height: 1.3; }
  .ticket-rva-name { font-size: 9pt; }
  .ticket-logo { width: 18mm; height: 10mm; margin: 0.5mm auto; }
  .tf-label, .tf-value { font-size: 9.5pt; }
  .ticket-field { margin: 1.5mm 0; }
  .ticket-footer { margin-top: 2.5mm; padding-top: 2mm; }
  .ticket-sign { font-size: 9.5pt; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .header h1 { font-size: 1.2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: 0.8rem; }
  th, td { padding: 8px 6px; }
  .nav-user { display: none; }
  .topbar { flex-wrap: wrap; }
  .topbar-clock { display: none; }
  .user-info { display: none; }
  .brand-text h1 { font-size: 1.1rem; white-space: normal; }
  .profile-head { flex-direction: column; text-align: center; }
}
