/* global.css */

:root {
  /* Couleurs de base */
  --primary: #3b82f6;
  --primary-dark: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Textes & Fonds */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-page: #f8fafc;
  --bg-panel: #ffffff;

  /* Bordures, Arrondis & Ombres */
  --border-light: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* 🛡️ RESET MOBILE UNIVERSEL */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}
body.no-scroll {
  overflow: hidden !important;
  height: 100vh !important;
}

/* === HEADER & NAVIGATION === */
.pf-header {
  background: white;
  border-bottom: 1px solid var(--border-light);
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.pf-logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.pf-nav {
  display: flex;
  gap: 8px;
}
.pf-nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}
.pf-nav-link:hover {
  background: #f1f5f9;
  color: var(--text-main);
}
.pf-nav-link--active {
  background: #eff6ff;
  color: var(--primary);
}
.pf-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.pf-user-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pf-logout-btn {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.pf-logout-btn:hover {
  background: #fef2f2;
  border-color: #fecaca;
}
.pf-burger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-main);
}

/* === MENU MOBILE (Sidebar "Off-Canvas") === */
.pf-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.pf-mobile-overlay.is-visible {
  display: block;
  opacity: 1;
}

.pf-mobile-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh; /* Fallback (sécurité) */
  height: 100dvh;
  background: var(--bg-panel);
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
  z-index: 999;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 0;
  color: var(--text-main);
}

.pf-mobile-menu.is-open {
  right: 0; /* Le menu glisse dans l'écran */
}

.pf-mobile-menu-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-page);
}

.pf-mobile-close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.pf-mobile-menu-body {
  padding: 20px;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.pf-mobile-nav-link {
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-main);
  padding: 14px 16px; /* Plus large pour le tactile */
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}

.pf-mobile-nav-link:active {
  background: #f1f5f9;
}

.pf-mobile-logout {
  color: var(--danger);
  background: #fef2f2;
  margin-top: 10px;
}

.pf-mobile-menu-header .pf-logo,
body.pf-home .pf-mobile-menu-header .pf-logo {
  color: var(--primary);
}

/* Force la croix en gris, MÊME sur la page d'accueil */
.pf-mobile-close-btn,
body.pf-home .pf-mobile-close-btn {
  color: var(--text-muted);
}

.pf-mobile-close-btn:hover {
  color: var(--danger); /* Touche de rouge au survol */
}

/* === MAIN CONTENT & TYPOGRAPHY === */
.pf-main {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px;
}
.pf-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--text-main);
  line-height: 1.2;
}
p {
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* === COMPOSANTS GLOBAUX === */
.pf-modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 32px;
}
.pf-module-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pf-module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}
.pf-card-icon {
  font-size: 2rem;
  margin-bottom: 4px;
}
.pf-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}
.pf-card-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  flex: 1;
}
.pf-card-cta {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Boutons Standards */
.pf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  padding: 12px 24px;
  text-decoration: none;
}
.pf-btn:hover {
  background: var(--primary-dark);
}
.pf-btn.btn-secondary {
  background: white;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.pf-btn.btn-secondary:hover {
  background: #f8fafc;
  color: var(--text-main);
  border-color: #94a3b8;
}

/* Formulaires & Inputs Standards */
.pf-form-group {
  margin-bottom: 20px;
}
.pf-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.pf-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 1rem;
  background: #f8fafc;
  color: var(--text-main);
  transition: all 0.2s;
  font-family: inherit;
  box-sizing: border-box;
}
.pf-input:focus {
  background: white;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tableaux Standards */
.pf-table {
  width: 100%;
  background: var(--bg-panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.pf-table th {
  background: #f8fafc;
  padding: 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.pf-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-page);
  vertical-align: middle;
  font-size: 0.95rem;
}
.pf-table tbody tr:last-child td {
  border-bottom: none;
}
.pf-table tbody tr:hover {
  background-color: #f8fafc;
}

/* === 🪟 LE DESIGN SYSTEM DES MODALES (Applicable partout) === */
.pf-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pf-modal.is-active,
.pf-modal.open {
  display: flex;
} /* Supporte tes deux syntaxes JS */

.pf-modal-content {
  background: var(--bg-panel);
  width: 100%;
  max-width: 500px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: pfModalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  margin: auto;
}
.pf-modal-title {
  margin-top: 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 15px;
  margin-bottom: 8px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  width: 100%;
  box-sizing: border-box;
}
.modal-footer .pf-btn {
  width: auto;
  min-width: 100px;
  padding: 10px 20px;
} /* Ajustement pour modale */

@keyframes pfModalPop {
  from {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* === FOOTER & TOASTS === */
.pf-footer {
  border-top: 1px solid var(--border-light);
  background: white;
  padding: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}
.pf-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border-left: 5px solid var(--primary);
  z-index: 10000;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-weight: 600;
  color: var(--text-main);
}
.pf-toast.is-visible {
  transform: translateX(0);
}

/* === RESPONSIVE MOBILE === */
@media (max-width: 768px) {
  .pf-header {
    padding: 0 16px;
  }
  .pf-nav,
  .pf-header-actions {
    display: none;
  }
  .pf-burger-btn {
    display: block;
  }
  .pf-main {
    padding: 16px 10px;
  }
  .pf-mobile-nav-link {
    font-size: 1.2rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-main);
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
  }

  /* 📱 BOTTOM SHEET MODALES MOBILE */
  .pf-modal {
    align-items: center !important; /* On remet au centre */
    padding: 20px;
  }
  .pf-modal-content {
    width: 100% !important;
    max-width: none !important;
    border-radius: 20px !important; /* On garde les arrondis partout */
    transform: none !important;
    animation: pfModalPop 0.3s ease !important; /* On remet l'animation desktop */
    margin: auto !important;
  }
  .pf-modal-content::before {
    content: "";
    display: block;
    width: 40px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 10px;
    margin: -10px auto 20px auto;
  }
  .modal-footer {
    flex-direction: column-reverse;
  }
  .modal-footer .pf-btn {
    width: 100%;
    margin-top: 8px;
  }

  @keyframes slideUpSheet {
    to {
      transform: translateY(0);
    }
  }
}

/* === BOUTONS D'ACTION ICÔNES UNIVERSELS (Édition / Suppression) === */
.btn-icon-action {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}
.btn-icon-action.edit {
  color: var(--primary);
}
.btn-icon-action.edit:hover {
  background: #eff6ff; /* Fond bleu très clair au survol */
}
.btn-icon-action.delete {
  color: var(--danger);
}
.btn-icon-action.delete:hover {
  background: #fef2f2; /* Fond rouge très clair au survol */
}

/* === 13. PAGE DE CONNEXION (LOGIN) === */
.pf-login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
  padding: 20px;
}

.pf-login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

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

.pf-login-header .pf-login-icon {
  width: 60px; /* Tu peux ajuster cette valeur selon le rendu voulu */
  height: auto;
  margin-bottom: 15px;
  border-radius: 12px; /* Optionnel : ajoute un léger arrondi si ton favicon est carré */
}

.pf-login-header h1 {
  font-size: 1.8rem;
  margin: 0;
  color: var(--text-main);
}

.pf-login-header p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 0.95rem;
}

.pf-login-error {
  background: #fef2f2;
  color: #ef4444;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #fca5a5;
  margin-bottom: 20px;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
}

.pf-btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 10px;
  padding: 14px;
  font-size: 1.05rem;
}

/* --- Optimisation Login Mobile --- */
@media (max-width: 480px) {
  .pf-login-wrapper {
    padding: 0;
    align-items: flex-start; /* Aligné en haut pour laisser de la place au clavier */
    background: var(--bg-panel);
  }

  .pf-login-card {
    border-radius: 0; /* Supprime les arrondis pour un look plein écran */
    border: none;
    box-shadow: none;
    padding: 60px 24px;
    min-height: 100vh;
  }
}

/* ⚠️ IMPORTANT : Éviter le zoom auto sur iOS */
.pf-login-card .pf-input {
  font-size: 16px; /* En dessous de 16px, Safari iOS zoome automatiquement sur le champ */
  padding: 14px; /* Zone de clic plus large pour les doigts */
}

.pf-btn-block {
  padding: 16px; /* Bouton plus haut pour un appui facile au pouce */
  font-size: 1.1rem;
}
