/* =========================================================
   VCardi unified map modal (Leaflet)
   ========================================================= */

.vcardi-map-picker-overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  box-sizing: border-box;
  background: rgba(15, 23, 42, .68) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden !important;
}

body.vcardi-map-modal-open {
  overflow: hidden !important;
}

body.vcardi-map-modal-open #vcardi-floating-dashboard-button,
body.vcardi-map-modal-open #vcardi-floating-messages-icon,
body.vcardi-map-modal-open #vcardi-floating-home-button,
body.vcardi-map-modal-open #vcardi-floating-create-card,
body.vcardi-map-modal-open .vcardi-floating-dashboard-button,
body.vcardi-map-modal-open .vcardi-floating-messages-icon,
body.vcardi-map-modal-open .vcardi-floating-home-button,
body.vcardi-map-modal-open .vcardi-floating-create-card {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

.vcardi-map-picker-content {
  --picker-accent: #4f46e5;
  --picker-accent-hover: #4338ca;
  --picker-accent-soft: #eef2ff;
  --picker-success: #0f766e;
  --picker-success-hover: #0d9488;
  --picker-border: #e2e8f0;
  --picker-text: #0f172a;
  --picker-muted: #64748b;

  width: min(1120px, 100%);
  max-width: 100%;
  height: min(820px, calc(100vh - 40px));
  max-height: calc(100vh - 40px);
  min-height: 0;
  padding: 18px;
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  color: var(--picker-text);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15,23,42,.28), 0 4px 18px rgba(15,23,42,.12);
  animation: vcardiMapPickerIn .22s ease-out;
  position: relative;
  z-index: 1;
}

@keyframes vcardiMapPickerIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.vcardi-map-picker-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--picker-border);
}

.vcardi-map-picker-header h3 {
  min-width: 0;
  margin: 0;
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.35;
  font-weight: 700;
  color: var(--picker-text);
}

.vcardi-map-picker-header h3 i {
  margin-inline-end: 7px;
  color: var(--picker-accent);
}

.vcardi-map-picker-close {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--picker-border);
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}

.vcardi-map-picker-close:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
  transform: rotate(2deg);
}

.vcardi-map-picker-map-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 0 12px;
}

.vcardi-map-picker-map {
  width: 100%;
  height: 100%;
  min-height: 260px;
  box-sizing: border-box;
  display: block;
  position: relative;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid var(--picker-border);
  border-radius: 12px;
}

.vcardi-map-picker-map .leaflet-container {
  width: 100%;
  height: 100%;
}

.vcardi-zoom-indicator {
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  font-family: monospace;
}

.vcardi-leaflet-gps-btn {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: #0f766e !important;
  font-size: 15px;
}

.vcardi-map-gps-btn {
  background: var(--picker-success);
  border-color: var(--picker-success);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, .22);
}

.vcardi-map-gps-btn:hover:not(:disabled) {
  background: var(--picker-success-hover);
  border-color: var(--picker-success-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(15,118,110,.28);
}

.vcardi-map-gps-btn:disabled {
  opacity: .7;
  cursor: wait;
}

.vcardi-map-nav-btn {
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, .22);
}

.vcardi-map-nav-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.vcardi-map-gps-btn:active,
.vcardi-map-picker-btn:active,
.vcardi-map-picker-close:active {
  transform: scale(.97);
}

.vcardi-map-picker-info {
  flex: 0 0 auto;
  min-height: 0;
  margin: 0 0 12px;
}

.vcardi-map-picker-instruction {
  margin: 0 0 8px;
  padding: 9px 11px;
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 9px;
  color: #1e40af;
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.vcardi-map-picker-instruction p { margin: 0; }

.vcardi-map-picker-coords {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 9px;
  color: var(--picker-muted);
  font-size: 12px;
  line-height: 1.5;
}

.vcardi-map-picker-coords span {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.vcardi-map-picker-coords strong {
  color: #334155;
  font-weight: 700;
}

.vcardi-map-picker-gps-coords {
  margin-top: 7px;
  padding: 7px 10px;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 9px;
  color: #0f766e;
  font-size: 12px;
  line-height: 1.5;
}

.vcardi-map-picker-gps-coords[hidden] {
  display: none !important;
}

.vcardi-map-picker-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  padding-top: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: relative;
  z-index: 2;
}

.vcardi-map-picker-btn {
  min-width: 110px;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.vcardi-map-picker-cancel {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

.vcardi-map-picker-cancel:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.vcardi-map-picker-confirm {
  background: var(--picker-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.22);
}

.vcardi-map-picker-confirm:hover {
  background: var(--picker-accent-hover);
  box-shadow: 0 6px 16px rgba(79,70,229,.28);
  transform: translateY(-1px);
}

.vcardi-map-marker {
  background: transparent !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.vcardi-map-marker:hover { z-index: 2000 !important; }

.vcardi-marker-container {
  pointer-events: auto !important;
  position: relative;
  will-change: transform;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

.leaflet-marker-dragging { transition: none !important; }

.leaflet-div-icon {
  border: none !important;
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
}

.vcardi-map-gps-marker {
  background: transparent !important;
  border: none !important;
  animation: vcardiMapPulse 2s infinite;
}

@keyframes vcardiMapPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: .8; }
}

@media (max-width: 900px) {
  .vcardi-map-picker-overlay {
    padding: 12px !important;
  }

  .vcardi-map-picker-content {
    width: min(760px, 100%);
    height: min(760px, calc(100vh - 24px));
    max-height: calc(100vh - 24px);
    padding: 15px;
    border-radius: 16px;
  }

  .vcardi-map-picker-map { min-height: 230px; }
}

@media (max-width: 600px) {
  .vcardi-map-picker-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(15,23,42,.58) !important;
  }

  .vcardi-map-picker-content {
    width: 100% !important;
    height: min(94dvh, 760px);
    max-height: 94dvh !important;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(15,23,42,.22);
  }

  .vcardi-map-picker-header {
    margin-bottom: 9px;
    padding-bottom: 9px;
  }

  .vcardi-map-picker-header h3 { font-size: 15px; }

  .vcardi-map-picker-close {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .vcardi-map-picker-map-container { margin-bottom: 9px; }

  .vcardi-map-picker-map {
    min-height: 0;
    height: 100%;
    border-radius: 10px;
  }

  .vcardi-map-picker-info { margin-bottom: 9px; }

  .vcardi-map-picker-instruction {
    padding: 7px 9px;
    font-size: 11px;
    line-height: 1.55;
    margin-bottom: 6px;
  }

  .vcardi-map-picker-coords {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .vcardi-map-picker-gps-coords {
    margin-top: 5px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .vcardi-map-picker-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .vcardi-map-picker-actions .vcardi-map-gps-btn {
    grid-column: 1 / -1;
  }

  .vcardi-map-picker-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 9px 10px;
    font-size: 13px;
  }
}

@media (max-width: 380px), (max-height: 620px) {
  .vcardi-map-picker-content {
    height: 96dvh;
    max-height: 96dvh !important;
    padding: 9px;
    padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  }

  .vcardi-map-picker-header h3 { font-size: 14px; }
  .vcardi-map-picker-map { min-height: 0; }
  .vcardi-map-picker-instruction { display: none; }
  .vcardi-map-picker-info { margin-bottom: 6px; }
  .vcardi-map-picker-coords { font-size: 10px; padding: 5px 7px; }
  .vcardi-map-picker-btn { min-height: 42px; }
}

.vcardi-map-picker-btn:focus-visible,
.vcardi-map-picker-close:focus-visible,
.vcardi-map-gps-btn:focus-visible {
  outline: 3px solid rgba(99,102,241,.28);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .vcardi-map-picker-content,
  .vcardi-map-gps-marker {
    animation: none !important;
  }

  .vcardi-map-picker-btn,
  .vcardi-map-picker-close,
  .vcardi-map-gps-btn {
    transition: none !important;
  }
}
