/* ============================================================
   Türkiye Satış Haritası — geo analytics dashboard
   Leaflet map card, filter toolbar, legend, drill-through panel.
   No basemap tiles: everything here is themed to match the app's
   glassmorphism design tokens instead of inheriting Leaflet's defaults.
   ============================================================ */

/* ---------- Filter toolbar ---------- */
.geo-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.geo-filters__group { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }

.geo-filters__field { display: flex; flex-direction: column; gap: 4px; min-width: 148px; }
.geo-filters__field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.geo-filters__select {
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.geo-filters__select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(46, 107, 255, 0.18); }

.geo-filters__range {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
}
.geo-filters__range-icon { color: var(--text-muted); flex-shrink: 0; }
.geo-filters__range-input {
  width: 76px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.geo-filters__range-input:focus { outline: none; }
.geo-filters__range-sep { color: var(--text-muted); }

.geo-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.geo-toggle-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.geo-toggle-btn.is-active {
  background: var(--gradient-brand);
  border-color: transparent;
  color: #fff;
}

/* ---------- Layout: map + detail panel ---------- */
.geo-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-5);
  align-items: start;
}

.geo-map-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: geo-map-enter var(--dur-slow) var(--ease-out) both;
}
@keyframes geo-map-enter {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

.geo-map-container {
  height: 620px;
  width: 100%;
  background: var(--bg-app);
}
.leaflet-container { background: var(--bg-app); font-family: var(--font-sans); outline: none; }

/* Leaflet zoom control, restyled to match the design system */
.leaflet-bar {
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-bar a {
  background: var(--bg-surface-raised) !important;
  color: var(--text-primary) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
}
.leaflet-bar a:hover { background: var(--bg-hover) !important; }
.leaflet-bar a:last-child { border-bottom: none !important; }

/* Leaflet tooltip → app-styled card */
.leaflet-tooltip.geo-tooltip {
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  opacity: 1 !important;
}
.leaflet-tooltip.geo-tooltip::before { display: none; }
.geo-tooltip__title { font-weight: var(--weight-semibold); font-size: var(--text-base); margin-bottom: 6px; }
.geo-tooltip__row { display: flex; justify-content: space-between; gap: var(--space-4); padding: 2px 0; color: var(--text-secondary); }
.geo-tooltip__row strong { color: var(--text-primary); font-weight: var(--weight-semibold); }
.geo-tooltip__row strong.is-positive { color: var(--positive); }
.geo-tooltip__row strong.is-negative { color: var(--negative); }

/* ---------- Legend ---------- */
.geo-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.geo-legend__item { display: flex; align-items: center; gap: 6px; }
.geo-legend__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.geo-legend__dot--positive { background: var(--positive); }
.geo-legend__dot--warning { background: var(--warning); }
.geo-legend__dot--negative { background: var(--negative); }
.geo-legend__dot--neutral { background: var(--text-muted); }
.geo-legend__sep { color: var(--border-strong); }
.geo-legend__hint { color: var(--text-muted); font-size: var(--text-xs); }

.geo-map__unmatched {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.geo-map__unmatched svg { flex-shrink: 0; margin-top: 1px; }

.geo-kpi-empty { grid-column: 1 / -1; }

/* ---------- Detail / compare panel ---------- */
.geo-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  min-height: 620px;
  animation: geo-map-enter var(--dur-slow) var(--ease-out) both;
}
.geo-panel__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }

.geo-panel__hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  min-height: 520px;
  color: var(--text-muted);
  padding: var(--space-6);
}
.geo-panel__hint svg { opacity: 0.5; }

.geo-panel__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.geo-panel__header h2 { font-size: var(--text-lg); margin: 2px 0 0; }

.geo-panel__kpis { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.geo-panel__kpis .kpi-card__body { padding: var(--space-3); }

.geo-panel__info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  font-size: var(--text-sm);
}
.geo-panel__info-label { color: var(--text-muted); }

.geo-panel__section-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-secondary); margin: 0 0 var(--space-2); }

.geo-panel__compare-charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

.geo-compare-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.geo-compare-table th, .geo-compare-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; }
.geo-compare-table th { color: var(--text-muted); font-weight: var(--weight-medium); width: 40%; }
.geo-compare-table td { font-weight: var(--weight-semibold); color: var(--text-primary); }
.geo-compare-table tr:last-child th, .geo-compare-table tr:last-child td { border-bottom: none; }

/* ---------- Responsive: 1920 / 2560 / tablet / mobile ---------- */
@media (min-width: 1800px) {
  .geo-layout { grid-template-columns: 1fr 440px; }
  .geo-map-container, .geo-panel { min-height: 760px; }
  .geo-map-container { height: 760px; }
}

@media (max-width: 1180px) {
  .geo-layout { grid-template-columns: 1fr; }
  .geo-panel { min-height: 0; }
  .geo-panel__hint { min-height: 220px; }
  .geo-panel__kpis { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 720px) {
  .geo-map-container { height: 420px; }
  .geo-filters { flex-direction: column; align-items: stretch; }
  .geo-filters__group { flex-direction: column; align-items: stretch; }
  .geo-filters__field { min-width: 0; }
  .geo-panel__kpis { grid-template-columns: 1fr 1fr; }
  .geo-panel__compare-charts { grid-template-columns: 1fr; }
}
