/* ============================================================
   MAPEADOS — Estilos
   Dark theme inspirado no mapa Telefonica
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #1e293b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #334155;
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* Header */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}
.tagline { font-size: 12px; color: var(--text-muted); }

.header-center { flex: 1; max-width: 400px; margin: 0 24px; }
.search-box {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box button {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
}
.search-box button:hover { color: var(--accent); }

.header-right { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--bg-card);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.user-info { font-size: 12px; color: var(--text-muted); }

/* Buttons */
.btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-google { background: #34a853; color: #fff; }
.btn-google:hover { background: #2d8f47; }
.btn-google:disabled { background: var(--text-muted); cursor: not-allowed; }
.btn-cnpj { background: var(--warning); color: #000; }
.btn-cnpj:hover { background: #d97706; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Map */
#map {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Marker Pins */
.marker-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.marker-pin:hover { transform: rotate(-45deg) scale(1.2); }
.pin-dot {
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.8);
  border-radius: 50%;
  transform: rotate(45deg);
}

/* Cluster Markers */
.cluster-marker {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border: 3px solid rgba(59,130,246,0.3);
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}
.cluster-marker:hover { transform: scale(1.15); }

/* Popup */
.maplibregl-popup-content {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 0 !important;
  box-shadow: var(--shadow) !important;
}
.maplibregl-popup-tip { border-top-color: var(--bg-card) !important; }
.maplibregl-popup-close-button { color: var(--text-secondary) !important; font-size: 18px; }

.popup-content { padding: 12px; }
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}
.popup-source { font-size: 10px; }
.popup-body { font-size: 12px; }
.popup-field { margin-bottom: 4px; color: var(--text-secondary); }
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.popup-btn-ficha {
  width: 100%;
  margin-top: 8px;
}

/* Filter Panel */
.filter-panel {
  position: fixed;
  top: 56px;
  right: 0;
  width: 280px;
  height: calc(100vh - 56px);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  padding: 16px;
  z-index: 999;
  overflow-y: auto;
  transition: transform 0.3s;
}
.filter-panel.hidden { transform: translateX(100%); }
.filter-panel h3 { margin-bottom: 16px; font-size: 16px; }
.filter-group { margin-bottom: 16px; }
.filter-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.filter-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  cursor: pointer;
}
.filter-checks input[type="checkbox"] { accent-color: var(--accent); }
.filter-panel select {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.filter-panel .btn { width: 100%; margin-top: 8px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; padding: 10px; }

/* Ficha sections */
.ficha-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.ficha-section:last-child { border-bottom: none; }
.ficha-section h3 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.ficha-section h3 small { font-size: 11px; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.ficha-section h3 small.muted { color: var(--text-muted); }

.ficha-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ficha-field { font-size: 13px; }
.ficha-field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ficha-field span { color: var(--text-primary); }
.ficha-field a { color: var(--accent); text-decoration: none; }
.ficha-field a:hover { text-decoration: underline; }
.ficha-field.full-width { grid-column: 1 / -1; }

/* Editable fields */
.ficha-field.editable input,
.ficha-field.editable select,
.ficha-field.editable textarea {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.ficha-field.editable input:focus,
.ficha-field.editable select:focus,
.ficha-field.editable textarea:focus {
  border-color: var(--accent);
  outline: none;
}

/* Socios table */
.socios-table { margin-top: 12px; }
.socios-table h4 { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.socios-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.socios-table th {
  text-align: left;
  padding: 6px 8px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.socios-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.loading.hidden { display: none; }
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { color: var(--text-primary); font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Legenda */
.map-legend {
  position: fixed;
  bottom: 32px;
  left: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  z-index: 1001;
  font-size: 12px;
  pointer-events: auto;
}
.legend-title { font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.legend-item { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--text-secondary); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); flex-shrink: 0; }

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

/* Responsive */
@media (max-width: 768px) {
  .header-center { display: none; }
  .tagline { display: none; }
  .modal { width: 95%; max-height: 90vh; }
  .ficha-grid { grid-template-columns: 1fr; }
  .filter-panel { width: 100%; }
}
