/* style.css - 12e Arrondissement Panels Map */
:root {
  --primary: #E1396C;
  --primary-hover: #c42f5b;
  --bg-dark: #FEF7FA;
  /* Keeps same var name but light pink value */
  --bg-panel: #FFFFFF;
  --text-main: #111827;
  --text-muted: #4B5563;

  --status-ok: #039660;
  --status-degrade: #E1396C;
  --status-non-verifie: #F59E0B;

  --brand-gradient: linear-gradient(130deg, #FFD504, #E93D77, #E83C78, #039660);

  --font-family: Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

/* Glassmorphism */
.glass-panel {
  background: var(--bg-panel);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* Soft shadow */
  border-radius: 8px;
  /* Slightly sharper corners like the reference */
}

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

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 0.875rem;
}

.margin-top-md {
  margin-top: 1rem;
}

/* Select dropdown */
.arr-select {
  width: 100%;
  background: #FFFFFF;
  border: 1px solid #D1D5DB;
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 1rem;
  appearance: auto;
  cursor: pointer;
  transition: border-color 0.2s;
}

.arr-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: var(--font-family);
}

.btn.primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.secondary {
  background: #F3F4F6;
  color: var(--text-main);
}

.btn.secondary:hover {
  background: #E5E7EB;
}

.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: inline-flex;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--text-main);
  background: #F3F4F6;
}

.input-group {
  display: flex;
  position: relative;
  align-items: center;
}

.input-group .material-icons-round {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  background: #FFFFFF;
  border: 1px solid #D1D5DB;
  color: var(--text-main);
  padding: 0.75rem 1rem 0.75rem 3rem;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 1rem;
  transition: border-color 0.2s;
}

textarea {
  padding: 0.75rem 1rem;
  /* remove left padding for icon */
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Overlays & Login */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #FEF7FA;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.overlay::before {
  display: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  text-align: center;
}

.login-card h2 {
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.error-text {
  color: var(--status-non-verifie);
  font-size: 0.875rem;
  text-align: left;
  margin-top: -0.5rem;
}

/* Main App Layout */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  width: calc(100% - 2rem);
  max-width: 600px;

  border-top: 4px solid #E1396C;
  border-image: var(--brand-gradient) 1;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

#map-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
}

/* Fix leaflet popup styles for dark mode */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--bg-panel);
  color: var(--text-main);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content {
  margin: 1rem;
}

.leaflet-popup-content p {
  margin: 0 0 0.5rem 0;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

/* Custom Leaflet Overrides */
.leaflet-top {
  top: 5rem !important;
  /* Push controls below the app-header */
}

/* Legend Overlay */
.map-overlay.bottom-left {
  position: fixed;
  bottom: max(env(safe-area-inset-bottom, 20px), 1.5rem);
  /* iOS home bar fix */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: max-content;
  max-width: 90vw;
}

.legend {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  /* pill shape */
}

.legend h3 {
  display: none;
}

.legend ul {
  list-style: none;
  font-size: 0.75rem;
  display: flex;
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.status-ok {
  color: var(--status-ok);
  background: var(--status-ok);
}

.status-degrade {
  color: var(--status-degrade);
  background: var(--status-degrade);
}

.status-non-verifie {
  color: var(--status-non-verifie);
  background: var(--status-non-verifie);
}

/* Modal Update */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  padding-right: 1rem;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #E5E7EB;
  background: #F9FAFB;
  border-radius: 0 0 12px 12px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* Photo Upload */
.photo-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.panel-photo-preview {
  width: 100%;
  max-width: 300px;
  max-height: 250px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #D1D5DB;
  background: #F3F4F6;
}

.photo-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: #F3F4F6;
  color: var(--text-main);
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px dashed #D1D5DB;
  transition: all 0.2s;
  width: 100%;
}

.photo-upload-label:hover {
  background: #E5E7EB;
  border-color: var(--text-main);
}

.photo-upload-label input[type="file"] {
  display: none;
}

/* Status Radio Selectors */
.status-selector {
  display: flex;
  gap: 1rem;
}

.status-option {
  flex: 1;
  cursor: pointer;
}

.status-option input[type="radio"] {
  display: none;
}

.status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid #E5E7EB;
  background: #F9FAFB;
  transition: all 0.2s;
}

.status-option input[type="radio"]:checked+.status-card {
  background: #F3F4F6;
}

.status-card-ok {
  color: var(--status-ok);
}

.status-option input[type="radio"]:checked+.status-card-ok {
  border-color: var(--status-ok);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.2);
}

.status-option input[type="radio"]:checked+.status-card-degrade {
  border-color: var(--status-degrade);
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.2);
}

/* Poster Type Selector */
.type-selector {
  display: flex;
  gap: 1rem;
}

.type-option {
  flex: 1;
  cursor: pointer;
}

.type-option input[type="radio"] {
  display: none;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  border: 2px solid #E5E7EB;
  background: #F9FAFB;
  transition: all 0.2s;
  font-weight: 500;
  text-align: center;
}

.type-option input[type="radio"]:checked+.type-card {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

/* Map Markers */
.custom-marker {
  display: flex;
  justify-content: center;
  align-items: center;
}

.marker-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  background: var(--status-non-verifie);
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -14px 0 0 -14px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: background-color 0.3s ease;
  border: 2px solid white;
}

.marker-pin::after {
  content: '';
  width: 10px;
  height: 10px;
  margin: 7px 0 0 7px;
  background: white;
  position: absolute;
  border-radius: 50%;
}

.custom-marker[data-status="ok"] .marker-pin {
  background: var(--status-ok);
}

.custom-marker[data-status="degrade"] .marker-pin {
  background: var(--status-degrade);
}

.custom-marker[data-status="non-verifie"] .marker-pin {
  background: var(--status-non-verifie);
}

/* Geolocation Blue Dot */
.geolocation-dot {
  width: 18px;
  height: 18px;
  background: #3b82f6;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
  position: relative;
}

.geolocation-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  animation: geo-pulse 2s ease-out infinite;
}

@keyframes geo-pulse {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Photo buttons */
.photo-buttons {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.photo-buttons .photo-upload-label {
  flex: 1;
  justify-content: center;
  text-align: center;
}

/* Route FAB */
.route-fab {
  position: fixed;
  bottom: max(calc(env(safe-area-inset-bottom, 20px) + 60px), 5rem);
  right: 1rem;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-main);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transition: all 0.3s;
}

.route-fab:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.route-fab .material-icons-round {
  font-size: 28px;
}

/* Route Panel (Bottom Drawer) */
.route-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15000;
  background: var(--bg-panel);

  border: 1px solid #D1D5DB;
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.route-panel.hidden {
  display: flex !important;
  transform: translateY(100%);
  pointer-events: none;
}

.route-panel-header {
  padding: 0.75rem 1.5rem 0;
  flex-shrink: 0;
}

.route-panel-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 0 auto 0.75rem;
}

.route-panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #E5E7EB;
}

.route-panel-title-row h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.route-panel-body {
  padding: 1rem 1.5rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Route start address row */
.route-start-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.route-start-row input {
  flex: 1;
  padding: 0.75rem 1rem;
}

.route-gps-btn {
  background: rgba(59, 130, 246, 0.2) !important;
  color: var(--primary) !important;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.route-gps-btn:hover {
  background: rgba(59, 130, 246, 0.4) !important;
}

/* Panel select header */
.route-select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-family);
  padding: 0.25rem 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Panel list */
.route-panel-list {
  max-height: 35vh;
  overflow-y: auto;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  background: #F9FAFB;
}

.route-panel-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #F3F4F6;
  cursor: pointer;
  transition: background 0.15s;
}

.route-panel-item:last-child {
  border-bottom: none;
}

.route-panel-item:hover {
  background: #F9FAFB;
}

.route-panel-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.route-panel-item-info {
  flex: 1;
  min-width: 0;
}

.route-panel-item-addr {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-panel-item-num {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Status dot in route panel list */
.route-panel-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-non-verifie);
  box-shadow: 0 0 6px currentColor;
  color: var(--status-non-verifie);
  transition: background 0.3s;
}

.route-panel-dot[data-status="ok"] {
  background: var(--status-ok);
  color: var(--status-ok);
}

.route-panel-dot[data-status="degrade"] {
  background: var(--status-degrade);
  color: var(--status-degrade);
}

.route-panel-dot[data-status="non-verifie"] {
  background: var(--status-non-verifie);
  color: var(--status-non-verifie);
}

/* Calculate button */
.route-calculate-btn {
  width: 100%;
  margin-top: 1rem;
}

/* Results */
.route-results {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.route-results-info {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  transition: background-color 0.2s;
  margin-bottom: 1rem;
}

.route-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary);
}

.route-stat .material-icons-round {
  font-size: 20px;
  color: var(--primary);
}

.route-gmaps-btn {
  width: 100%;
  text-decoration: none;
  margin-bottom: 0.75rem;
  background: #10B981;
  /* Green for maps */
}

.route-gmaps-btn:hover {
  background: #059669;
}

.route-results .btn.secondary {
  width: 100%;
}

.login-card h2 {
  font-size: 2rem;
  font-weight: 900;
  color: transparent;
  background: var(--brand-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  margin-bottom: 1rem;
}
/* =========================================
   GAMIFICATION STYLES
   ========================================= */

/* Header Profile */
.gamified-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.user-profile:hover {
  background: #F3F4F6;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  overflow: hidden;
  background: #FFF;
  flex-shrink: 0;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-pseudo {
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.user-grade {
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

/* Merci Toast */
.merci-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: white;
  border-left: 4px solid var(--primary);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 99999;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

/* Stat Cards */
.stat-card {
  box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
  transition: transform 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
}

/* Floating Profile Header */
.floating-profile {
  position: absolute;
  top: max(env(safe-area-inset-top, 20px), 1rem);
  left: max(env(safe-area-inset-left, 20px), 1rem);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.floating-profile:hover {
  transform: scale(1.05);
}

.user-grade-badge {
  background: var(--bg-panel);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border: 1px solid rgba(225,57,108,0.2);
  white-space: nowrap;
}
