/* ==========================================================================
   MRESYSTEMS FTTH CADASTRE LITIGES PRO — MOBILE-FIRST DESIGN SYSTEM
   Conçu & Développé par MreSystems © 2026
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg-dark: #090d16;
  --bg-surface: rgba(15, 23, 42, 0.92);
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-card-hover: rgba(51, 65, 85, 0.9);
  
  --primary: #0284c7;
  --primary-light: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.4);
  
  --accent: #6366f1;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.18);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.18);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.18);
  
  --border: rgba(255, 255, 255, 0.12);
  --border-active: rgba(56, 189, 248, 0.6);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.2);
  
  --transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

[data-theme="light"] {
  --bg-dark: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.95);
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border: rgba(0, 0, 0, 0.1);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   1. PLEIN ÉCRAN CARTE (FOND MOBILE ABSOLU)
   ───────────────────────────────────────────────────────────────────────────── */
#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: #0b0f19;
}

#map.crosshair-cursor {
  cursor: crosshair !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. BARRE SUPÉRIEURE FLOTTANTE (TOP FLOATING HUD)
   ───────────────────────────────────────────────────────────────────────────── */
.top-nav-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.top-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.search-box-card {
  flex: 1;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  padding: 6px 14px;
  box-shadow: var(--shadow-md);
  position: relative;
  height: 48px;
}

.search-box-card input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 500;
  padding-left: 8px;
}

.search-box-card input::placeholder {
  color: var(--text-muted);
  font-size: 13px;
}

.btn-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-icon-circle:active {
  transform: scale(0.92);
}

.btn-icon-circle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 20px var(--primary-glow);
}

/* Autocomplete Dropdown */
.autocomplete-list {
  position: absolute;
  top: 54px;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: none;
}

.autocomplete-item {
  padding: 12px 16px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
}

.autocomplete-item:active, .autocomplete-item:hover {
  background: rgba(56, 189, 248, 0.18);
  color: var(--primary-light);
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. BOUTONS D'ACTION FLOTTANTS (FABs)
   ───────────────────────────────────────────────────────────────────────────── */
.fab-container {
  position: absolute;
  right: 14px;
  bottom: 180px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
}

.fab-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.fab-btn:active {
  transform: scale(0.92);
}

.fab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.fab-btn.locating {
  background: var(--primary);
  color: #fff;
  animation: fabSpinRadar 1.2s linear infinite;
  box-shadow: 0 0 25px var(--primary-glow);
}

@keyframes fabSpinRadar {
  0% { transform: scale(1.05) rotate(0deg); }
  50% { transform: scale(1.15) rotate(180deg); }
  100% { transform: scale(1.05) rotate(360deg); }
}

/* Balise GPS Position Utilisateur */
.user-loc-wrapper {
  background: transparent !important;
  border: none !important;
}

.user-gps-beacon {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-gps-dot {
  width: 14px;
  height: 14px;
  background: #0284c7;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.95);
  z-index: 2;
}

.user-gps-pulse {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.45);
  animation: userGpsPulse 2s infinite ease-out;
  z-index: 1;
}

@keyframes userGpsPulse {
  0% {
    transform: scale(0.6);
    opacity: 1;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

/* Bannière d'état en haut */
.status-pill {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-active);
  color: var(--primary-light);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  z-index: 450;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. BOTTOM SHEET MOBILE (TIROIR INFÉRIEUR INTERACTIF)
   ───────────────────────────────────────────────────────────────────────────── */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 600;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  max-height: 85vh;
}

/* Poignée de tirage tactile */
.sheet-handle-bar {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
}

/* En-tête visible permanent (Peek state) */
.sheet-peek-header {
  padding: 0 16px 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.verdict-badge {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.verdict-badge.public {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.verdict-badge.private {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.verdict-badge.neutral {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text-muted);
}

.verdict-badge-title {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.verdict-badge-sub {
  font-size: 11px;
  color: var(--text-main);
  margin-top: 1px;
}

.btn-report-quick {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Contenu déroulant du tiroir */
.sheet-scroll-content {
  overflow-y: auto;
  padding: 0 16px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cartes d'informations dans le tiroir */
.sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-light);
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item span:first-child {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.info-item span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

/* Saisie GPS responsive sans rognage */
.gps-inputs-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.gps-inputs-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.btn-sm-action {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* Curseur opacité cadastre */
.slider-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-control input[type="range"] {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
}

/* Sélecteur de calques moderne en segmented pills */
.layer-radio-group {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}

[data-theme="light"] .layer-radio-group {
  background: rgba(0, 0, 0, 0.06);
}

.layer-radio-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  margin: 0;
  user-select: none;
}

.layer-radio-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.layer-radio-btn span {
  width: 100%;
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.layer-radio-btn input[type="radio"]:checked + span {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.layer-radio-btn:hover span {
  color: var(--text-main);
}

#map.cadastre-view,
#map.cadastre-view .leaflet-container,
#map.cadastre-view .leaflet-pane {
  background-color: #fbf9f5 !important;
}

/* Repère Poteau Télécom FTTH */
.pole-icon-marker {
  background: transparent !important;
  border: none !important;
}

.telecom-pole-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: grab;
  user-select: none;
}

.telecom-pole-pin:active {
  cursor: grabbing;
}

.pole-pin-body {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284c7, #075985);
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.7);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
}

.telecom-pole-pin:hover .pole-pin-body {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.9);
}

.pole-pin-tip {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid #075985;
  margin-top: -3px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
  z-index: 1;
}

.pole-pin-pulse {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 8px;
  border-radius: 50%;
  background: rgba(2, 132, 199, 0.45);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.85);
  animation: polePulse 2s infinite ease-out;
  pointer-events: none;
  z-index: 0;
}

@keyframes polePulse {
  0% {
    transform: translateX(-50%) scale(0.8);
    opacity: 0.9;
  }
  70% {
    transform: translateX(-50%) scale(2.8);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) scale(2.8);
    opacity: 0;
  }
}

.pole-pin-tag {
  position: absolute;
  top: -22px;
  background: rgba(15, 23, 42, 0.92);
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-active);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. ÉTATS DU TIROIR (PEEK vs EXPANDED)
   ───────────────────────────────────────────────────────────────────────────── */
.bottom-sheet.peek .sheet-scroll-content {
  display: none;
}

.bottom-sheet.expanded {
  height: 75vh;
}

.bottom-sheet.expanded .sheet-scroll-content {
  display: flex;
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. RESPONSIVE DESKTOP & GRANDES TABLETTES (min-width: 769px)
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 769px) {
  .bottom-sheet {
    position: absolute;
    top: 72px;
    left: 16px;
    bottom: 16px;
    width: 420px;
    max-height: none;
    height: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }

  .sheet-handle-bar {
    display: none;
  }

  .bottom-sheet.peek .sheet-scroll-content {
    display: flex;
  }

  .top-nav-hud {
    left: 450px;
    right: 20px;
  }

  .fab-container {
    bottom: 24px;
    right: 24px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. MODALE DE CONSTAT PDF IMPRIMABLE
   ───────────────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 12px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-sheet {
  background: #ffffff;
  color: #0f172a;
  width: 100%;
  max-width: 780px;
  max-height: 94vh;
  border-radius: var(--radius-lg);
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  font-size: 12.5px;
}

.sheet-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

.sheet-header {
  border-bottom: 2px solid #0284c7;
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sheet-title h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.sheet-table th, .sheet-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: left;
}

.sheet-table th {
  background: #f8fafc;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: #334155;
  width: 38%;
}

.sheet-signatures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
}

.sig-box {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  height: 90px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #f8fafc;
}

.sig-box span {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
}

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

@media print {
  body * { visibility: hidden; }
  .modal-sheet, .modal-sheet * { visibility: visible; }
  .modal-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-shadow: none;
  }
  .sheet-close-btn, .sheet-actions { display: none !important; }
}
