:root {
  --navy-900: #0f2438;
  --navy-800: #16324a;
  --navy-700: #1c3f5e;
  --orange-500: #f2792a;
  --orange-600: #e0661a;
  --orange-100: #fdece0;
  --green-600: #1e8e5a;
  --green-100: #e3f6ec;
  --amber-600: #b9760a;
  --amber-100: #fdf1de;
  --red-600: #c53939;
  --red-100: #fce9e9;
  --blue-600: #0b6bcb;
  --blue-100: #e5f1fc;
  --bg-app: #f2f5f9;
  --border-soft: #e3e8ee;
  --text-main: #1e2b3a;
  --text-muted: #6b7a8c;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgba(15, 36, 56, 0.08), 0 1px 2px rgba(15, 36, 56, 0.04);
}

* { box-sizing: border-box; }

body {
  background: var(--bg-app);
  color: var(--text-main);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

a { text-decoration: none; }

/* ---------- Barre de navigation ---------- */
.gp-navbar {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-800));
  padding: 0 1.5rem;
  box-shadow: 0 2px 8px rgba(15, 36, 56, 0.25);
  position: sticky;
  top: 0;
  z-index: 50;
}

.gp-navbar-row {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 0.5rem;
}

.gp-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  margin-right: 2rem;
  white-space: nowrap;
}

/* Bouton hamburger : masqué sur grand écran, visible sous 960px.
   Les 3 barres sont positionnées en absolu (top fixe) ; l'état ouvert anime
   uniquement "top" et "transform: rotate(...)" séparément — jamais combinés
   dans une seule fonction transform — pour un rendu fiable sur tous les
   moteurs de rendu, anciens comme récents. */
.gp-nav-toggle {
  display: none;
  position: relative;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
  margin-left: auto;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.gp-nav-toggle span {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  margin-left: -9px;
  margin-top: -1px;
  background: #fff;
  border-radius: 1px;
  transition: top 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}
.gp-nav-toggle span:nth-child(1) { top: calc(50% - 6px); }
.gp-nav-toggle span:nth-child(3) { top: calc(50% + 6px); }
.gp-nav-toggle.ouvert span:nth-child(1) { top: 50%; transform: rotate(45deg); }
.gp-nav-toggle.ouvert span:nth-child(2) { opacity: 0; }
.gp-nav-toggle.ouvert span:nth-child(3) { top: 50%; transform: rotate(-45deg); }

.gp-nav-admin-link { display: none; }

.gp-logo-badge {
  background: var(--orange-500);
  color: #fff;
  font-weight: 800;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.gp-nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.gp-nav-links a {
  color: #b9c8d8;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.gp-nav-links a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.gp-nav-links a.active {
  color: #fff;
  background: rgba(242, 121, 42, 0.18);
  border-bottom: 2px solid var(--orange-500);
}

.gp-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--orange-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ---------- Navigation mobile (< 960px) ----------
   Placé après les règles de base ci-dessus afin de bien les surcharger
   (même spécificité : l'ordre dans la feuille de style fait foi). */
@media (max-width: 960px) {
  .gp-navbar { padding: 0 1rem; }
  .gp-nav-toggle { display: flex; }
  .gp-avatar { display: none; }

  .gp-nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0.15rem;
    background: var(--navy-800);
    padding: 0.75rem 1rem 1.25rem;
    box-shadow: 0 10px 20px rgba(15, 36, 56, 0.3);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  .gp-nav-links.ouvert { display: flex; }
  .gp-nav-links a { padding: 0.75rem 0.9rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-radius: 8px; }
  .gp-nav-links a.active { border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-left: 3px solid var(--orange-500); }
  .gp-nav-admin-link { display: block; color: #b9c8d8; }
}

/* ---------- Conteneur principal ---------- */
.gp-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.gp-breadcrumb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.gp-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.gp-page-title { font-size: 1.6rem; font-weight: 800; margin: 0; color: var(--navy-900); }
.gp-page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ---------- Boutons ---------- */
.btn-gp-orange {
  background: var(--orange-500);
  border: 1px solid var(--orange-500);
  color: #fff;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
}
.btn-gp-orange:hover { background: var(--orange-600); border-color: var(--orange-600); color: #fff; }

.btn-gp-navy {
  background: var(--navy-800);
  border: 1px solid var(--navy-800);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-md);
}
.btn-gp-navy:hover { background: var(--navy-700); color: #fff; }

.btn-gp-outline {
  background: #fff;
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  font-weight: 600;
  border-radius: var(--radius-md);
}
.btn-gp-outline:hover { background: #f7f9fb; }

.btn-gp-green {
  background: var(--green-600);
  border: 1px solid var(--green-600);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-md);
}
.btn-gp-green:hover { background: #17734a; color: #fff; }

/* ---------- Cartes KPI ---------- */
.gp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 900px) { .gp-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.gp-kpi-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.25rem;
  border-left: 4px solid var(--navy-800);
}
.gp-kpi-card.orange { border-left-color: var(--orange-500); }
.gp-kpi-card.green { border-left-color: var(--green-600); }
.gp-kpi-card.blue { border-left-color: var(--blue-600); }
.gp-kpi-card.red { border-left-color: var(--red-600); }

.gp-kpi-value { font-size: 1.9rem; font-weight: 800; color: var(--navy-900); line-height: 1.1; }
.gp-kpi-label { color: var(--text-main); font-weight: 600; margin-top: 0.15rem; font-size: 0.92rem; }
.gp-kpi-sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.2rem; }

/* ---------- Cartes / panneaux ---------- */
.gp-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}
.gp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.gp-card-title { font-weight: 700; font-size: 1.05rem; color: var(--navy-900); }

/* ---------- Tableaux ---------- */
.table-gp {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-gp thead th {
  background: var(--navy-800);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: none;
  padding: 0.7rem 0.9rem;
  white-space: nowrap;
}
.table-gp thead th:first-child { border-top-left-radius: 8px; }
.table-gp thead th:last-child { border-top-right-radius: 8px; }
.table-gp tbody td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88rem;
  vertical-align: middle;
}
.table-gp tbody tr:hover { background: #f8fafc; }
.table-gp tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges de statut ---------- */
.badge-statut {
  display: inline-block;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-pending { background: var(--amber-100); color: var(--amber-600); }
.badge-send { background: var(--green-100); color: var(--green-600); }
.badge-error { background: var(--red-100); color: var(--red-600); }
.badge-partial { background: var(--blue-100); color: var(--blue-600); }
.badge-actif { background: var(--green-100); color: var(--green-600); }
.badge-inactif { background: var(--red-100); color: var(--red-600); }

/* ---------- Formulaires ---------- */
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--text-main); }
.form-control:focus, .form-select:focus {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 0.2rem rgba(242, 121, 42, 0.15);
}
.gp-readonly {
  background: #f4f6f9;
  color: var(--text-muted);
}

.gp-variable-tag {
  display: inline-block;
  background: var(--blue-100);
  color: var(--blue-600);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.2rem 0.3rem 0.2rem 0;
  cursor: pointer;
  border: none;
}
.gp-variable-tag:hover { background: #d7ebfb; }

/* ---------- Modale de sélection ---------- */
.gp-modal-overlay {
  background: rgba(15, 36, 56, 0.55);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem;
}
.gp-modal {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(15, 36, 56, 0.35);
}
.gp-modal-header {
  background: var(--navy-800);
  color: #fff;
  padding: 1.1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gp-modal-body { padding: 1.5rem; max-height: 60vh; overflow-y: auto; }
.gp-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gp-modal-close {
  background: var(--red-600);
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none;
}

/* ---------- Aperçu courriel ---------- */
.gp-mail-preview {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.gp-mail-meta {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-soft);
  padding: 0.55rem 1.25rem;
  font-size: 0.87rem;
  display: flex;
  gap: 0.5rem;
}
.gp-mail-meta strong { color: var(--text-muted); min-width: 40px; display: inline-block; }
.gp-mail-body { padding: 1.5rem; white-space: pre-line; line-height: 1.6; }
.gp-mail-iframe {
  display: block;
  width: 100%;
  min-height: 320px;
  border: none;
  background: #f2f5f9;
}

.gp-mail-attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--blue-100);
  color: var(--blue-600);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.4rem;
}

.gp-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.gp-login-check { accent-color: var(--orange-500); }

/* ---------- Tableaux défilables horizontalement (mobile) ---------- */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ---------- Ajustements généraux petits écrans ---------- */
@media (max-width: 576px) {
  .gp-container { padding: 1.1rem 0.85rem 2.25rem; }
  .gp-card { padding: 1.1rem; }
  .gp-modal-overlay { padding: 0; align-items: stretch; }
  .gp-modal { max-width: 100%; min-height: 100vh; border-radius: 0; }
  .gp-modal-body { max-height: calc(100vh - 128px); }
  .gp-page-title { font-size: 1.35rem; }
  .gp-page-header { flex-direction: column; align-items: stretch; }
  .gp-page-header .btn,
  .gp-page-header a.btn { width: 100%; text-align: center; }
  .gp-kpi-value { font-size: 1.6rem; }
  .gp-mail-meta { flex-wrap: wrap; }
}

/* Champs générés par Django sans classe Bootstrap (changement de mot de passe) */
.gp-card input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}
