:root {
  --bg-main: #0f1015;
  --bg-card: #18191f;
  --bg-input: #20222b;
  --bg-input-focus: #282a36;
  --border-color: #2e323e;
  --border-focus: #ff5500;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --btn-primary: #ff5500;
  --btn-primary-hover: #e04b00;
  --btn-secondary: #272935;
  --btn-secondary-hover: #333644;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 30px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* Header & Tabs */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-title h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.app-title .badge {
  font-size: 11px;
  background: linear-gradient(135deg, #ff5500, #ff8800);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  gap: 4px;
}

.nav-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-tab.active {
  background: var(--btn-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 85, 0, 0.35);
}

/* GPS Status Card */
.gps-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.gps-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gps-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-yellow);
  box-shadow: 0 0 8px var(--accent-yellow);
  transition: all 0.3s ease;
}

.status-dot.green {
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulse-green 2s infinite;
}

.status-dot.yellow {
  background-color: var(--accent-yellow);
  box-shadow: 0 0 10px var(--accent-yellow);
}

.status-dot.red {
  background-color: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.accuracy-chip {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-family: monospace;
  color: #fff;
  border: 1px solid var(--border-color);
}

.gps-progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.gps-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff5500, #10b981);
  transition: width 0.3s ease;
}

.gps-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.gps-meta-item strong {
  color: var(--text-main);
}

.btn-recalibrate {
  background: rgba(255, 85, 0, 0.15);
  color: #ff7733;
  border: 1px solid rgba(255, 85, 0, 0.3);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.btn-recalibrate:hover {
  background: rgba(255, 85, 0, 0.25);
  color: #ff9955;
}

/* Map Preview Card */
.map-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.map-card-header {
  padding: 9px 14px;
  background: #12131a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}

.map-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.map-layer-select {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

.btn-map-control {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-map-control:hover {
  background: rgba(59, 130, 246, 0.28);
  color: #93c5fd;
}

/* Map wrapper: chứa map + crosshair + coords */
.map-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
  overflow: hidden;
}

#map-container {
  width: 100%;
  height: 100%;
  background: #1e2029;
  cursor: grab;
}

#map-container:active {
  cursor: grabbing;
}

/* ─── CROSSHAIR ─────────────────────────────────────────── */
.map-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  pointer-events: none;
  z-index: 800;
  transition: transform 0.15s ease;
}

/* Vòng tròn bên ngoài */
.crosshair-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(0,0,0,0.2);
  transition: all 0.2s;
}

/* Chấm trung tâm */
.crosshair-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  background: #ff5500;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 6px rgba(255, 85, 0, 0.9);
  z-index: 2;
}

/* Đường ngang */
.crosshair-h {
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1.5px;
  background: rgba(255,255,255,0.8);
  transform: translateY(-50%);
  box-shadow: 0 0 3px rgba(0,0,0,0.5);
}

/* Đường dọc */
.crosshair-v {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1.5px;
  background: rgba(255,255,255,0.8);
  transform: translateX(-50%);
  box-shadow: 0 0 3px rgba(0,0,0,0.5);
}

/* Khi đang kéo → crosshair mở rộng */
.map-crosshair.dragging .crosshair-ring {
  width: 52px; height: 52px;
  border-color: #ff5500;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 0 12px rgba(255,85,0,0.4);
}

.map-crosshair.dragging .crosshair-dot {
  background: #ff8800;
  box-shadow: 0 0 10px rgba(255, 136, 0, 1);
  width: 8px; height: 8px;
}

/* Flash khi chốt */
.map-crosshair.flash .crosshair-ring {
  border-color: #10b981;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 0 20px rgba(16,185,129,0.7);
  animation: crosshair-flash 0.6s ease;
}

@keyframes crosshair-flash {
  0%   { transform: translate(-50%,-50%) scale(1); }
  30%  { transform: translate(-50%,-50%) scale(1.5); }
  100% { transform: translate(-50%,-50%) scale(1); }
}

/* ─── TỌAỘ REALTIME ─────────────────────────────────────── */
.map-coords-live {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.72);
  color: #7dd3fc;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  pointer-events: none;
  z-index: 900;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* ─── NÚT CHỐT VỊ TRÍ ───────────────────────────────────── */
.btn-pin-location {
  display: block;
  width: calc(100% - 20px);
  margin: 10px auto;
  padding: 11px 16px;
  background: linear-gradient(135deg, #ff5500 0%, #ff8800 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(255, 85, 0, 0.35);
}

.btn-pin-location:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 85, 0, 0.5);
}

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

.btn-pin-location.pinned {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}

/* ─── GHIM MARKER (khi đã chốt) ─────────────────────────── */
.map-pin-icon {
  background: transparent !important;
  border: none !important;
}

.pin-body {
  position: relative;
  width: 32px;
  height: 32px;
}

.pin-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #ff5500;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(255,85,0,0.8);
  z-index: 2;
}

.pin-pulse {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 32px; height: 32px;
  background: rgba(255, 85, 0, 0.2);
  border-radius: 50%;
  animation: pin-pulse 2s ease-out infinite;
}

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

.pin-shadow {
  width: 10px; height: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  margin: -2px auto 0;
  filter: blur(2px);
}

/* Leaflet overrides */
.leaflet-touch .leaflet-control-zoom a {
  width: 34px; height: 34px;
  line-height: 34px;
  font-size: 18px;
}



/* Main Form Card (Matching User Screenshot Exactly) */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.form-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 8px;
}

.form-label .required {
  color: #ef4444;
  margin-left: 2px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.form-control:focus {
  border-color: var(--btn-primary);
  background-color: var(--bg-input-focus);
}

.form-control::placeholder {
  color: var(--text-dim);
}

.form-control.readonly {
  background-color: #191a22;
  color: #e2e8f0;
  font-family: monospace;
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
}

.form-help {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Alias form row: label + nút Tạo lại */
.alias-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.alias-label-row .form-label {
  margin-bottom: 0;
}

/* Nút Tạo lại alias */
.btn-regen-alias {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(59, 130, 246, 0.12));
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.35);
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-regen-alias:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.32), rgba(59, 130, 246, 0.22));
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}

/* Indicator tự động */
.alias-auto-indicator {
  font-size: 11px;
  font-weight: 600;
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 4px;
  padding: 4px 10px;
  margin-top: 6px;
  animation: fade-in-up 0.3s ease;
}

.alias-auto-indicator.loading {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.2);
  background-image: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.05) 50%,
    rgba(255,255,255,0) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Quick Category Tags */
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.quick-tag {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-tag:hover, .quick-tag.active {
  background: rgba(255, 85, 0, 0.2);
  border-color: var(--btn-primary);
  color: #ff9955;
}

/* Button Group (Matching User Screenshot) */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
  box-shadow: 0 4px 12px rgba(255, 85, 0, 0.35);
}

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

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

/* List Tab Views */
.search-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.location-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s;
}

.location-item:hover {
  border-color: #4b5162;
}

.location-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.location-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.location-badge {
  background: rgba(255, 85, 0, 0.15);
  color: #ff8833;
  border: 1px solid rgba(255, 85, 0, 0.3);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
}

.location-coords {
  font-family: monospace;
  font-size: 12px;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.location-coords-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.copy-hint {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  opacity: 0.7;
}

/* Alias Section */
.alias-section {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alias-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alias-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.3px;
}

.alias-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.alias-tag {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: inherit;
}

/* Copy Alias Button */
.btn-copy-alias {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-copy-alias:hover {
  background: rgba(59, 130, 246, 0.28);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.5);
}

.btn-copy-alias.copied {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.location-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #252836;
  color: white;
  border: 1px solid var(--border-color);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.3s ease;
}

.toast.success {
  border-color: var(--accent-green);
  background: #0f2e22;
}

.toast.error {
  border-color: var(--accent-red);
  background: #3b1212;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: span 1;
  }
  .gps-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}
