/* tczkarta.com — стили карты безопасности */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --text: #ffffff;
  --text-muted: #a1a7b3;
  --accent: #3b82f6;
  --danger: #ff4d4f;
  --warning: #ffd43b;
  --safe: #3d8bfd;
  --glass-bg: rgba(255,255,255,0.08);
  --glass-border: rgba(255,255,255,0.15);
  --radius-card: 16px;
  --radius-btn: 24px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100dvh;
  position: relative;
}

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-brand img {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 0 8px rgba(59,130,246,0.6));
}

.navbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.navbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-btn);
  padding: 8px 14px;
  cursor: pointer;
  flex: 1;
  max-width: 220px;
  margin-left: 12px;
}

.navbar-search span {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== MAP ===== */
#map {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
}

/* Тёмный стиль карты через фильтр */
.leaflet-tile-pane {
  filter: brightness(0.7) contrast(1.1) saturate(0.8) hue-rotate(195deg);
}

/* ===== LEGEND ===== */
.legend-panel {
  position: fixed;
  top: 80px;
  right: 12px;
  z-index: 500;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  min-width: 160px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
}

.legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}

.legend-dot.urgent { background: var(--danger); box-shadow: 0 0 6px rgba(255,77,79,0.6); }
.legend-dot.warning { background: var(--warning); box-shadow: 0 0 6px rgba(255,212,59,0.5); }
.legend-dot.info { background: var(--safe); box-shadow: 0 0 6px rgba(61,139,253,0.5); }

.legend-label { flex: 1; }
.legend-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ===== COUNTER BAR ===== */
.counter-bar {
  position: fixed;
  top: 80px;
  left: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.counter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.counter-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.counter-dot.urgent { background: var(--danger); }
.counter-dot.warning { background: var(--warning); }
.counter-dot.info { background: var(--safe); }

/* ===== ACTION BAR ===== */
.action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-btn);
  padding: 10px 14px;
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: #2563eb; transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

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

.btn-danger {
  background: rgba(255,77,79,0.15);
  border: 1px solid rgba(255,77,79,0.3);
  color: var(--danger);
  padding: 10px;
  width: 42px;
  justify-content: center;
}

.btn img {
  width: 18px; height: 18px;
  opacity: 0.9;
}

/* ===== BOTTOM SHEET ===== */
.bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 800;
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--glass-border);
  padding: 0 0 env(safe-area-inset-bottom, 0);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 65vh;
  overflow-y: auto;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet-content {
  padding: 16px 20px 24px;
}

.sheet-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.urgent {
  background: rgba(255,77,79,0.15);
  color: var(--danger);
  border: 1px solid rgba(255,77,79,0.3);
}
.status-badge.warning {
  background: rgba(255,212,59,0.15);
  color: var(--warning);
  border: 1px solid rgba(255,212,59,0.3);
}
.status-badge.info {
  background: rgba(61,139,253,0.15);
  color: var(--safe);
  border: 1px solid rgba(61,139,253,0.3);
}

.sheet-time {
  font-size: 12px;
  color: var(--text-muted);
}

.sheet-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}

.sheet-address {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sheet-description {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
  line-height: 1.5;
  margin-bottom: 16px;
}

.sheet-media {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 4px;
}

.sheet-media img, .sheet-media video {
  height: 80px;
  width: auto;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-actions .btn {
  flex: 1;
  justify-content: center;
  min-width: 100px;
}

/* ===== ПУЛЬСИРУЮЩИЕ МАРКЕРЫ ===== */
.pulse-marker {
  position: relative;
}

.pulse-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  animation: pulse-ring 1.5s ease-out infinite;
  pointer-events: none;
}

.pulse-ring-2 {
  animation-delay: 0.5s;
  width: 55px; height: 55px;
}

@keyframes pulse-ring {
  0% { transform: translate(-50%,-50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.5); opacity: 0; }
}

/* Кастомные маркеры */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.2s;
}

.custom-marker:hover { transform: scale(1.15); }
.custom-marker.urgent { background: var(--danger); }
.custom-marker.warning { background: var(--warning); color: #1a1a1a; }
.custom-marker.info { background: var(--safe); }

/* Popup стили */
.leaflet-popup-content-wrapper {
  background: rgba(22,27,34,0.95);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-card);
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.leaflet-popup-tip { background: rgba(22,27,34,0.95); }

.popup-content { padding: 4px; }
.popup-time { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.popup-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.popup-more {
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.popup-more:hover { text-decoration: underline; }

/* ===== LOADER ===== */
.map-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.5s;
}

.map-loader.hidden { opacity: 0; pointer-events: none; }

.loader-logo {
  width: 64px; height: 64px;
  animation: logo-pulse 1.5s ease-in-out infinite;
}

@keyframes logo-pulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(59,130,246,0.4)); }
  50% { filter: drop-shadow(0 0 24px rgba(59,130,246,0.8)); }
}

.loader-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
}

.loader-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(59,130,246,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== SYSTEM STATUS ===== */
.system-status {
  position: fixed;
  bottom: 90px;
  left: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
  transition: opacity 0.3s;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
  animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* ===== LOCATE BUTTON ===== */
.locate-btn {
  position: fixed;
  right: 12px;
  bottom: 90px;
  z-index: 500;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.locate-btn:hover { background: rgba(255,255,255,0.12); }
.locate-btn img { width: 20px; height: 20px; }

/* Responsive */
@media (min-width: 768px) {
  .action-bar { min-width: 320px; }
  .legend-panel { min-width: 180px; }
}
