/* =============================================
   VHASS GIS - Main Stylesheet
   ============================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: #333;
}

/* =============================================
   Header
   ============================================= */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  z-index: 1001;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
}

.app-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a1a1a;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-container {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.search-container input {
  width: 240px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
}

.search-container input::placeholder {
  color: #999;
}

.search-container button {
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: color 0.2s;
}

.search-container button:hover {
  color: #2E7D32;
}

/* =============================================
   Main Layout
   ============================================= */
.main-container {
  display: flex;
  height: calc(100vh - 56px);
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
  width: 300px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 1000;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.sidebar-title {
  font-weight: 600;
  font-size: 15px;
  color: #333;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: #e0e0e0;
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* =============================================
   Layer Groups
   ============================================= */
.layer-group {
  border-bottom: 1px solid #eee;
}

.layer-group:last-child {
  border-bottom: none;
}

.layer-group-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s;
  gap: 8px;
}

.layer-group-header:hover {
  background: #f5f5f5;
}

.group-chevron {
  font-size: 12px;
  color: #666;
  transition: transform 0.2s;
}

.layer-group.collapsed .group-chevron {
  transform: rotate(-90deg);
}

.group-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
}

.pin-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #999;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}

.layer-group-header:hover .pin-btn {
  opacity: 1;
}

.pin-btn:hover {
  color: #2E7D32;
}

.pin-btn.pinned {
  opacity: 1;
  color: #2E7D32;
}

.layer-group-content {
  padding: 4px 0 8px 0;
  display: block;
}

.layer-group.collapsed .layer-group-content {
  display: none;
}

/* =============================================
   Toggle Switch
   ============================================= */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.toggle-switch input:disabled + .toggle-slider {
  background-color: #e0e0e0;
  cursor: not-allowed;
}

/* =============================================
   Layer Items
   ============================================= */
.layer-item {
  display: flex;
  align-items: center;
  padding: 6px 12px 6px 20px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.layer-item:hover {
  background: #f5f5f5;
}

.layer-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layer-item.active {
  background: #e8f5e9;
}

.layer-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.layer-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.layer-name {
  flex: 1;
  font-size: 13px;
}

.layer-expand {
  width: 20px;
  height: 20px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #666;
  cursor: pointer;
}

.layer-expand:hover {
  background: #f0f0f0;
}

/* =============================================
   Map Wrapper
   ============================================= */
.map-wrapper {
  flex: 1;
  position: relative;
  background: #e5e3df;
}

#map {
  width: 100%;
  height: 100%;
}

/* =============================================
   Map Controls
   ============================================= */
.map-controls {
  position: absolute;
  top: 80px;
  left: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-control-btn {
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 14px;
  transition: background 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.map-control-btn:hover {
  background: #f0f0f0;
}

/* =============================================
   Navigate Dropdown
   ============================================= */
.navigate-dropdown {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
}

.navigate-btn {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: background 0.2s;
}

.navigate-btn:hover {
  background: #f5f5f5;
}

.navigate-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: 180px;
  overflow: hidden;
}

.navigate-menu.show {
  display: block;
}

.navigate-menu a {
  display: block;
  padding: 10px 16px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s;
}

.navigate-menu a:hover {
  background: #f5f5f5;
}

/* =============================================
   Coordinates Display
   ============================================= */
.coordinates-display {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.9);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: #555;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  z-index: 1000;
  white-space: nowrap;
}

.custom-attribution {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(255,255,255,0.8);
  padding: 2px 8px;
  font-size: 11px;
  color: #666;
  z-index: 1000;
}

/* =============================================
   Leaflet Overrides
   ============================================= */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2) !important;
}

.leaflet-control-zoom a {
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 13px;
}

/* =============================================
   Popup Styles
   ============================================= */
.popup-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  color: #2E7D32;
}

.popup-row {
  display: flex;
  margin-bottom: 4px;
}

.popup-label {
  font-weight: 500;
  color: #666;
  width: 80px;
  flex-shrink: 0;
}

.popup-value {
  color: #333;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1001;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .search-container input {
    width: 160px;
  }
}

/* =============================================
   Facility Type Colors
   ============================================= */
.facility-air-transport { background-color: #D32F2F; }
.facility-alt-care { background-color: #D32F2F; }
.facility-dialysis { background-color: #D32F2F; }
.facility-family-assistance { background-color: #4CAF50; }
.facility-free-standing { background-color: #4CAF50; }
.facility-hospital { background-color: #2196F3; }
.facility-long-term { background-color: #9C27B0; }
.facility-ndms { background-color: #9C27B0; }
.facility-public-health { background-color: #FF9800; }
.facility-rhcc { background-color: #FF9800; }
.facility-ocme { background-color: #D32F2F; }
.facility-support { background-color: #D32F2F; }

/* Region colors */
.region-counties { background-color: #78909C; }
.region-doe { background-color: #26A69A; }
.region-mrc { background-color: #AB47BC; }
.region-vdem { background-color: #5C6BC0; }
.region-vdh { background-color: #66BB6A; }
.region-ocme { background-color: #EF5350; }
.region-odw { background-color: #42A5F5; }
.region-hpp { background-color: #FFA726; }
