/**
 * Styles globaux — variables CSS, header, footer, modals, formulaires, badges
 *
 * @version  1.0.0
 * @since    2.7.0 (GunsAcademy)
 * @depends  Chargé par toutes les pages de l'application
 */

/* ── Variables globales ────────────────────────────────────────────────────
   Valeurs par défaut (thème "GunsAcademy" bleu marine).
   Écrasées dynamiquement par /api/theme.css.php qui lit les couleurs en BDD.
   Chaque page inclut ce fichier d'abord, puis theme.css.php en second pour
   que les variables personnalisées aient la priorité. */
:root {
  --color-primary:      #0C1323;   /* fond header, boutons principaux */
  --color-primary-text: #ffffff;   /* texte sur fond primary */
  --color-bg:           #f5f5f5;   /* fond de page */
  --color-card:         #ffffff;   /* fond des cartes / modals */
  --color-text:         #212121;   /* texte courant */
  --color-danger:       #c62828;   /* boutons danger, messages d'erreur */
}

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

/* ── Layout racine ──────────────────────────────────────────────────────────
   flex-direction:column + min-height:100vh → footer collé en bas de page
   même quand le contenu est court. */
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-primary);
  color: var(--color-primary-text);
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  position: relative;
  z-index: 10;
}

.header-title { font-size: 1.25rem; font-weight: 700; }

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.header-user button {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s;
}
.header-user button:hover { background: rgba(255,255,255,.25); }

/* ── Conteneur FullCalendar ─────────────────────────────────────────────────
   display:none par défaut — app.js l'active après vérification de la session.
   Masquer en CSS évite un flash de contenu avant que refreshUser() soit résolu. */
#calendar {
  width: 100%;
  max-width: 80vw;
  margin: 1rem auto;
  background: var(--color-card);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  padding: 1rem;
  display: none;
}

/* ─── Landing page (non connecté) ──────────────────────────────────────── */

#loginWall {
  display: none;
  flex: 1;
  flex-direction: column;
}

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 2rem;
  gap: 2rem;
}

.landing-logo {
  width: clamp(180px, 60vw, 520px);
  max-height: 65vh;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}

.landing-liens {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.landing-liens-label {
  font-size: 0.78rem;
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.eden-logo {
  height: 72px;
  width: auto;
  transition: opacity .15s;
}

.eden-logo:hover { opacity: 0.75; }

/* ─── Modals ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 0;
  overflow-y: auto;
  z-index: 9999;
}

.modal {
  background: var(--color-card);
  border-radius: 8px;
  padding: 2rem;
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  position: relative;
}

.modal h2 { color: var(--color-primary); font-size: 1.2rem; } /* hors modal-header */

.modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #424242;
}

.modal input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color .15s;
}
.modal input:focus { outline: none; border-color: var(--color-primary); }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity .15s;
}
.modal-actions button:first-child { background: var(--color-primary); color: var(--color-primary-text); }
.modal-actions button:last-child  { background: #e0e0e0; color: #424242; }
.modal-actions button:hover { opacity: 0.85; }
/* En-tête modal : titre à gauche, bouton ✕ à droite */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.modal-header h2 { margin: 0; color: var(--color-primary); font-size: 1.2rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #9e9e9e;
  line-height: 1;
  padding: .2rem .45rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.modal-close:hover { background: #f5f5f5; color: #212121; }


.info-box {
  background: #e8eaf6;
  border-left: 4px solid var(--color-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--color-primary);
}

.cout-preview {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 0.95rem;
}

.error-msg {
  color: var(--color-danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.btn-admin {
  background: rgba(255,255,255,.9);
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background .15s;
}
.btn-admin:hover { background: #fff; }


/* ── Boutons d'action ───────────────────────────────────────────────────────
   btn-danger  : suppression, annulation (rouge)
   btn-perm    : variante du btn-admin pour permanents (bleu clair)
   La couleur primaire est volontairement codée en dur ici pour le btn-danger :
   le rouge de danger ne doit pas suivre le thème personnalisable. */
.btn-danger { background: var(--color-danger); color: #fff; border: none; padding: 0.5rem 1.2rem; border-radius: 4px; cursor: pointer; font-size: 0.95rem; }
.btn-danger:hover { opacity: .85; }
.btn-perm { background: #6b9fcc; }
.btn-admin-root { background: var(--color-danger, #c62828); color: #fff; }
.btn-admin-root:hover { background: #b71c1c !important; }

/* Bouton "Nouveau créneau" : seul point d'entrée en vue liste (mobile), où le
   calendrier n'a pas de cellule vide cliquable pour dateClick. */
#creneauNouveauWrap { margin: 0.75rem 1rem 0; }
.btn-nouveau-creneau {
  background: var(--color-primary, #0C1323);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-nouveau-creneau:hover { opacity: .88; }

/* Footer */
footer.app-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  background: var(--color-primary);
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
footer.app-footer .footer-left,
footer.app-footer .footer-right { line-height: 1.7; }
footer.app-footer .footer-right { text-align: right; }
footer.app-footer a { color: rgba(255,255,255,0.85); text-decoration: none; }
footer.app-footer a:hover { text-decoration: underline; }

.book-lignes-group { display: flex; gap: 1.5rem; padding: 0.25rem 0; }
.book-lignes-group label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-weight: normal; }

/* ── Événements FullCalendar : stand complet ────────────────────────────────
   stand-complet      : violet clair — créneau sans lignes disponibles
   stand-complet.stand-mine : orange — le stand est complet ET c'est ma réservation
   !important nécessaire car FullCalendar applique ses propres styles inline. */
.fc-event.stand-complet {
  background-color: #e1bee7 !important;
  border-width: 2px !important;
  font-weight: bold !important;
}
.fc-event.stand-complet.stand-mine {
  background-color: #e65100 !important;
  border-color: #7b1fa2 !important;
}

/* Récurrence créneaux */
.recur-row { margin: .5rem 0 .25rem; }
.recur-toggle-label { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
#creneauRecurOptions { margin-top: .5rem; padding: .6rem .8rem; background: #f0f4ff; border-radius: 6px; display: flex; flex-direction: column; gap: .4rem; }
#creneauRecurOptions label { font-size: .9rem; }
.recur-hint { margin: 0; font-size: .78rem; color: #666; font-style: italic; }

/* Logo header */
.header-logo {
  height: 38px;
  width: auto;
  margin-right: 0.75rem;
  border-radius: 3px;
  display: block;
  flex-shrink: 0;
}

/* Groupe logo + titre côte à côte */
.header-brand {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Badges partagés (admin, account, user) */
.badge        { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 12px; font-size: 0.82rem; font-weight: 600; }
.badge-admin  { background: #ffebee; color: #c62828; }
.badge-membre { background: #e3f2fd; color: #6b9fcc; }
.badge-perm   { background: #e8eaf6; color: #7b92c8; margin-left: 0.3rem; }
.badge-fo     { background: #e8eaf6; color: #3949ab; margin-left: 0.3rem; font-weight: 700; }

/* Bannière mot de passe temporaire */
.force-change-banner { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; border-radius: 8px; padding: 0.9rem 1.2rem; margin-bottom: 1.2rem; font-weight: 600; }

/* Bouton retour calendrier (partage header) */
.btn-back { color: #fff; text-decoration: none; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); padding: 0.35rem 0.9rem; border-radius: 4px; font-size: 0.9rem; transition: background .15s; }
.btn-back:hover { background: rgba(255,255,255,.25); }

/* ── Modal aide (iframe) ────────────────────────────────────────────────────
   La page aide.php est chargée dans une iframe avec ?embed=1 pour masquer
   header/footer et adapter le fond à la carte (background:var(--color-card)).
   width min(920px, 96vw) : large sur desktop, plein écran sur mobile. */
.aide-modal-wrap {
  background: var(--color-card, #fff);
  width: min(920px, 96vw);
  height: 85vh;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.aide-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 10;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.12);
  color: #333;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aide-modal-close:hover { background: rgba(0,0,0,.22); }
.aide-modal-frame { width: 100%; flex: 1; border: none; }

/* ── Token info popover ──────────────────────────────────────────────────── */
.token-info-btn {
  background: none;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  width: 1.15em;
  height: 1.15em;
  font-size: 0.72em;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
  padding: 0;
  vertical-align: middle;
  margin-left: 4px;
  color: inherit;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.token-info-btn:hover { opacity: 1; }
.token-popover {
  position: fixed;
  background: #fff;
  border: 1px solid #bdbdbd;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
  padding: 0.7rem 1rem;
  max-width: 280px;
  font-size: 0.87rem;
  line-height: 1.55;
  z-index: 9999;
  color: #333;
  pointer-events: none;
}
.token-popover strong { display: block; margin-bottom: 0.25em; color: #1a237e; }

/* Burger caché sur desktop */
.burger-btn { display: none; }

/* ── Responsive mobile (≤ 768px) ──────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Header : logo + burger sur une ligne */
  header {
    padding: 0.6rem 0.9rem;
  }
  .header-title { display: none; }
  .header-logo  { height: 32px; }

  /* Menu caché par défaut — révélé par burger-open */
  .header-user {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--color-primary);
    padding: 0.6rem 0.75rem;
    min-width: 190px;
    gap: 0.4rem;
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
    border-top: 1px solid rgba(255,255,255,.15);
    z-index: 100;
  }
  .header-user.burger-open { display: flex; }

  .header-user button,
  .header-user .btn-admin,
  .header-user .btn-back {
    font-size: 0.88rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
    text-align: left;
  }

  /* Bouton burger */
  .burger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Calendrier */
  #calendar {
    margin: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    max-width: none;
    width: 100%;
  }

  /* Modals : boutons pleine largeur, empilés */
  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }
  .modal-actions button {
    width: 100%;
    padding: 0.65rem;
  }

  /* Calendrier : titre sur sa propre ligne au-dessus des boutons */
  .fc .fc-header-toolbar { flex-wrap: wrap; gap: 0.3rem 0; }
  .fc .fc-header-toolbar .fc-toolbar-chunk:nth-child(2) {
    width: 100%;
    text-align: center;
    order: -1;
  }
  .fc .fc-toolbar-title { font-size: 0.95rem; }

  /* Tables débordantes → scroll horizontal */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Footer : empiler les deux colonnes */
  footer.app-footer {
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    text-align: center;
  }
  footer.app-footer .footer-right { display: none; }
}

/* ── Accès libre ─────────────────────────────────────────────────────────── */

/* La cellule allDay (rangée "info") en mode timeGrid doit être relative
   pour que le badge AL soit positionné en son centre */
.fc-timegrid .fc-daygrid-day { position: relative; }

/* Empêcher le curseur "pointeur" sur la cellule info elle-même */
.fc-timegrid .fc-daygrid-day-frame { cursor: default; }

.al-toggle-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  background: #f1f8e9;
  color: #558b2f;
  border: 1px solid #aed581;
  line-height: 1.4;
  user-select: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.al-toggle-btn:hover { background: #dcedc8; }
.al-readonly-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid #a5d6a7;
  cursor: default;
  white-space: nowrap;
}
.al-toggle-btn.al-active {
  background: #4caf50;
  color: #fff;
  border-color: #388e3c;
}
.al-toggle-btn.al-active:hover { background: #388e3c; }

/* Créneaux en display:background (2026-08-01) — FullCalendar applique par défaut
   opacity:.3, ce qui rendait les créneaux quasi invisibles (couleurs déjà pastel).
   On restaure une opacité pleine + une bordure. Correctif du 2026-08-01 : FullCalendar
   rendait déjà un .fc-event-title natif (en italique) pour ces événements — invisible
   jusqu'ici à cause de l'opacité 30%, mais bien présent dans le DOM. En le découvrant
   après coup (une fois l'opacité corrigée), on se retrouvait avec DEUX libellés
   visibles : le natif (italique) et le nôtre (.creneau-bg-label, injecté en pensant
   que FullCalendar n'affichait rien). On masque le natif, on garde le nôtre — plus
   simple à styler/positionner que de reprendre le rendu FullCalendar par défaut. */
.fc-bg-event.creneau-bg {
  opacity: 1 !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  z-index: 1; /* au-dessus des lignes de grille/plages horaires, sous les réservations */
}
.fc-bg-event.creneau-bg .fc-event-title {
  display: none;
}
.creneau-bg-label {
  position: absolute;
  /* En haut-gauche (2026-08-01, v2) : les réservations sont désormais alignées à
     droite en carrés de largeur fixe (cf. eventDidMount, app.js) — la partie
     gauche du créneau reste libre tant que le stand n'est pas complet. max-width
     évite de chevaucher les carrés de réservation quand ils sont larges. */
  top: 2px;
  left: 4px;
  max-width: 55%;
  font-size: 0.72rem;
  line-height: 1.2;
  color: #333 !important;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Carrés de réservation en vue Semaine (2026-08-01, v3) : le texte natif FullCalendar
   (nom du tireur, heure) devient illisible/parasite une fois réduit à un petit carré —
   masqué, l'info reste disponible au survol (title, déjà posé en JS). En vue Jour
   (2026-08-01, v7), les rectangles sont assez larges (75% de la colonne) pour que le
   texte reste lisible et utile — on ne masque donc que pour Semaine/Mois, pas Jour. */
.fc-timeGridWeek-view .fc-timegrid-event.resa-square .fc-event-main-frame,
.fc-timeGridWeek-view .fc-timegrid-event.resa-square .fc-event-time,
.fc-timeGridWeek-view .fc-timegrid-event.resa-square .fc-event-title {
  display: none;
}

