/**
 * Estilos para el visor geográfico planexoid
 * Enfoque Mobile-First, prevención de desbordamiento horizontal y ergonomía táctil
 */

:root {
  --header-height: 56px;
  --bottom-nav-height: 60px;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Navbar superior ergonómico y táctil */
header {
  position: relative;
  z-index: 1040;
}

/* Barra inferior de navegación de pestañas (Bottom Navigation Tabs) */
#bottomNavBar {
  height: var(--bottom-nav-height);
  z-index: 1020;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background-color: rgba(33, 37, 41, 0.92) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45) !important;
}

.bottom-tab-link {
  transition: transform 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  user-select: none;
  border-radius: 8px;
}

.bottom-tab-link:hover,
.bottom-tab-link:focus {
  transform: translateY(-2px);
  background-color: rgba(255, 255, 255, 0.05);
}

.bottom-tab-link.active .bottom-tab-icon {
  filter: drop-shadow(0 2px 6px rgba(13, 110, 253, 0.6));
}

.bottom-tab-link.active .bottom-tab-label {
  color: #0d6efd !important;
}

.navbar {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.navbar-nav .nav-link {
  transition: color 0.2s ease, background-color 0.2s ease;
  border-radius: 6px;
  touch-action: manipulation;
}

.navbar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.navbar-toggler {
  touch-action: manipulation;
}

/* Botones de inicio de sesión y perfil en la barra superior */
#topNavLoginBtn,
#navLoginBtn {
  min-height: 44px;
  touch-action: manipulation;
  transition: all 0.2s ease-in-out;
}

#topNavLoginBtn:hover,
#navLoginBtn:hover {
  background-color: var(--bs-primary);
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(13, 110, 253, 0.35);
}

#topNavLoginBtn:hover i,
#navLoginBtn:hover i {
  color: #ffffff !important;
}

#userProfileCircleBtn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#userProfileCircleBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(25, 135, 84, 0.4);
}

/* Sidebar Offcanvas de Bootstrap 5.3 y Backdrop con z-index superior a bottomNavBar (1020) */
#sidebarOffcanvas.offcanvas,
.offcanvas {
  z-index: 1060 !important;
  max-width: 320px;
}

.offcanvas-backdrop {
  z-index: 1050 !important;
}

#navbarRightActions {
  touch-action: manipulation;
}

/* Contenedor del mapa a pantalla completa bajo el header y sobre la barra inferior */
#map-container {
  height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
  height: calc(100dvh - var(--header-height) - var(--bottom-nav-height));
  width: 100%;
  margin: 0;
  padding: 0;
  position: relative;
  background-color: #212529;
}

/* Indicador de carga sutil centrado */
#map-loading-indicator {
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.4s ease-out;
}

#map-loading-indicator.loaded {
  opacity: 0;
  visibility: hidden;
}

/* Personalización táctil de controles MapLibre */
.maplibregl-ctrl-group {
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  overflow: hidden;
  background-color: #212529 !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.maplibregl-ctrl-group button {
  min-width: 44px !important;
  min-height: 44px !important;
  touch-action: manipulation;
  background-color: #212529 !important;
  color: #dee2e6 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.maplibregl-ctrl-group button:last-child {
  border-bottom: none !important;
}

.maplibregl-ctrl-group button:hover {
  background-color: #2c3035 !important;
  color: #ffffff !important;
}

.maplibregl-ctrl-pluscodes.active {
  background-color: #0d6efd !important;
  color: #ffffff !important;
}

/* Elevación de controles inferiores de MapLibre para no colisionar con el bottom navbar */
.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
  bottom: calc(var(--bottom-nav-height, 60px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
  transition: bottom 0.2s ease;
  z-index: 1010 !important;
}

/* Atribución discreta */
.maplibregl-ctrl-attrib {
  background-color: rgba(33, 37, 41, 0.8) !important;
  color: #adb5bd !important;
  font-size: 11px !important;
}

.maplibregl-ctrl-attrib a {
  color: #0dcaf0 !important;
}

/* Corrección de especificidad en Bootstrap 5.3:
   Garantizar que el toggler use trazo oscuro nítido y borde canónico en la navbar light */
.navbar[data-bs-theme="light"] .navbar-toggler-icon,
[data-bs-theme="light"] .navbar-toggler-icon {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

.navbar[data-bs-theme="light"] .navbar-toggler {
  border-color: rgba(0, 0, 0, 0.2) !important;
}

.navbar[data-bs-theme="light"] .navbar-toggler:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Prevención de desbordamiento horizontal y elevación táctil en pantallas pequeñas */
@media (max-width: 991.98px) {
  .navbar-collapse.show,
  .navbar-collapse.collapsing {
    background-color: var(--bs-tertiary-bg, #212529);
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(255, 255, 255, 0.15));
    padding: 0.5rem 0.75rem 1rem 0.75rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  }
}

/* Ergonomía táctil para formularios de autenticación (mínimo 44x44px y sin desbordamiento a 320px) */
.form-control,
.form-select,
.input-group-text,
.btn {
  min-height: 44px;
  touch-action: manipulation;
}

@media (max-width: 576px) {
  .card {
    border-radius: 0.75rem;
  }
  .card-body {
    padding: 1.25rem !important;
  }
}

/* Offcanvas Bottom Extendido (Mayor altura para visualización y personalización de parcelas) */
.offcanvas-bottom-extended {
  height: 68vh !important;
  max-height: 85vh !important;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.65);
  z-index: 1055;
  background-color: rgba(33, 37, 41, 0.96) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.offcanvas-bottom-extended .nav-tabs .nav-link {
  min-height: 44px;
  font-weight: 600;
  color: var(--bs-secondary-color);
  border-radius: 8px 8px 0 0;
}

.offcanvas-bottom-extended .nav-tabs .nav-link.active {
  color: #ffc107 !important;
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.2) transparent;
}

#property-draw-canvas {
  touch-action: none;
  cursor: crosshair;
  background-color: #1a1d20;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
}


