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

:root {
  --bg:        var(--tg-theme-bg-color, #ffffff);
  --bg2:       var(--tg-theme-secondary-bg-color, #f0f0f0);
  --text:      var(--tg-theme-text-color, #000000);
  --hint:      var(--tg-theme-hint-color, #888888);
  --accent:    var(--tg-theme-button-color, #2481cc);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);

  --target:  #F59E0B;
  --fait:    #10B981;
  --detruit: #6B7280;

  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.15);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

/* ── Map ─────────────────────────────────────────────────────────────────── */

#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */

#filter-bar {
  position: fixed;
  top: 0;
  left: 0; right: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}
#filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--hint);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* ── Dots ────────────────────────────────────────────────────────────────── */

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-target  { background: var(--target); }
.dot-fait    { background: var(--fait); }
.dot-detruit { background: var(--detruit); }

/* ── Geolocate button ────────────────────────────────────────────────────── */

#btn-geolocate {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 10;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
}
#btn-geolocate:active { transform: scale(.93); }
#btn-geolocate svg { width: 22px; height: 22px; }

/* ── Sheet overlay ───────────────────────────────────────────────────────── */

#sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.35);
}

/* ── Bottom sheet ────────────────────────────────────────────────────────── */

#sheet {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 21;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  max-height: 85vh;
  overflow-y: auto;
  transition: transform .25s cubic-bezier(.32,.72,0,1);
}
#sheet.hidden, #sheet-overlay.hidden { display: none; }

#sheet-handle {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--hint);
  opacity: .4;
  margin: 12px auto 0;
}

#sheet-body {
  padding: 16px 20px 32px;
}

.sheet-mode { display: none; }
.sheet-mode.active { display: block; }

/* ── Add mode ────────────────────────────────────────────────────────────── */

#add-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--hint);
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  border: 1.5px solid var(--bg2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font-size: 15px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
textarea:focus { border-color: var(--accent); }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary, .btn-secondary, .btn-save, .btn-delete {
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 11px 0;
  transition: opacity .15s, transform .1s;
}
.btn-primary:active, .btn-secondary:active, .btn-save:active, .btn-delete:active {
  transform: scale(.97);
  opacity: .85;
}

.btn-primary  { flex: 1; background: var(--accent); color: var(--accent-fg); }
.btn-secondary { flex: 1; background: var(--bg2); color: var(--text); }
.btn-save { width: 100%; margin-top: 10px; background: var(--bg2); color: var(--accent); }
.btn-delete { width: 100%; background: #FEE2E2; color: #DC2626; }

/* ── Edit mode ───────────────────────────────────────────────────────────── */

#edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.badge-target  { background: #FEF3C7; color: #92400E; }
.badge-fait    { background: #D1FAE5; color: #065F46; }
.badge-détruit { background: #F3F4F6; color: #374151; }

.edit-date {
  font-size: 12px;
  color: var(--hint);
}

.divider {
  height: 1px;
  background: var(--bg2);
  margin: 18px 0;
}

.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--hint);
  margin-bottom: 10px;
}

.status-btns {
  display: flex;
  gap: 8px;
}

.status-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 0;
  border: 1.5px solid var(--bg2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.status-btn.active-status {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.status-btn:active { opacity: .75; }

/* ── Leaflet overrides ───────────────────────────────────────────────────── */

.leaflet-control-zoom {
  top: 56px !important;
}

.marker-dot {
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: transform .15s;
}

/* ── User location pulse ─────────────────────────────────────────────────── */

.user-location {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid white;
  box-shadow: 0 0 0 6px rgba(36,129,204,0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(36,129,204,0.2); }
  50%       { box-shadow: 0 0 0 10px rgba(36,129,204,0.05); }
}
