/* ========================================
   BASE STYLES
   ======================================== */

body {
  font-family: "Montserrat", sans-serif;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

#container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ========================================
   HEADER
   ======================================== */

.header {
  background-color: #f9f9f9;
  padding: 0 30px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  height: 60px;
}

.logo {
  height: 40px;
  width: auto;
  margin-right: 20px;
}

.header-title {
  font-family: "Montserrat", sans-serif;
  color: #333;
  font-size: 24px;
  font-weight: 500;
  margin: 0;
}

/* ========================================
   MAP
   ======================================== */

#map {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgb(255, 255, 255);
}

.leaflet-interactive:focus {
  outline: none !important;
}

/* ========================================
   HOME BUTTON
   ======================================== */

.home-button {
  position: absolute !important;
  top: 60px !important;
  left: -3px !important;
  border: 1px solid #dadce0;
}

/* ========================================
   SEARCH CONTROL
   ======================================== */

.leaflet-control-geosearch {
  position: absolute !important;
  top: 4px !important;
  left: 10px !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
}

/* ========================================
   LAYER TOGGLE BUTTON
   ======================================== */

#layer-toggle-container {
  position: absolute;
  top: 120px;
  left: 10px;
  z-index: 99999 !important;
}

#layer-toggle {
  width: 30px;
  height: 30px;
  background-color: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  cursor: pointer;
  box-shadow: none;
  display: block;
  padding: 0;
  margin: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2l9 5-9 5-9-5 9-5z"/><path d="M3 12l9 5 9-5"/><path d="M3 17l9 5 9-5"/></svg>');
  background-size: 20px 20px;
  background-position: center;
  background-repeat: no-repeat;
}

#layer-toggle:hover {
  background-color: #f1f1f1;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ========================================
   LAYER CONTROLS PANEL
   ======================================== */

#layer-controls {
  position: absolute;
  top: 0;
  left: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 0;
  display: none;
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  min-width: 280px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 1001;
  font-family: "Roboto", "Arial", sans-serif;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}

/* Header mit Close Button */
#layer-controls h2 {
  padding: 12px 16px 8px 16px;
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 500;
  color: #202124;
  border-bottom: 1px solid #dadce0;
  position: relative;
}

#layer-controls h2::after {
  content: "×";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: #5f6368;
  cursor: pointer;
  line-height: 1;
}

/* Section Headers */
#layer-controls h3 {
  padding: 2px 16px 6px 16px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Scrollbar */
#layer-controls::-webkit-scrollbar {
  width: 8px;
}

#layer-controls::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#layer-controls::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

#layer-controls::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ========================================
   LAYER GRID & ITEMS
   ======================================== */

.layer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 0;
  padding: 4px 16px;
}

.layer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 6px 10px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-align: center;
  min-height: 65px;
  user-select: none;
}

.layer-item:hover .icon {
  background-color: #fce8ee;
}

.layer-item.selected .icon {
  border: 2px solid #2e2d2c8c !important;
  background-color: #efeae4;
}

/* Icons */
.layer-item .icon {
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
  border: 1px solid #dadce0;
  font-size: 28px;
}

.layer-item .icon svg,
.layer-item .icon img {
  width: 40px;
  height: 40px;
  user-select: none;
}

/* Labels */
.layer-item .label {
  font-size: 12px;
  color: #202124;
  font-weight: 400;
  line-height: 1.2;
  user-select: none;
}

/* Hidden Inputs */
.layer-item input[type="checkbox"],
.layer-item input[type="radio"] {
  display: none;
}

/* Disabled State */
.layer-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layer-item.disabled:hover {
  background-color: transparent;
}

/* Disabled by Zoom Level */
.layer-item.disabled-zoom {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

.layer-item.disabled-zoom .icon {
  filter: grayscale(100%);
}

.layer-item.disabled-zoom .label {
  color: #999 !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media screen and (max-width: 768px) {
  #layer-controls {
    min-width: 260px;
  }

  .layer-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  }

  .layer-item {
    padding: 8px 4px;
    min-height: 70px;
  }

  .layer-item .icon {
    width: 32px;
    height: 32px;
  }

  .layer-item .icon svg {
    width: 18px;
    height: 18px;
  }
}

@media screen and (max-height: 800px) {
  #layer-controls {
    max-height: 70vh;
  }
}

@media screen and (max-height: 600px) {
  #layer-controls {
    max-height: 50vh;
  }
}