/* ============================================================
   Mons – Coupures Gaz & Electricite
   style.css
   ============================================================ */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
}

/* --- Carte --- */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* --- Panneau --- */
#panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 340px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: rgba(24, 24, 38, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 1000;
  padding: 16px;
}

#panel header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

#panel header .subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* --- Sections formulaire --- */
.form-section { margin-top: 10px; }
.form-group  { margin-bottom: 12px; }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Boutons toggle --- */
.btn-group {
  display: flex;
  gap: 6px;
}

.btn-toggle {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #334155;
  background: transparent;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-toggle:hover {
  border-color: #64748b;
  color: #e2e8f0;
}
.btn-toggle.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  color: #fff;
}

/* --- Inputs --- */
textarea, input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #334155;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}
textarea:focus, input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
}

.char-count {
  display: block;
  text-align: right;
  font-size: 0.7rem;
  color: #64748b;
  margin-top: 2px;
}

/* --- Bouton principal --- */
.btn-primary {
  width: 100%;
  padding: 11px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #2563eb; }
.btn-primary.selecting {
  background: #f59e0b;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

/* --- Info rue detectee --- */
#street-info {
  margin-top: 10px;
  padding: 10px;
  background: rgba(30, 41, 59, 0.6);
  border-radius: 8px;
  border: 1px solid #334155;
}

.street-detected { margin-bottom: 8px; }
.street-label { font-size: 0.78rem; color: #94a3b8; }
.street-detected strong { color: #fbbf24; font-size: 0.95rem; }

.street-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-confirm {
  flex: 1;
  padding: 9px;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-confirm:hover { background: #16a34a; }

.btn-cancel {
  padding: 9px 14px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-cancel:hover { background: #dc2626; }

/* --- Cooldown --- */
#cooldown-bar {
  margin-top: 10px;
  background: #1e293b;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  height: 24px;
}
#cooldown-bar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #94a3b8;
  z-index: 1;
}
.cooldown-progress {
  height: 100%;
  background: rgba(245, 158, 11, 0.3);
  width: 0;
}

/* --- Stats footer --- */
#stats {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #334155;
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
}

/* --- Recherche rue --- */
#search-results {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 4px;
}
.search-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.84rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.search-item:hover {
  background: rgba(59, 130, 246, 0.2);
}
.search-loading, .search-empty {
  padding: 6px 10px;
  font-size: 0.8rem;
  color: #64748b;
}

/* --- Legende --- */
#legend {
  position: absolute;
  bottom: 24px;
  left: 12px;
  background: rgba(24, 24, 38, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  z-index: 1000;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
#legend h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-line {
  display: inline-block;
  width: 30px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-line.solid.red    { background: #e53e3e; }
.legend-line.solid.green  { background: #38a169; }
.legend-line.dashed.red   { background: repeating-linear-gradient(90deg, #e53e3e 0, #e53e3e 6px, transparent 6px, transparent 10px); }
.legend-line.dashed.green { background: repeating-linear-gradient(90deg, #38a169 0, #38a169 6px, transparent 6px, transparent 10px); }

.legend-sep {
  height: 1px;
  background: #334155;
  margin: 6px 0;
}
.legend-note {
  font-size: 0.7rem;
  color: #64748b;
  line-height: 1.4;
}

/* --- Toasts --- */
#toast-container {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 420px;
  width: 90%;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateY(-12px);
  transition: all 0.3s ease;
  pointer-events: auto;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #2563eb; }

/* --- Loading overlay --- */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
#loading p {
  color: #fff;
  margin-top: 12px;
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Utilitaires --- */
.hidden { display: none !important; }

/* --- Temp marker --- */
.temp-marker {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* --- Popup Leaflet --- */
.popup-content h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: #1a202c;
}
.popup-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.popup-content td {
  padding: 3px 6px;
  vertical-align: middle;
}
.popup-content tr + tr td {
  border-top: 1px solid #e2e8f0;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.out { background: #fed7d7; color: #c53030; }
.badge.ok  { background: #c6f6d5; color: #276749; }
.badge.na  { background: #e2e8f0; color: #718096; }

.popup-comment {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #4a5568;
  font-style: italic;
}

/* --- Scrollbar panneau --- */
#panel::-webkit-scrollbar { width: 5px; }
#panel::-webkit-scrollbar-track { background: transparent; }
#panel::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }

/* --- Bouton toggle mobile (masque sur desktop) --- */
#panel-toggle {
  display: none;
}

/* --- Tablette (641px – 1024px) --- */
@media (max-width: 1024px) and (min-width: 641px) {
  #panel {
    width: 300px;
    padding: 14px;
  }
  #panel header h1 { font-size: 1rem; }
  .btn-toggle { font-size: 0.8rem; padding: 7px 8px; }
}

/* --- Mobile (≤ 640px) --- */
@media (max-width: 640px) {
  /* Panneau en bas, collapsible */
  #panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    padding: 0 14px 14px;
    transition: transform 0.35s ease;
  }

  /* Etat reduit : seul le header + toggle visible */
  #panel.collapsed {
    transform: translateY(calc(100% - 52px));
  }

  /* Bouton toggle visible sur mobile */
  #panel-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 0 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.8rem;
    gap: 6px;
  }
  #panel-toggle::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #475569;
    border-radius: 2px;
  }
  #panel.collapsed #panel-toggle .toggle-text::after { content: 'Ouvrir le panneau'; }
  #panel:not(.collapsed) #panel-toggle .toggle-text::after { content: 'Reduire'; }

  #panel header h1 { font-size: 1rem; }
  #panel header .subtitle { font-size: 0.72rem; }

  .form-section { margin-top: 8px; }
  .form-group { margin-bottom: 10px; }
  .btn-toggle { font-size: 0.82rem; padding: 10px 8px; }
  .btn-primary { padding: 12px; font-size: 0.88rem; }
  textarea { font-size: 0.88rem; }

  /* Legende : compacte en haut a gauche */
  #legend {
    bottom: auto;
    top: 10px;
    left: 10px;
    font-size: 0.68rem;
    padding: 6px 10px;
    max-width: 170px;
  }
  #legend h3 { font-size: 0.62rem; margin-bottom: 4px; }
  #legend .legend-line { width: 18px; height: 3px; }
  #legend .legend-item { gap: 5px; margin-bottom: 2px; }
  #legend .legend-sep { margin: 4px 0; }
  #legend .legend-note { font-size: 0.6rem; }

  /* Toasts sous la legende */
  #toast-container {
    top: auto;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 340px;
  }
  .toast { font-size: 0.8rem; padding: 8px 14px; }

  /* Stats plus compact */
  #stats { font-size: 0.75rem; margin-top: 8px; padding-top: 8px; }
}
