/* ═══════════════════════════════════════════════════════════════════════════
   Papillon'pédia — Design System v2
   Langage visuel unifié : slate + indigo + system font
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  /* Palette principale */
  --c-bg:        #f1f5f9;
  --c-surface:   #ffffff;
  --c-border:    #e2e8f0;
  --c-border-md: #cbd5e1;

  /* Texte */
  --c-text:      #0f172a;
  --c-text-md:   #1e293b;
  --c-text-sm:   #475569;
  --c-text-xs:   #94a3b8;

  /* Primaire — indigo */
  --c-primary:   #4f46e5;
  --c-primary-h: #4338ca;
  --c-primary-bg:#eff6ff;

  /* Alertes */
  --c-rouge-bg:   #fef2f2; --c-rouge-border: #fca5a5; --c-rouge-text: #991b1b;
  --c-orange-bg:  #fff7ed; --c-orange-border:#fdba74; --c-orange-text: #9a3412;
  --c-yellow-bg:  #fffbeb; --c-yellow-border:#fcd34d; --c-yellow-text: #92400e;
  --c-green-bg:   #f0fdf4; --c-green-border: #86efac; --c-green-text:  #15803d;

  /* Sidebar */
  --c-sidebar:   #0f172a;
  --c-sidebar-h: #1e293b;

  /* Misc */
  --radius-sm:  6px;
  --radius:     8px;
  --radius-lg: 12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --transition: .15s ease;
}

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

hr { border: none; border-top: 1px solid var(--c-border); margin: 1rem 0; }


/* ══════════════════════════════════════════════════════════════════════════
   1. PAGE LOGIN
   ══════════════════════════════════════════════════════════════════════════ */
.login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #312e81 100%);
  padding: 1.5rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2rem 2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.logo-butterfly { font-size: 3rem; display: block; line-height: 1; }
.login-logo h1  { font-size: 1.5rem; font-weight: 700; color: var(--c-text); margin-top: .4rem; }
.login-subtitle { font-size: .82rem; color: var(--c-text-xs); margin-top: .25rem; }

.login-container .form-group { margin-bottom: 1.1rem; }
.login-container label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--c-text-sm);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.login-container input {
  width: 100%;
  padding: .65rem .85rem;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .95rem;
  color: var(--c-text);
  background: #fafafa;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.login-container input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
  background: #fff;
}

.btn-login {
  width: 100%;
  padding: .75rem;
  margin-top: .5rem;
  background: linear-gradient(135deg, var(--c-primary), #7c3aed);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition);
  letter-spacing: .02em;
}
.btn-login:hover { opacity: .9; }

.login-footer {
  margin-top: 1.5rem;
  font-size: .75rem;
  color: rgba(255,255,255,.45);
  text-align: center;
}
.login-footer a { color: rgba(255,255,255,.6); }
.login-footer a:hover { color: #fff; }


/* ══════════════════════════════════════════════════════════════════════════
   2. ADMIN LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */
.admin-body { background: var(--c-bg); }

/* When admin uses app-header (no sidebar), reuse main-content layout */
.admin-body .main-content { padding-top: 1.5rem; }
.admin-body .admin-header { margin-bottom: 1.25rem; }
.admin-body .admin-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-text);
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.admin-sidebar {
  background: var(--c-sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.2rem 1rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 1rem;
  color: #fff;
  font-weight: 700;
}
.sidebar-logo span { font-size: 1.3rem; }

.sidebar-nav {
  flex: 1;
  padding: .65rem 0;
  display: flex;
  flex-direction: column;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .6rem 1rem;
  font-size: .85rem;
  color: #94a3b8;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
  border-left-color: rgba(255,255,255,.2);
}
.sidebar-nav a.active {
  background: rgba(99,102,241,.18);
  color: #a5b4fc;
  border-left-color: #6366f1;
  font-weight: 600;
}
.sidebar-nav a.logout {
  margin-top: auto;
  color: #fca5a5;
}
.sidebar-nav a.logout:hover { background: rgba(239,68,68,.12); color: #fca5a5; }
.sidebar-nav hr { border-color: rgba(255,255,255,.08); margin: .4rem 0; }

.sidebar-user {
  padding: .75rem 1rem;
  font-size: .75rem;
  color: #64748b;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user strong { color: #94a3b8; }

/* ── Main ── */
.admin-main {
  padding: 2rem 2.5rem 3rem;
  min-width: 0;
}
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: .5rem; }
  .sidebar-logo { padding: .5rem .75rem; }
  .sidebar-nav  { flex-direction: row; flex-wrap: wrap; padding: 0; }
  .sidebar-nav a { border-left: none; border-bottom: 2px solid transparent; padding: .45rem .65rem; font-size: .78rem; }
  .sidebar-nav a.active { border-bottom-color: #6366f1; border-left-color: transparent; }
  .sidebar-user { display: none; }
  .admin-main   { padding: 1.25rem 1rem 2rem; }
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.admin-header h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 999px;
  vertical-align: middle;
}

/* ── Sections admin ── */
.admin-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.admin-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 1rem;
}
.admin-section p { color: var(--c-text-sm); font-size: .88rem; }


/* ══════════════════════════════════════════════════════════════════════════
   3. STATS CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid transparent;
}
.stat-val {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1.1;
}
.stat-label {
  display: block;
  font-size: .78rem;
  color: var(--c-text-sm);
  margin-top: .3rem;
  font-weight: 500;
}
.stat-hint {
  display: block;
  font-size: .72rem;
  color: var(--c-text-xs);
  margin-top: .2rem;
}

.stat-card.total        { border-top-color: var(--c-primary); }
.stat-card.total .stat-val { color: var(--c-primary); }
.stat-card.rouge        { border-top-color: #dc2626; }
.stat-card.rouge  .stat-val { color: #dc2626; }
.stat-card.orange       { border-top-color: #ea580c; }
.stat-card.orange .stat-val { color: #ea580c; }
.stat-card.surveillance { border-top-color: #ca8a04; }
.stat-card.surveillance .stat-val { color: #ca8a04; }
.stat-card.vert         { border-top-color: #16a34a; }
.stat-card.vert  .stat-val { color: #15803d; }


/* ══════════════════════════════════════════════════════════════════════════
   4. BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: opacity var(--transition), background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary-h);
}
.btn-primary:hover { background: var(--c-primary-h); opacity: 1; }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text-sm);
  border-color: var(--c-border);
}
.btn-secondary:hover { background: var(--c-bg); border-color: var(--c-border-md); }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fee2e2; }

.btn-link {
  background: transparent;
  color: var(--c-text-sm);
  border: none;
  padding-left: .4rem;
  padding-right: .4rem;
}
.btn-link:hover { color: var(--c-primary); background: transparent; }

/* Petits boutons d'action dans les tables */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-sm);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.btn-sm:hover { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; text-decoration: none; }
.btn-sm.danger { color: #dc2626; }
.btn-sm.danger:hover { background: #fef2f2; border-color: #fca5a5; }

button.btn-sm { font-family: inherit; }


/* ══════════════════════════════════════════════════════════════════════════
   5. FORMULAIRES (partagés)
   ══════════════════════════════════════════════════════════════════════════ */
.form-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.form-section h3 {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-sm);
  margin-bottom: 1.1rem;
  padding-bottom: .55rem;
  border-bottom: 2px solid var(--c-border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.form-group label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-text-sm);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group label .required { color: #dc2626; }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--c-text-md);
  background: var(--c-surface);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
input::placeholder, textarea::placeholder { color: var(--c-text-xs); }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-top: 1.25rem;
  flex-wrap: wrap;
}


/* ══════════════════════════════════════════════════════════════════════════
   6. ALERTES & MESSAGES
   ══════════════════════════════════════════════════════════════════════════ */
.alert-success,
.alert-error,
.alert-info,
.alert-warn {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  line-height: 1.45;
  border: 1px solid;
}
.alert-success { background: var(--c-green-bg);  border-color: var(--c-green-border);  color: var(--c-green-text);  }
.alert-error   { background: var(--c-rouge-bg);  border-color: var(--c-rouge-border);  color: var(--c-rouge-text);  }
.alert-warn    { background: var(--c-yellow-bg); border-color: var(--c-yellow-border); color: var(--c-yellow-text); }
.alert-info    { background: #eff6ff;            border-color: #bfdbfe;                color: #1d4ed8;              }


/* ══════════════════════════════════════════════════════════════════════════
   7. BADGES DE NIVEAU D'ALERTE
   ══════════════════════════════════════════════════════════════════════════ */
.badge-alerte {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  border: 1px solid;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-rouge        { background: var(--c-rouge-bg);  border-color: var(--c-rouge-border);  color: var(--c-rouge-text);  }
.badge-orange       { background: var(--c-orange-bg); border-color: var(--c-orange-border); color: var(--c-orange-text); }
.badge-surveillance { background: var(--c-yellow-bg); border-color: var(--c-yellow-border); color: var(--c-yellow-text); }
.badge-ok           { background: var(--c-green-bg);  border-color: var(--c-green-border);  color: var(--c-green-text);  }
.badge-vert-confirme{ background: var(--c-green-bg);  border-color: var(--c-green-border);  color: var(--c-green-text);  }


/* ── Badges sources (IUCN / CITES) ─────────────────────────────────────── */
.badge-source {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .03em;
  vertical-align: middle;
  margin-left: .25rem;
}
.badge-source-code {
  display: inline-block;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
  color: #fff;
  margin-right: .2rem;
}
.badge-iucn-full, .badge-cites-full {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  padding: .2rem .55rem;
  border-radius: 8px;
  font-size: .75rem;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: .25rem;
}

/* ══════════════════════════════════════════════════════════════════════════
   8. TABLES
   ══════════════════════════════════════════════════════════════════════════ */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-table thead {
  background: #f8fafc;
  border-bottom: 2px solid var(--c-border);
}
.admin-table th {
  padding: .7rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-sm);
  text-align: left;
  white-space: nowrap;
}
.admin-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-md);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #f8fafc; }
.admin-table td.actions { display: flex; gap: .4rem; align-items: center; }
.admin-table td em { font-style: italic; color: var(--c-text); }
.text-muted { color: var(--c-text-xs); font-size: .85rem; }


/* ══════════════════════════════════════════════════════════════════════════
   9. FILTRES & FORMULAIRE DE RECHERCHE
   ══════════════════════════════════════════════════════════════════════════ */
.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.filters-form input[type="text"],
.filters-form select {
  padding: .45rem .7rem;
  font-size: .84rem;
  min-width: 0;
  flex: 1 1 150px;
  max-width: 240px;
}


/* ══════════════════════════════════════════════════════════════════════════
   10. PAGINATION
   ══════════════════════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.5rem;
  justify-content: center;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 .5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .84rem;
  color: var(--c-text-sm);
  background: var(--c-surface);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.pagination a:hover { background: #eff6ff; border-color: #bfdbfe; color: var(--c-primary); }
.pagination a.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  font-weight: 700;
}


/* ══════════════════════════════════════════════════════════════════════════
   11. BLOC ROTATION VÉRIFICATION (dashboard)
   ══════════════════════════════════════════════════════════════════════════ */
.blocs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}
.bloc-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .8rem;
  color: var(--c-text-sm);
  min-width: 70px;
  text-align: center;
  transition: border-color var(--transition);
}
.bloc-item.actif {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--c-primary);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(79,70,229,.15);
}
.bloc-num { font-size: 1.1rem; font-weight: 800; }
.bloc-nom { font-size: .72rem; margin-top: .15rem; }


/* ══════════════════════════════════════════════════════════════════════════
   12. PAGE RECHERCHE (search.php)
   ══════════════════════════════════════════════════════════════════════════ */
.search-body { background: var(--c-bg); }

.search-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Header */
.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.search-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--c-text);
  text-decoration: none;
}
.search-logo:hover { text-decoration: none; }
.search-toplinks { display: flex; gap: .5rem; }

/* Barre de recherche */
.search-bar-wrap {
  position: relative;
  margin-bottom: 1.5rem;
}
.search-bar-wrap input[type="search"],
.search-bar-wrap input[type="text"] {
  padding: .8rem 1rem .8rem 3rem;
  font-size: 1rem;
  border-radius: 999px;
  border: 2px solid var(--c-border);
  box-shadow: var(--shadow-md);
  width: 100%;
}
.search-bar-wrap input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}
.search-bar-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

/* Autocomplete dropdown */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 100;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid #f1f5f9;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.selected { background: #f8fafc; }
.autocomplete-item .item-nom { font-style: italic; font-weight: 600; font-size: .88rem; color: var(--c-text); }
.autocomplete-item .item-fr  { font-size: .78rem; color: var(--c-text-sm); }
.autocomplete-item .item-src { font-size: .7rem; color: var(--c-text-xs); margin-left: auto; white-space: nowrap; }

/* Cartes résultats */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.result-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.result-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}
.result-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #f1f5f9;
  display: block;
}
.result-card-img-placeholder {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #cbd5e1;
}
.result-card-body {
  padding: .8rem .9rem .9rem;
}
.result-card-nom {
  font-style: italic;
  font-weight: 700;
  font-size: .9rem;
  color: var(--c-text);
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-card-fr {
  font-size: .78rem;
  color: var(--c-text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-card-meta {
  margin-top: .5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
}

/* Quick-add form dans search.php */
.quick-add-card {
  background: var(--c-surface);
  border: 2px dashed var(--c-border-md);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.quick-add-card h3 {
  font-size: .88rem;
  font-weight: 700;
  color: var(--c-text-sm);
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}


/* ══════════════════════════════════════════════════════════════════════════
   13. FICHE ESPÈCE (espece_fiche.php)
   ══════════════════════════════════════════════════════════════════════════ */
.fiche-body { background: var(--c-bg); }
.fiche-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Topbar */
.fiche-topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .9rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--c-text-sm);
  text-decoration: none;
  font-weight: 500;
  transition: background var(--transition);
}
.btn-back:hover { background: var(--c-bg); color: var(--c-text); text-decoration: none; }

.topbar-actions { display: flex; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .85rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity var(--transition);
}
.btn-action:hover { opacity: .82; text-decoration: none; }
.btn-edit    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn-rapport { background: var(--c-green-bg); color: var(--c-green-text); border-color: var(--c-green-border); }
.btn-bold    { background: #f5f3ff; color: #6d28d9; border-color: #c4b5fd; }
.btn-fetch   { background: var(--c-orange-bg); color: var(--c-orange-text); border-color: var(--c-orange-border); }

/* Sections générique de la fiche */
.fiche-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.section-header {
  padding: .75rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-header h2 {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-sm);
  margin: 0;
}
.section-body { padding: 1.1rem 1.25rem; }

/* Chips taxonomiques */
.taxo-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .78rem;
  padding: .2rem .6rem;
  color: var(--c-text-sm);
}
.taxo-chip strong { color: var(--c-text); }


/* ══════════════════════════════════════════════════════════════════════════
   14. RAPPORT PAGE (rapport.php)
   ══════════════════════════════════════════════════════════════════════════ */
.rapport-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
.rapport-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--c-border);
}
.rapport-header h1 { font-size: 1.4rem; font-weight: 800; color: var(--c-text); }


/* ══════════════════════════════════════════════════════════════════════════
   15. IMPORT PAGE
   ══════════════════════════════════════════════════════════════════════════ */
.import-log {
  margin-top: 1.25rem;
  max-height: 350px;
  overflow-y: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .8rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  line-height: 1.6;
}
.log-ok    { color: #86efac; }
.log-skip  { color: #94a3b8; }
.log-error { color: #fca5a5; }
.log-warn  { color: #fcd34d; }

/* Zone upload */
.upload-zone {
  border: 2px dashed var(--c-border-md);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--c-bg);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.upload-zone:hover { border-color: var(--c-primary); background: #eff6ff; }
.upload-zone p { color: var(--c-text-sm); font-size: .88rem; }


/* ══════════════════════════════════════════════════════════════════════════
   16. UTILITAIRES
   ══════════════════════════════════════════════════════════════════════════ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* Scrollbar globale */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

/* Helpers */
.d-flex   { display: flex; }
.gap-1    { gap: .4rem; }
.gap-2    { gap: .75rem; }
.mt-1     { margin-top: .5rem; }
.mt-2     { margin-top: 1rem; }
.mt-3     { margin-top: 1.5rem; }
.mb-2     { margin-bottom: 1rem; }
.fw-bold  { font-weight: 700; }
.text-sm  { font-size: .82rem; }
.italic   { font-style: italic; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══════════════════════════════════════════════════════════════════════════
   17. APP HEADER (search.php + espece_fiche.php)
   ══════════════════════════════════════════════════════════════════════════ */
.app-header {
  background: var(--c-sidebar);
  color: #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 1.25rem;
}
.header-logo a {
  font-size: .95rem;
  font-weight: 800;
  color: #e2e8f0;
  text-decoration: none;
  letter-spacing: -.01em;
}
.header-logo a:hover { color: #fff; }

.header-nav {
  display: flex;
  gap: .15rem;
  flex: 1;
}
.header-nav a {
  padding: .35rem .75rem;
  font-size: .82rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.header-nav a:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.header-nav a.active { background: rgba(99,102,241,.22); color: #a5b4fc; font-weight: 600; }

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .8rem;
  color: #64748b;
  margin-left: auto;
}
.header-user a {
  color: #94a3b8;
  font-size: .78rem;
  padding: .28rem .65rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  transition: background var(--transition);
}
.header-user a:hover { background: rgba(255,255,255,.07); color: #e2e8f0; text-decoration: none; }
.header-user a.logout-link { color: #fca5a5; border-color: rgba(239,68,68,.2); }
.header-user a.logout-link:hover { background: rgba(239,68,68,.1); }


/* ── Print ── */
@media print {
  .admin-sidebar, .filters-form, .form-actions,
  .btn, .btn-sm, .btn-action, .btn-back { display: none !important; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-main   { padding: 0; }
  body { background: #fff; color: #000; }
}


/* ══════════════════════════════════════════════════════════════════════════
   18. SEARCH PAGE — layout, cards, sections
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Layout principal ── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ── Stats section ── */
.stats-section { }
/* Note: overridden by .stats-grid-2col when used in .stats-map-row */
.stats-section .stats-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.stats-section .stats-grid.stats-grid-2col {
  grid-template-columns: 1fr 1fr !important;
  margin-bottom: 0;
}
.stat-card.active {
  box-shadow: 0 0 0 3px rgba(79,70,229,.25);
  transform: translateY(-2px);
}
.stat-card.rouge.active  { box-shadow: 0 0 0 3px rgba(220,38,38,.3); }
.stat-card.orange.active { box-shadow: 0 0 0 3px rgba(234,88,12,.3); }
.stat-card.surveillance.active { box-shadow: 0 0 0 3px rgba(202,138,4,.3); }
.stat-card.vert.active   { box-shadow: 0 0 0 3px rgba(22,163,74,.3); }
a.stat-card { text-decoration: none; color: inherit; display: block; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }

/* ── Zone map section ── */
.zones-section { }

/* ── Search section ── */
.search-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow-sm);
}
.search-section h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--c-text);
  margin-bottom: .3rem;
}
.search-hint {
  font-size: .84rem;
  color: var(--c-text-sm);
  margin-bottom: 1rem;
}
.search-form { }
.search-row {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-row input[type="search"] {
  height: 2.5rem;
  box-sizing: border-box;
}
.search-row select {
  flex: 0 0 auto;
  width: auto;
  min-width: 155px;
  height: 2.5rem;
  box-sizing: border-box;
}
.search-row button[type="submit"] {
  padding: .45rem 1.3rem;
  height: 2.5rem;
  box-sizing: border-box;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.search-row button[type="submit"]:hover { background: var(--c-primary-h); }

/* ── Results section ── */
.results-section { }

.verdict-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .9rem 1.1rem;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.verdict-main {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.verdict-query {
  font-size: .88rem;
  color: var(--c-text-sm);
  font-style: italic;
}
.verdict-disclaimer {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  font-size: .84rem;
  color: #78350f;
  margin-top: .75rem;
}

.results-title {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-sm);
  margin-bottom: .85rem;
  margin-top: 1.25rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--c-border);
}

/* ── Espèces grid & cards ── */
.especes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.espece-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: visible;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.espece-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
}

/* Image pleine largeur en haut */
.espece-card .card-thumb {
  float: none !important;
  width: 100% !important;
  height: 140px !important;
  object-fit: cover !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  margin: 0 !important;
  border: none !important;
  display: block !important;
  cursor: zoom-in;
  transition: transform .2s;
}
.espece-card:hover .card-thumb { transform: scale(1.04); }

.espece-card .card-no-photo {
  float: none !important;
  width: 100% !important;
  height: 140px !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  margin: 0 !important;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 2.5rem !important;
  color: #cbd5e1 !important;
  border: none !important;
}

/* Corps de la carte */
.espece-card h4 {
  font-size: .88rem;
  font-weight: 700;
  font-style: italic;
  color: var(--c-text);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.espece-card .nom-commun {
  font-size: .75rem;
  color: var(--c-text-sm);
  margin-top: .1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.espece-card .badge-niveau {
  margin-top: .55rem;
  text-align: center;
}
.espece-card .badge-niveau .badge-alerte {
  white-space: normal;
  max-width: 100%;
  font-size: .68rem;
  text-align: center;
  justify-content: center;
}
.espece-card .zone-mini {
  font-size: .72rem;
  color: var(--c-text-xs);
  margin-top: .3rem;
}
.espece-card .source-mini {
  font-size: .7rem;
  color: var(--c-text-xs);
  margin-top: .15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Wrapper du contenu texte */
.espece-card-body {
  padding: .8rem .9rem .9rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Couleur de la bordure selon niveau */
.espece-card.card-rouge   { border-top: 3px solid #dc2626; }
.espece-card.card-orange  { border-top: 3px solid #ea580c; }
.espece-card.card-surveillance { border-top: 3px solid #ca8a04; }
.espece-card.card-vert    { border-top: 3px solid #16a34a; }

/* ── Compact list (famille) ── */
.especes-list-compact {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.espece-compact {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .75rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .87rem;
  transition: background var(--transition);
}
.espece-compact:hover { background: #f8fafc; }
.espece-compact strong { font-style: italic; color: var(--c-text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.espece-compact .badge-mini { flex-shrink: 0; }
.espece-compact .zone-mini  { font-size: .75rem; color: var(--c-text-xs); white-space: nowrap; }

/* ── Precaution box ── */
.precaution-box {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.precaution-box.orange {
  background: var(--c-orange-bg);
  border-color: var(--c-orange-border);
}
.precaution-box h3 {
  font-size: .92rem;
  font-weight: 700;
  color: #78350f;
  margin-bottom: .35rem;
}
.precaution-box.orange h3 { color: var(--c-orange-text); }
.precaution-box p { font-size: .84rem; color: #92400e; }

/* ── Browse section ── */
.browse-section { }

/* ── App footer ── */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--c-text-xs);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}
.app-footer a { color: var(--c-text-xs); }
.app-footer a:hover { color: var(--c-primary); }


/* ══════════════════════════════════════════════════════════════════════════
   19. ADMIN SIDEBAR — improved mobile nav
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }

  .admin-sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    padding: 0;
    background: var(--c-sidebar);
  }

  /* Logo compact + nav horizontal scrollable */
  .sidebar-logo {
    padding: .65rem 1rem;
    font-size: .92rem;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: .3rem .5rem .4rem;
    gap: .15rem;
    scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav a {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: .42rem .7rem;
    font-size: .78rem;
    white-space: nowrap;
  }
  .sidebar-nav a:hover {
    background: rgba(255,255,255,.08);
    border-bottom-color: transparent;
  }
  .sidebar-nav a.active {
    background: rgba(99,102,241,.2);
    border-bottom-color: #6366f1;
    border-left-color: transparent;
  }
  .sidebar-nav hr { display: none; }

  .sidebar-user {
    display: none;
  }
  .admin-main { padding: 1.25rem 1rem 2rem; }
}


/* ══════════════════════════════════════════════════════════════════════════
   20. STATS + MAP — côte à côte (2 colonnes)
   ══════════════════════════════════════════════════════════════════════════ */

/* Conteneur grille : stats à gauche, carte monde à droite */
.stats-map-row {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) 3fr;
  gap: 1.25rem;
  align-items: start;
}

/* Grille 2×2 pour les stat-cards dans la colonne gauche */
.stats-grid-2col {
  grid-template-columns: 1fr 1fr !important;
}

/* Colonne carte monde — même rendu "carte" que les autres sections */
.zones-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* Responsive : empiler sur mobile */
@media (max-width: 760px) {
  .stats-map-row {
    grid-template-columns: 1fr;
  }
  .stats-grid-2col {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Admin body — ajustement main-content sous app-header */
.admin-body .main-content {
  padding-top: 1.5rem;
}
