/* ============================================================
   Frelon Asiatique GE — feuille de style
   Palette : rouge frelon #e53935, tons sobres (gris anthracite).
   ============================================================ */
:root {
  --red: #e53935;
  --red-dark: #c62828;
  --ink: #21252b;
  --muted: #6b7280;
  --line: #e3e6ea;
  --bg: #f4f5f7;
  --card: #ffffff;
  --topbar-h: 52px;
  --panel-w: 400px;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 24, 30, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}
a { color: var(--red-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
h1 { font-size: 1.4rem; margin: 0 0 .8rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .92rem; }

/* ---------------- Barre du haut ---------------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 .9rem;
  background: var(--ink);
  color: #fff;
  position: relative; z-index: 1200;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, .35);
}
.topbar-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: .4rem;
  overflow-x: auto;
}
.tb-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  background: transparent; color: #e8eaee;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 8px;
  padding: .34rem .7rem;
  white-space: nowrap;
}
.tb-btn:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.tb-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.tb-primary:hover { background: var(--red-dark); }
.user-chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding-left: .5rem; color: #e8eaee; white-space: nowrap;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
}

/* ---------------- Application cartographique ---------------- */
#app { display: flex; height: calc(100dvh - var(--topbar-h)); }

#panel {
  width: var(--panel-w);
  max-width: var(--panel-w);
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: margin-left .2s ease;
  z-index: 900;
}
#panel:not(.open) { margin-left: calc(-1 * var(--panel-w)); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.05rem;
}
#panel-close {
  background: none; border: none; font-size: 1.4rem; line-height: 1;
  color: var(--muted); border-radius: 6px; padding: 0 .3rem;
}
#panel-close:hover { background: var(--bg); color: var(--ink); }
#panel-body { flex: 1; overflow-y: auto; padding: .9rem; }
.view[hidden] { display: none; }

#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #dfe3e8; }

/* Recherche de lieu */
#map-search {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  width: min(300px, 60vw);
}
#search-input {
  width: 100%; padding: .5rem .7rem;
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
}
#search-results {
  margin-top: 4px; background: #fff; border-radius: 8px;
  box-shadow: var(--shadow); overflow: hidden;
  max-height: 260px; overflow-y: auto;
}
#search-results button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: .5rem .7rem;
  border-bottom: 1px solid var(--line); font-size: .9rem;
}
#search-results button:hover { background: var(--bg); }

/* Boutons flottants de la carte */
#locate-btn, #panel-open {
  position: absolute; z-index: 1000;
  width: 40px; height: 40px; border-radius: 8px;
  background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 1.2rem;
}
#locate-btn { right: 10px; top: 60px; }
#panel-open { left: 10px; top: 10px; }
#locate-btn:hover, #panel-open:hover { background: var(--bg); }

/* Bandeaux de mode placement / dessin */
#placing-banner, #drawing-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 1100; background: var(--ink); color: #fff;
  padding: .5rem .9rem; border-radius: 8px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: .8rem; font-size: .9rem;
  max-width: 90vw;
}
#placing-banner button, #drawing-banner button {
  background: var(--red); color: #fff; border: none;
  border-radius: 6px; padding: .25rem .6rem;
}

/* ---------------- Accueil ---------------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: .6rem; margin-bottom: 1rem;
}
.stat {
  background: var(--bg); border-radius: var(--radius);
  padding: .6rem .8rem;
}
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .82rem; }
.big-btn {
  display: flex; align-items: center; gap: .8rem;
  width: 100%; padding: .9rem 1rem; margin-bottom: .6rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 1rem; font-weight: 600;
  text-align: left;
}
.big-btn:hover { border-color: var(--red); box-shadow: var(--shadow); }
.big-ico { font-size: 1.4rem; }

/* Cartes de types */
.type-card {
  display: flex; align-items: center; gap: .8rem;
  width: 100%; padding: .8rem; margin-bottom: .5rem;
  background: var(--card); border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: var(--radius); text-align: left;
}
.type-card:hover { box-shadow: var(--shadow); }
.type-card b { display: block; }
.type-card small { color: var(--muted); }

/* ---------------- Formulaires ---------------- */
.form-card { max-width: 420px; width: 100%; }
label.f-label, .form-card label {
  display: block; margin-bottom: .8rem; font-weight: 600; font-size: .92rem;
}
.f-input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"], select, textarea {
  display: block; width: 100%; margin-top: .25rem;
  padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(229, 57, 53, .35); border-color: var(--red);
}
textarea { min-height: 70px; resize: vertical; }
.f-group { margin-bottom: 1rem; }
.f-group > .f-legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.f-choice { display: flex; align-items: center; gap: .45rem; font-weight: 400; margin: .25rem 0; }
.f-choice input { width: auto; margin: 0; }
.f-required { color: var(--red); }
.f-row { display: flex; gap: .6rem; }
.f-row > * { flex: 1; }

.btn-primary {
  display: inline-block; width: 100%;
  background: var(--red); color: #fff; border: none;
  border-radius: 8px; padding: .6rem 1rem; font-weight: 700;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary {
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .9rem;
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger { color: #fff; background: #b3261e; border: none; }
.btn-small {
  border-radius: 6px; border: 1px solid var(--line);
  background: #fff; padding: .25rem .55rem; font-size: .82rem;
}
.btn-small:hover { background: var(--bg); }
.form-error { color: #b3261e; font-size: .9rem; }
.form-ok { color: #1b7f3b; font-size: .9rem; }

/* Aperçus photos */
.photo-previews { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.photo-previews img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
}

/* ---------------- Marqueurs ---------------- */
.mk {
  position: relative;
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.mk-archived { opacity: .55; filter: grayscale(.6); }
.mk-age {
  position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
  background: rgba(33, 37, 43, .85); color: #fff;
  font-size: 9px; line-height: 1; padding: 1px 3px; border-radius: 4px;
  white-space: nowrap;
}

/* ---------------- Badges & listes ---------------- */
.badge {
  display: inline-block; border-radius: 999px;
  padding: .12rem .55rem; font-size: .78rem; font-weight: 700;
  background: var(--bg); color: var(--ink);
}
.badge-warn { background: #fff3e0; color: #e65100; }
.badge-st-to_verify { background: #fff3e0; color: #e65100; }
.badge-st-positive { background: #fdecea; color: var(--red-dark); }
.badge-st-negative { background: #e8f5e9; color: #1b7f3b; }
.badge-st-eradicated { background: #e3f2fd; color: #1565c0; }
.badge-archived { background: #eceff1; color: #546e7a; }
.badge-validated { background: #e8f5e9; color: #1b7f3b; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: .15rem .6rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------- Fiche observation ---------------- */
.detail-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .6rem; }
.detail-title .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.gallery { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .8rem; }
.gallery img {
  height: 110px; border-radius: 8px; cursor: zoom-in;
  border: 1px solid var(--line);
}
.hist-item {
  border-left: 3px solid var(--line);
  padding: .4rem 0 .4rem .7rem; margin-bottom: .7rem;
}
.hist-item .hist-head { display: flex; align-items: center; gap: .45rem; font-weight: 600; }
.hist-item .hist-meta { color: var(--muted); font-size: .82rem; margin: .1rem 0 .3rem; }
.hist-data { font-size: .88rem; }
.hist-data .kv { grid-template-columns: minmax(110px, 45%) 1fr; }
.hist-remark {
  background: var(--bg); border-radius: 8px;
  padding: .4rem .6rem; margin-top: .3rem; font-size: .88rem;
  white-space: pre-wrap;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0; }

/* ---------------- Tâches ---------------- */
.task-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem .7rem; margin-bottom: .5rem; background: #fff;
}
.task-item.late { border-left: 5px solid var(--red); }
.task-item.todo { border-left: 5px solid #1e88e5; }
.task-item.done { border-left: 5px solid #43a047; opacity: .8; }
.task-item .t-head { display: flex; justify-content: space-between; gap: .5rem; font-weight: 600; }
.task-item .t-sub { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.task-item button { margin-top: .4rem; }

.assignee-box { border: 1px solid var(--line); border-radius: 8px; max-height: 180px; overflow-y: auto; margin-top: .25rem; }
.assignee-box label { display: flex; gap: .45rem; align-items: center; padding: .3rem .5rem; font-weight: 400; margin: 0; }
.assignee-box label:hover { background: var(--bg); }
.assignee-box input { width: auto; margin: 0; }

/* ---------------- Filtres ---------------- */
.filters-sec { border-bottom: 1px solid var(--line); padding: .5rem 0 .8rem; margin-bottom: .5rem; }
.filters-sec h3 { margin-top: .2rem; }
.filters-actions { display: flex; gap: .5rem; position: sticky; bottom: 0; background: var(--card); padding: .6rem 0; }

/* ---------------- Zones ---------------- */
.zone-item { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.zone-item .z-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.zone-item .z-name { flex: 1; }

/* ---------------- Pages hors carte ---------------- */
.page-center {
  min-height: calc(100dvh - var(--topbar-h));
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem 1rem;
}
.page-wide { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1rem;
}
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 150px; margin-top: 0; }
.inline-form .btn-primary { width: auto; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table input[type="text"], .table select { margin-top: 0; padding: .25rem .4rem; min-width: 110px; }
.actions-cell { white-space: nowrap; }

/* ---------------- Lightbox & toast ---------------- */
#lightbox {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(10, 12, 15, .88);
  display: flex; align-items: center; justify-content: center;
}
#lightbox img { max-width: 94vw; max-height: 90dvh; border-radius: 8px; }
#lightbox-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: none; color: #fff; font-size: 2.2rem;
}
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 2100; background: var(--ink); color: #fff;
  padding: .55rem 1rem; border-radius: 8px; box-shadow: var(--shadow);
  max-width: 90vw;
}
#toast.error { background: #b3261e; }

/* ---------------- Responsive : panneau plein écran ---------------- */
@media (max-width: 768px) {
  :root { --panel-w: 100vw; }
  .user-name { display: none; }
  .tb-btn { padding: .3rem .5rem; font-size: .88rem; }
  .brand { font-size: .95rem; }
  #panel { position: absolute; height: calc(100dvh - var(--topbar-h)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
