/**
 * Mon-TJM.fr - Carte des TJM Styles
 */

/* =============================================================================
   MAP LAYOUT
   ============================================================================= */

.main--map {
  padding-top: calc(80px + var(--space-8));
  min-height: 100vh;
}

.map-section {
  padding: 0 var(--space-4);
  max-width: 1400px;
  margin: 0 auto;
}

.map-section__header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.map-section__title {
  font-size: var(--text-3xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary), var(--color-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-2);
}

.map-section__subtitle {
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.map-section__contribute-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, var(--color-primary), var(--color-violet));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
}

.map-section__contribute-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.map-section__contribute-btn svg {
  width: 16px;
  height: 16px;
}

/* =============================================================================
   STATS BAR
   ============================================================================= */

.map-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.map-stats__item {
  text-align: center;
}

.map-stats__value {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary);
}

.map-stats__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* =============================================================================
   FILTERS (Badge Style)
   ============================================================================= */

.map-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.map-filters__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.map-filters__label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.map-filters__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  user-select: none;
}

.filter-badge:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.05);
}

.filter-badge--active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-violet));
  border-color: transparent;
  color: white;
}

.filter-badge--active:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  border-color: transparent;
  color: white;
}

/* Legacy select styles (kept for form) */
.map-filters__select {
  padding: var(--space-2) var(--space-4);
  padding-right: var(--space-8);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  min-width: 180px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: all var(--duration-fast) var(--ease-out);
}

.map-filters__select:hover {
  border-color: var(--color-primary);
}

.map-filters__select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* =============================================================================
   MAP CONTAINER
   ============================================================================= */

.map-container {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
}

.map {
  width: 100%;
  height: 65vh;
  min-height: 400px;
  max-height: 700px;
  background: var(--color-bg);
  z-index: 1;
}

/* Dark mode map tiles adjustment */
[data-theme="dark"] .map {
  filter: brightness(0.9) contrast(1.1);
}

/* =============================================================================
   MAP LEGEND
   ============================================================================= */

.map-legend {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  z-index: 1000;
}

.map-legend__title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.map-legend__scale {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.map-legend__scale:last-child {
  margin-bottom: 0;
}

.map-legend__color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =============================================================================
   LEAFLET CUSTOMIZATION
   ============================================================================= */

/* Popup */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--glass-shadow);
}

.leaflet-popup-content {
  margin: var(--space-4);
  font-family: var(--font-sans);
  color: var(--color-text);
}

.leaflet-popup-tip {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-top: none;
  border-left: none;
}

.map-popup {
  min-width: 180px;
}

.map-popup__city {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.map-popup__count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.map-popup__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.map-popup__stat {
  text-align: center;
  padding: var(--space-2);
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-sm);
}

.map-popup__stat-value {
  display: block;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
}

.map-popup__stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Marker Clusters - Custom TJM style */
.tjm-cluster-wrapper {
  background: transparent !important;
}

.tjm-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  min-width: 60px;
  height: 32px;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  background: linear-gradient(135deg, var(--marker-color, var(--color-primary)) 0%, color-mix(in srgb, var(--marker-color, var(--color-primary)) 80%, #000) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.25),
    0 0 0 3px rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.tjm-cluster:hover {
  transform: scale(1.05);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.3),
    0 0 0 4px rgba(255, 255, 255, 0.15);
}

.tjm-cluster__value {
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tjm-cluster__count {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-1);
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  color: white;
}

[data-theme="dark"] .tjm-cluster {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 0 3px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .tjm-cluster:hover {
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.5),
    0 0 0 4px rgba(255, 255, 255, 0.1);
}

/* Legacy marker clusters (fallback) */
.marker-cluster {
  background: rgba(99, 102, 241, 0.2);
  border: 2px solid var(--color-primary);
}

.marker-cluster div {
  background: var(--color-primary);
  color: white;
  font-family: var(--font-sans);
  font-weight: 700;
}

.marker-cluster-small {
  background: rgba(99, 102, 241, 0.3);
}

.marker-cluster-small div {
  background: #6366F1;
}

.marker-cluster-medium {
  background: rgba(139, 92, 246, 0.3);
}

.marker-cluster-medium div {
  background: #8B5CF6;
}

.marker-cluster-large {
  background: rgba(244, 63, 94, 0.3);
}

.marker-cluster-large div {
  background: #F43F5E;
}

/* Custom TJM markers - Glassmorphism style */
.tjm-marker-wrapper {
  background: transparent !important;
}

.tjm-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-2);
  min-width: 48px;
  height: 26px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--marker-color, var(--color-primary));
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

[data-theme="dark"] .tjm-marker {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
}

/* =============================================================================
   MODAL
   ============================================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-base) var(--ease-out);
}

.modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--duration-base) var(--ease-out);
}

.modal[aria-hidden="false"] .modal__content {
  transform: translateY(0) scale(1);
}

.modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all var(--duration-fast) var(--ease-out);
}

.modal__close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text);
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

.modal__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.modal__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* =============================================================================
   CONTRIBUTE FORM
   ============================================================================= */

.contribute-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: all var(--duration-fast) var(--ease-out);
}

.form-input::placeholder {
  color: var(--color-text-light);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--color-text-light);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: var(--space-10);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* City Search */
.city-search {
  position: relative;
}

.city-search__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-1);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.city-search__results.active {
  display: block;
}

.city-search__item {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  border-bottom: 1px solid var(--glass-border);
}

.city-search__item:last-child {
  border-bottom: none;
}

.city-search__item:hover {
  background: rgba(99, 102, 241, 0.1);
}

.city-search__item-name {
  font-weight: 600;
  color: var(--color-text);
}

.city-search__item-dept {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Form Actions */
.form-actions {
  margin-top: var(--space-2);
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  text-decoration: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-violet));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--glass-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--glass-border);
}

.btn--secondary:hover {
  background: var(--glass-bg-strong);
  border-color: var(--color-text-light);
}

.btn--full {
  width: 100%;
}

.btn__loading {
  display: none;
}

.btn--loading .btn__text {
  display: none;
}

.btn--loading .btn__loading {
  display: inline-flex;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Privacy Notice */
.form-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.form-privacy svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Success State */
.modal__success {
  text-align: center;
  padding: var(--space-4) 0;
}

.modal__success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 50%;
  color: var(--color-emerald);
}

.modal__success-icon svg {
  width: 32px;
  height: 32px;
}

.modal__success h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.modal__success p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* =============================================================================
   FOOTER MINIMAL
   ============================================================================= */

.footer--minimal {
  margin-top: var(--space-8);
  padding: var(--space-6) var(--space-4);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 768px) {
  .main--map {
    padding-top: calc(70px + var(--space-6));
  }

  .map-section__title {
    font-size: var(--text-2xl);
  }

  .map-section__subtitle {
    flex-direction: column;
    gap: var(--space-3);
  }

  .map-stats {
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
  }

  .map-stats__value {
    font-size: var(--text-xl);
  }

  .map-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .map-filters__select {
    min-width: auto;
    width: 100%;
  }

  .map {
    height: 55vh;
    min-height: 350px;
  }

  .map-legend {
    bottom: var(--space-2);
    left: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .modal__content {
    padding: var(--space-6);
  }
}

@media (max-width: 480px) {
  .map-stats {
    flex-direction: column;
    gap: var(--space-2);
    text-align: center;
  }

  .map-popup__stats {
    grid-template-columns: 1fr;
  }
}
