/* =========================================
   Styles généraux - Administration
   ========================================= */
body { font-family: system-ui, sans-serif; margin: 0; background: #f5f6f8; color: #1f2937; }
header { background: #1e293b; color: #fff; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
h1 { margin: 0; font-size: 1.25rem; }
.nav-actions { display: flex; align-items: center; gap: 0.75rem; }
main { max-width: 1100px; margin: 1.5rem auto; background: #fff; padding: 1.5rem 2rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Utilitaires */
.hidden { display: none !important; }
.admin-panel { margin-bottom: 2.5rem; }

/* Bouton Lien vers le site */
.btn-link-site {
  display: inline-flex; align-items: center; gap: 0.4rem; color: #94a3b8;
  background-color: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.45rem 0.85rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500;
  text-decoration: none; transition: all 0.2s ease;
}
.btn-link-site:hover {
  color: #ffffff; background-color: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3); text-decoration: none;
}

/* Formulaires */
fieldset { border: 1px solid #e5e7eb; border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
legend { font-weight: 600; color: #334155; padding: 0 .35rem; }
label { display: block; font-size: .85rem; margin: .65rem 0 .25rem; color: #374151; }
input[type=text], input[type=date], input[type=time], input[type=number], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: .5rem .6rem; border: 1px solid #cbd5e1; border-radius: 4px; font-size: .95rem; box-sizing: border-box;
}
textarea { min-height: 100px; resize: vertical; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.actions { display: flex; gap: .75rem; margin-top: 1rem; }

/* Boutons */
button { cursor: pointer; padding: .55rem 1.1rem; border-radius: 4px; border: 1px solid transparent; font-size: .95rem; font-weight: 500; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
th { background: #f8fafc; font-weight: 600; }

/* Feedbacks et divers */
.feedback { margin-top: 1rem; padding: .75rem 1rem; border-radius: 4px; }
.feedback.success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.feedback.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.hint { font-size: .8rem; color: #64748b; }
.checkbox-row { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-top: .5rem; }
.checkbox-row label { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .9rem; }

/* Modales HTML5 standard */
dialog::backdrop { background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(2px); }
#modal-event { border: none; border-radius: 8px; padding: 0; max-width: 850px; width: 95%; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2); }
#modal-demande-detail { border: none; border-radius: 8px; padding: 1.5rem; max-width: 500px; width: 90%; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2); }
#modal-factures { border: none; border-radius: 8px; padding: 0; max-width: 750px; width: 95%; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2); }
#modal-event-participants { border: none; border-radius: 8px; padding: 0; max-width: 950px; width: 95%; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2); }
.modal-header { background: #1e293b; color: #fff; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; max-height: 80vh; overflow-y: auto; }
.close-modal-btn { background: transparent; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1; }

/* --- Bouton / Badge Participants dans la table admin --- */
.btn-participants-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-participants-badge:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}
.btn-participants-badge.complet {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Synthèse modale participants (Pills) */
.participants-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.summary-pill {
  padding: 0.75rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border: 1px solid transparent;
}
.summary-pill .label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.summary-pill .count { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.summary-pill.total   { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.summary-pill.warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.summary-pill.info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.summary-pill.danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Pastilles statuts dans le tableau participants */
.status-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.status-pill.paye        { background: #dcfce7; color: #15803d; }
.status-pill.non-paye    { background: #fef3c7; color: #b45309; }
.status-pill.en-attente  { background: #e0f2fe; color: #0369a1; }
.status-pill.refuse      { background: #fee2e2; color: #b91c1c; }

/* =========================================
   Vue mobile compacte : cartes repliables
   ========================================= */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 1rem; text-align: center; padding: 1rem; }
  .nav-actions { width: 100%; justify-content: center; flex-wrap: wrap; }
  main { margin: 1rem; padding: 1rem; }
  .admin-panel > div[style*="display: flex"] { flex-direction: column; align-items: flex-start !important; gap: 1rem; }
  button { padding: .65rem 1.2rem; }

  /* La table devient une pile de cartes */
  table, thead, tbody, th, td, tr { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tbody { width: 100%; }

  /* Le conteneur de la carte */
  tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
  }

  /* La zone des boutons (en bas de la carte) */
  #admin-events-list tr td:last-child, 
  #admin-demandes-list tr td:last-child, 
  #admin-messages-list tr td:last-child { 
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 1rem !important;
    border-top: 1px solid #e2e8f0;
    text-align: left !important; 
    white-space: normal !important; 
  }

  tbody td {
    display: none;
    min-width: 0;
    padding: 0 !important;
    border: 0;
    text-align: left !important;
    word-break: break-word;
  }

  /* Cellules affichées quand la carte est repliée */
  /* Événements : Titre (1), Ville (2), Participants (6), Actions (7) */
  #admin-events-list tr td:nth-child(1),
  #admin-events-list tr td:nth-child(2),
  #admin-events-list tr td:nth-child(6),
  #admin-events-list tr td:nth-child(7),
  /* Demandes : Date (1), Salon (2), Actions (7) */
  #admin-demandes-list tr td:nth-child(1),
  #admin-demandes-list tr td:nth-child(2),
  #admin-demandes-list tr td:nth-child(7),
  /* Messages : Date (1), Expéditeur (2), Actions (5) */
  #admin-messages-list tr td:nth-child(1),
  #admin-messages-list tr td:nth-child(2),
  #admin-messages-list tr td:nth-child(5) { 
    display: block; 
  }

  /* Typographie */
  #admin-events-list tr td:nth-child(1), #admin-demandes-list tr td:nth-child(2), #admin-messages-list tr td:nth-child(2) { font-weight: 650; }
  #admin-events-list tr td:nth-child(2), #admin-demandes-list tr td:nth-child(1), #admin-messages-list tr td:nth-child(1) { color: #64748b; font-size: .88rem; }

  /* Boutons d'actions */
  #admin-events-list tr td:last-child, #admin-demandes-list tr td:last-child, #admin-messages-list tr td:last-child { 
    grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right !important; white-space: normal !important; 
  }

  /* Au clic, afficher le détail de la carte */
  tbody tr.card-expanded { display: block; }
  tbody tr.card-expanded td { display: block !important; padding: .55rem 0 !important; border-bottom: 1px solid #f1f5f9; }
  tbody tr.card-expanded td:last-child { border-bottom: 0; text-align: right !important; }
  tbody tr.card-expanded td::before { content: attr(data-label); display: block; margin-bottom: .2rem; color: #64748b; font-size: .78rem; font-weight: 600; }
  tbody tr.card-expanded td:last-child::before { content: none; }

  /* --- GESTION DU TABLEAU DES CONFÉRENCES SUR MOBILE --- */
  #conferences-tbody tr {
    display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem; border: 1px solid #cbd5e1;
    border-radius: 8px; margin-bottom: 1rem; cursor: default;
  }
  #conferences-tbody tr td { display: block; padding: 0 !important; border: none; text-align: left !important; }
  #conferences-tbody tr td:nth-child(1) { font-weight: bold; font-size: 1.1rem; }
  #conferences-tbody tr td:nth-child(2) { color: #64748b; font-size: 0.9rem; }
  #conferences-tbody tr td:nth-child(3) { font-weight: 500; color: #0f172a; }
  #conferences-tbody tr td:last-child { margin-top: 0.5rem; padding-top: 0.5rem !important; border-top: 1px solid #e2e8f0; }

  /* --- GESTION DU TABLEAU DES FACTURES SUR MOBILE --- */
  #factures-list tr {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.9rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 0.85rem;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: default;
  }
  #factures-list tr td {
    display: block !important;
    padding: 0 !important;
    border: none;
    text-align: left !important;
  }
  #factures-list tr td:nth-child(1) {
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
  }
  #factures-list tr td:nth-child(2) {
    color: #64748b;
    font-size: 0.88rem;
    word-break: break-all;
  }
  #factures-list tr td:nth-child(3) {
    font-weight: 600;
    color: #16a34a;
    font-size: 0.95rem;
    margin-top: 0.2rem;
  }
  #factures-list tr td:last-child {
    display: flex !important;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem !important;
    border-top: 1px solid #f1f5f9;
  }
  #factures-list tr td:last-child button,
  #factures-list tr td:last-child a {
    width: 100%;
    text-align: center;
  }

  /* --- GESTION DU TABLEAU DES PARTICIPANTS (MODALE) SUR MOBILE --- */
  #event-participants-list tr {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.85rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: default;
  }
  #event-participants-list tr td {
    display: block !important;
    padding: 0 !important;
    border: none;
    text-align: left !important;
  }
  #event-participants-list tr td:nth-child(1) { font-weight: 700; font-size: 0.95rem; color: #0f172a; }
  #event-participants-list tr td:nth-child(2) { color: #64748b; font-size: 0.85rem; }
}

/* =========================================
   Styles pour l'impression (Génération PDF)
   ========================================= */
@media print {
  @page { margin: 1.5cm; size: auto; }
  body > *:not(#modal-conferences) { display: none !important; }
  .no-print, .modal-header, #conferences-list-container, fieldset, dialog::backdrop { display: none !important; }

  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; height: auto !important; min-height: 0 !important; overflow: visible !important; }
  dialog { display: block !important; position: static !important; margin: 0 !important; padding: 0 !important; border: none !important; box-shadow: none !important; width: 100% !important; max-width: 100% !important; height: auto !important; max-height: none !important; overflow: visible !important; }

  #print-area { display: block !important; visibility: visible !important; position: static !important; width: 100% !important; margin: 0 !important; padding: 0 !important; color: #000 !important; background: #fff !important; }
  #print-area * { visibility: visible !important; }

  .print-table { display: table !important; width: 100% !important; border-collapse: collapse !important; margin-top: 0.8rem !important; margin-bottom: 1.5rem !important; page-break-inside: auto; }
  .print-table thead { display: table-header-group !important; }
  .print-table tbody { display: table-row-group !important; }
  .print-table tr { display: table-row !important; page-break-inside: avoid; page-break-after: auto; }
  .print-table th, .print-table td { display: table-cell !important; border: 1px solid #333 !important; padding: 6px 8px !important; text-align: left !important; color: #000 !important; background: transparent !important; font-size: 13px !important; line-height: 1.2 !important; }
  .print-table th { font-weight: bold !important; background-color: #f3f4f6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .print-title-date { font-size: 1.1rem !important; margin-top: 1.2rem !important; margin-bottom: 0.5rem !important; border-bottom: 1.5px solid #000 !important; color: #000 !important; padding-bottom: 3px !important; page-break-after: avoid; }
}