/* ==========================================================================
   Localizador de Vértices Geodésicos de España - Estilos Oficiales
   ========================================================================== */

:root {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #1a2433;
  --bg-card-hover: #222f42;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-accent: #06b6d4;
  --color-gold: #f59e0b;
  --color-emerald: #10b981;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.tool-layout {
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr 300px;
  }
}

.tool-main-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .card-main {
    padding: 1.75rem;
  }
}

/* --------------------------------------------------------------------------
   Barra superior de búsqueda y red
   -------------------------------------------------------------------------- */
.vg-control-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .vg-control-bar {
    flex-direction: row;
    align-items: center;
  }
}

.vg-search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.vg-search-wrap input {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  padding: 0 38px 0 40px;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vg-search-wrap input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-clear-input {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.btn-clear-input:hover {
  color: var(--text-main);
}

.vg-suggestions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
  z-index: 1000;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background-color 0.15s;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: var(--bg-card-hover);
}

.suggestion-main {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.suggestion-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.vg-actions-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .vg-actions-group {
    flex-wrap: nowrap;
  }
}

.btn-secondary {
  height: 44px;
  min-height: 40px;
  padding: 0 1rem;
  box-sizing: border-box;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s;
  text-decoration: none;
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--text-dim);
}

.network-select-wrap {
  min-width: 220px;
}

/* Reglas estrictas para desplegables */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 44px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 38px 0 0.85rem;
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* --------------------------------------------------------------------------
   Workspace dividido (Mapa + Ficha de vértice)
   -------------------------------------------------------------------------- */
.vg-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .vg-workspace-grid {
    grid-template-columns: 1fr 370px;
  }
}

.vg-map-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: #0b0f17;
  min-height: 450px;
}

.vg-map-container {
  width: 100%;
  height: 550px;
  background-color: #1a202c;
}

@media (min-width: 960px) {
  .vg-map-container {
    height: 640px;
  }
}

/* Selector flotante de capas */
.vg-layer-selector {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  background-color: rgba(19, 27, 38, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 200px;
}

[data-theme="light"] .vg-layer-selector {
  background-color: rgba(255, 255, 255, 0.92);
}

.layer-selector-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.layer-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.btn-layer {
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.btn-layer:hover {
  color: var(--text-main);
  background-color: var(--bg-card-hover);
}

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

/* Badge contador */
.vg-count-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 500;
  background-color: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Panel lateral: Ficha de vértice
   -------------------------------------------------------------------------- */
.vg-sidebar-card {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 400px;
}

.vg-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.empty-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: rgba(59, 130, 246, 0.12);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.vg-quick-peaks {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
  text-align: left;
}

.quick-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.5rem;
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.quick-tag {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 5px 9px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-tag:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Ficha real */
.vg-sheet-card {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.sheet-top-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sheet-badge-row {
  display: flex;
  gap: 0.5rem;
}

.vg-tag-badge {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.vg-num-badge {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.72rem;
}

.vg-name {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.vg-location {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Caja de altitud oficial */
.vg-altitude-box {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(6, 182, 212, 0.08) 100%);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alt-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent);
}

.alt-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
}

.alt-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.alt-unit {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.alt-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Cuadrícula de especificaciones */
.vg-specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  background-color: var(--bg-card);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.spec-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spec-cell.full-width {
  grid-column: 1 / -1;
  padding-top: 4px;
  border-top: 1px solid var(--border-color);
}

.spec-label {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.spec-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-all;
}

/* Acciones */
.vg-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.btn-primary {
  width: 100%;
  height: 46px;
  min-height: 40px;
  box-sizing: border-box;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.vg-action-subrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-action-sub {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Guía inferior
   -------------------------------------------------------------------------- */
.vg-guide-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.guide-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .guide-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.guide-box {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.guide-box h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.guide-box p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Modal accesible
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

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

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

.modal-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  color: var(--text-main);
}

.modal-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-actions {
  width: 100%;
  margin-top: 0.5rem;
}

/* Marcadores personalizados para los vértices */
.vg-marker-icon {
  background: none;
  border: none;
}

.vg-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: #3b82f6;
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  transition: transform 0.15s, background-color 0.15s;
}

.vg-pin.regente {
  background-color: #f59e0b;
}

.vg-pin:hover,
.vg-pin.active {
  transform: scale(1.28);
  background-color: #ef4444;
  z-index: 1000 !important;
}

.leaflet-control-attribution {
  background-color: rgba(11, 15, 23, 0.8) !important;
  color: var(--text-dim) !important;
  font-size: 0.68rem !important;
}

.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}
