:root {
  --rioterra-green: #0a1f06;
  --bg: #ffffff;
  --text: #222;
}

/* reset simples */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html,
body,
#map {
  height: 100%
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* header */
.header {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 8px 32px;
  background: #fff;
  color: var(--rioterra-green);
  border-bottom: 4px solid #0a1f06;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
}

.lang-switcher {
  display: flex;
  gap: 12px;
  align-items: center;
}

.lang-switcher .fi {
  width: 28px;
  height: 20px;
  cursor: pointer;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  opacity: 0.6;
}

.lang-switcher .fi:hover {
  opacity: 1;
  transform: scale(1.15);
}

.header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 2.4rem;
  letter-spacing: 4px;
  display: flex;
  gap: 12px;
  line-height: 1;
  user-select: none;
}

.brand-name .geo {
  color: #0a1f06;
}

.brand-name .rioterra {
  color: #9b6732;
}

.logo {
  height: 70px;
  display: inline-block;
  vertical-align: middle;
}

/* botão toggle */
.toggle-sidebar {
  position: fixed;
  left: 20px;
  top: 120px;
  z-index: 1100;
  /* Acima do mapa (0) e abaixo da sidebar se aberta (1200) */
  background: #0a1f06;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

/* Esconde o botão quando a sidebar está aberta */
.sidebar:not(.collapsed)~.toggle-sidebar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.toggle-sidebar:hover {
  background: #15440c;
}



.header-title {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* sidebar redesign - Dark Boxed with Semi-Transparency */
.sidebar {
  position: fixed;
  left: 0;
  top: 100px;
  bottom: 0;
  width: 320px;
  max-width: 90%;
  background: #0a1f06;
  z-index: 1200;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
  transform: translateX(-320px);
  transition: transform .4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  color: #fff;
  border-top-right-radius: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed {
  transform: translateX(-320px);
}

.sidebar:not(.collapsed) {
  transform: translateX(0);
}

.sidebar-header {
  padding: 24px 16px 20px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar .header-title {
  font-weight: 700;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  position: relative;
  width: 100%;
  text-align: center;
}

/* Linha verde vibrante abaixo do título */
.sidebar .header-title::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 0;
  width: 100%;
  height: 3px;
  background: #9b6732;
  /* Verde neon da imagem */
  box-shadow: 0 0 10px rgba(155, 103, 50, 0.5);
}

.sidebar .close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: transparent;
}

/* Seção Mapa Base e Outras Seções */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-align: center;
}

.basemap-grid {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 10px;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.basemap-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.basemap-btn.active {
  background: #9b6732;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(155, 103, 50, 0.3);
}

/* Barra de Busca */
.sidebar .search-container {
  position: relative;
  width: 100%;
}

.sidebar .search-container input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 35px 12px 15px;
  color: #fff;
  font-size: 0.9rem;
}

.sidebar .search-container input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.sidebar .search-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.5);
}

/* Categorias Boxed */
.layer-categories {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.category-item {
  border: none;
}

.category-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #fff;
}

.category-header:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #9b6732;
  box-shadow: 0 0 15px rgba(155, 103, 50, 0.2);
}

.category-header i {
  color: #9b6732;
  /* Ícones verdes como na imagem */
  font-size: 1.1rem;
}


.category-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0 0 10px 10px;
}

.category-item.active .category-content {
  max-height: 800px;
  padding: 10px 15px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: opacity 0.2s;
}

.layer-item:hover {
  opacity: 0.8;
}

.layer-item:last-child {
  border-bottom: none;
}

.layer-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #9b6732;
}

.layer-item label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  user-select: none;
}

/* Sub-categorias (Sub-tópicos) */
.sub-category {
  margin-top: 10px;
  margin-bottom: 5px;
}

.sub-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-category-header:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #9b6732;
}

.sub-category-header i {
  font-size: 0.8rem;
  color: #9b6732;
  transition: transform 0.3s ease;
}

.sub-category.active .sub-category-header i {
  transform: rotate(180deg);
}

.sub-category-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  padding-left: 10px;
  border-left: 2px solid rgba(155, 103, 50, 0.3);
  margin-left: 5px;
  margin-top: 5px;
}

.sub-category.active .sub-category-content {
  max-height: 400px;
  padding-top: 5px;
  padding-bottom: 5px;
}

/* Suporte para aninhamento mais profundo (3º nível) */
.sub-category-content .sub-category {
  margin-top: 5px;
  margin-bottom: 5px;
}

.sub-category-content .sub-category-header {
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  font-size: 0.8rem;
  border-color: rgba(255, 255, 255, 0.03);
}

.sub-category-content .sub-category-content {
  border-left: 1px dashed rgba(155, 103, 50, 0.5);
  padding-left: 15px;
}

/* Footer Sidebar */
.sidebar-footer {
  padding: 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.info-footer {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
}

.info-footer i {
  color: #9b6732;
  font-size: 0.9rem;
}

.info-footer:hover {
  text-decoration: underline;
}

/* barra de ferramentas vertical do mapa */
.map-tools {
  position: fixed;
  right: 20px;
  top: 110px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
}

.tool-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #0a1f06;
  color: #0a1f06;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: #0a1f06;
  color: #fff;
  transform: scale(1.05);
}

.tool-btn i {
  transition: transform 0.2s;
}

.tool-btn:active {
  transform: scale(0.95);
}

/* small screens */
@media (max-width: 700px) {
  .map-tools {
    right: 10px;
    top: 100px;
    gap: 8px;
  }

  .tool-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* map */
.map {
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1
}

/* Estilo de "pílula" para os créditos (atribuição) - Fixado no canto */
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.9) !important;
  padding: 6px 15px !important;
  border-radius: 30px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  border: none !important;
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 11px !important;
  color: #333 !important;
  position: fixed !important;
  right: 20px !important;
  bottom: 20px !important;
  z-index: 2000 !important;
  /* Acima de tudo */
  margin: 0 !important;
}

.leaflet-control-attribution a {
  color: #0078A8 !important;
  text-decoration: none;
  font-family: Arial, Helvetica, sans-serif !important;
}

/* Esconde o prefixo "Leaflet" se quiser apenas o conteúdo, 
   mas na imagem aparece o link do Leaflet, então mantemos. */

/* Estilo de pílula para as coordenadas */
.coords {
  background: rgba(255, 255, 255, 0.8) !important;
  padding: 6px 15px !important;
  border-radius: 30px !important;
  margin: 10px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  border: none !important;
  font-size: 12px !important;
  color: #15440c !important;
  /* Verde do projeto */
  font-weight: 600;
}

/* Marcador de localização customizado */
.custom-location-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.location-dot {
  width: 14px;
  height: 14px;
  background: #0a1f06;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
}

/* Menu de Medição Flutuante */
.measure-menu-container {
  position: absolute;
  right: 70px;
  top: 190px;
  width: 240px;
  background: #0a1f06;
  color: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 1500;
  display: none;
  /* Ativado via JS */
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  animation: fadeInRight 0.3s ease;
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.measure-menu-header {
  padding: 12px 15px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
  font-size: 0.95rem;
}

.measure-menu-body {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.measure-type-selector {
  display: flex;
  gap: 8px;
}

.measure-opt-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 10px 5px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.measure-opt-btn i {
  font-size: 1.1rem;
}

.measure-opt-btn:hover {
  background: rgba(155, 103, 50, 0.2);
  border-color: #9b6732;
}

.measure-opt-btn.active {
  background: #9b6732;
  color: #0a1f06;
  border-color: #9b6732;
  font-weight: 600;
}

.measure-unit-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.measure-unit-selector label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}

.measure-unit-selector select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

.clear-btn {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: opacity 0.2s;
}

.clear-btn:hover {
  opacity: 0.9;
}

.close-mini-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

/* Rótulos de medição no mapa */
.measure-label {
  background: none;
  border: none;
  color: #9b6732;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* popup styles */
.leaflet-popup-content-wrapper {
  font-size: 14px
}

/* barra de camadas centralizada na base */
.leaflet-bottom.leaflet-right {
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  /* permite clicar no mapa através do container vazio */
}

.leaflet-control-layers-expanded {
  pointer-events: auto;
  /* reativa cliques na barra */
  display: flex !important;
  flex-direction: row;
  /* Volta a ser horizontal */
  padding: 6px !important;
  background: rgba(255, 255, 255, 0.9) !important;
  border: none !important;
  border-radius: 30px !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
  margin-bottom: 20px !important;
  gap: 8px;
}

.leaflet-control-layers-base {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.leaflet-control-layers-base label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: #f0f0f0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.leaflet-control-layers-base label:hover {
  background: #e0e0e0;
}

/* Esconde o rádio original */
.leaflet-control-layers-base input {
  display: none;
}

/* Estilo para quando o item está selecionado */
.leaflet-control-layers-base label:has(input:checked) {
  background: var(--rioterra-green);
  color: #9b6732;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* small screen adjustments */
@media (max-width:700px) {
  .sidebar {
    width: 280px
  }

  .toggle-sidebar {
    top: 68px
  }

  .leaflet-control-layers-expanded {
    scale: 0.85;
    border: 1px solid rgba(155, 103, 50, 0.3);
  }
}

/* Modal de Informações */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  /* Oculto por padrão */
  align-items: center;
  justify-content: center;
  z-index: 3000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #fff;
  width: 95%;
  max-width: 450px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--rioterra-green);
  animation: modalEnter 0.3s ease-out;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  background: var(--rioterra-green);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn-modal {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  color: #333;
  line-height: 1.6;
  text-align: center;
}

.modal-body p {
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.modal-body hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid #eee;
}

.modal-body a {
  color: var(--rioterra-green);
  text-decoration: none;
  font-weight: 600;
}

.modal-body a:hover {
  text-decoration: underline;
}

.modal-overlay.active {
  display: flex;
}

/* Coordenadas centralizadas na base */
.coords {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0a1f06;
  color: #2ecc71;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 600;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(46, 204, 113, 0.3);
  pointer-events: none;
  white-space: nowrap;
}

/* =============================================
   Rótulos QML — Divisas Estaduais e Malha Viária
   Fonte: Open Sans 10pt, cor rgb(50,50,50),
   halo: rgb(250,250,250) — conforme QML
   ============================================= */

/* Importa Open Sans (mesma fonte do QML) */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&display=swap');

/* Rótulo permanente — Divisas Estaduais (fieldName="nome") */
.qml-label-estado {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: 'Open Sans', sans-serif !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: rgb(50, 50, 50) !important;
  /* Halo branco (bufferColor do QML: 250,250,250) */
  text-shadow:
    -1px -1px 2px rgb(250, 250, 250),
    1px -1px 2px rgb(250, 250, 250),
    -1px 1px 2px rgb(250, 250, 250),
    1px 1px 2px rgb(250, 250, 250),
    -2px 0 2px rgb(250, 250, 250),
    2px 0 2px rgb(250, 250, 250),
    0 -2px 2px rgb(250, 250, 250),
    0 2px 2px rgb(250, 250, 250) !important;
  pointer-events: none !important;
  white-space: nowrap !important;
}

.qml-label-estado::before {
  display: none !important;
}

/* Rótulo hover — Malha Viária (fieldName="Name") */
.qml-label-via {
  background: rgba(250, 250, 250, 0.92) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-radius: 4px !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15) !important;
  font-family: 'Open Sans', sans-serif !important;
  font-size: 10px !important;
  font-weight: 400 !important;
  color: rgb(50, 50, 50) !important;
  padding: 3px 6px !important;
  pointer-events: none !important;
  white-space: nowrap !important;
}

.qml-label-via::before {
  display: none !important;
}

/* Rótulo permanente — Municípios (fieldName="nome") */
.qml-label-municipio {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: 'Open Sans', sans-serif !important;
  font-size: 9px !important; /* Ligeiramente menor que o estado */
  font-weight: 400 !important;
  color: rgb(70, 70, 70) !important; /* Cinza escuro conforme QML */
  text-shadow:
    -1px -1px 1px rgb(250, 250, 250),
    1px -1px 1px rgb(250, 250, 250),
    -1px 1px 1px rgb(250, 250, 250),
    1px 1px 1px rgb(250, 250, 250) !important;
  pointer-events: none !important;
  white-space: nowrap !important;
}

.qml-label-municipio::before {
  display: none !important;
}