/* =============================================
   RESET & BASE STYLES
   ============================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: transparent; /* Transparent for WordPress embedding */
  color: #ffffff;
  overflow-x: hidden;
}

/* =============================================
   MAIN WRAPPER - Centers the entire widget
   ============================================= */
.snow-map-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  background: #1a1a2e;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* =============================================
   HEADER SECTION
   ============================================= */
.map-header {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  padding: 1rem 0.75rem 0.75rem;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1000;
  border-radius: 8px 8px 0 0;
}

.header-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #ffffff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header-subtitle {
  font-size: 0.85rem;
  color: #b8c6db;
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.header-link {
  color: #4a9eff;
  text-decoration: none;
  margin-left: 4px;
  transition: color 0.2s ease;
}

.header-link:hover {
  color: #7cbaff;
  text-decoration: underline;
}

/* =============================================
   CONTROLS BAR
   ============================================= */
.controls-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.search-container {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

#county-search {
  width: 100%;
  padding: 10px 35px 10px 15px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#county-search:focus {
  outline: none;
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
  background: white;
}

#county-search::placeholder {
  color: #888;
}

#clear-search {
  position: absolute;
  right: 8px;
  top: 12px;
  background: none;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 5px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

#clear-search.visible {
  opacity: 1;
}

#clear-search:hover {
  color: #333;
}

/* Search Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-height: 300px;
  overflow-y: auto;
  z-index: 2000;
  display: none;
}

.search-dropdown.visible {
  display: block;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-dropdown-item {
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.search-dropdown-item:hover {
  background: rgba(74, 158, 255, 0.1);
}

.search-dropdown-item.selected {
  background: rgba(74, 158, 255, 0.15);
}

.dropdown-county-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.dropdown-county-level {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.search-dropdown-empty {
  padding: 16px 15px;
  text-align: center;
  color: #888;
  font-size: 13px;
  font-style: italic;
}

.control-buttons {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: #4a9eff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon-btn .icon {
  font-size: 18px;
}

.icon-btn.active {
  background: #4a9eff;
  color: white;
}

/* =============================================
   MAP CONTAINER
   ============================================= */
.map-container {
  position: relative;
  width: 100%;
  height: 450px;
  min-height: 350px;
  background: #0f1419;
}

#map {
  height: 100%;
  width: 100%;
  max-width: 100%;
  display: block;
  background: #0f1419;
}

/* =============================================
   LOADING OVERLAY
   ============================================= */
#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 20, 25, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s ease-out;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #4a9eff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

#loading-overlay p {
  color: #b8c6db;
  font-size: 1rem;
  font-weight: 500;
}

/* =============================================
   LEGEND STYLES
   ============================================= */
.legend {
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 16px;
  line-height: 1.8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  color: #1a1a2e !important;
  max-width: 280px;
  transition: all 0.3s ease;
}

.legend strong {
  display: block;
  margin-top: 8px;
  margin-bottom: 4px;
  color: #0f3460;
  font-size: 15px;
}

.legend strong:first-child {
  margin-top: 0;
}

.legend span {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  vertical-align: middle;
}

.legend-item {
  display: flex;
  align-items: center;
  margin: 4px 0;
}

/* Legend Toggle Button for Mobile */
.legend-toggle {
  display: none;
  position: absolute;
  bottom: 100px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #0f3460;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  transition: all 0.3s ease;
  touch-action: manipulation;
}

.legend-toggle:active {
  transform: scale(0.95);
}

.legend-toggle.active {
  background: #4a9eff;
  color: white;
}

/* =============================================
   CUSTOM LOGO STYLES
   ============================================= */
.custom-logo {
  background-color: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.custom-logo img {
  max-width: 200px;
  max-height: 60px;
  object-fit: contain;
  display: block;
}

/* =============================================
   WATERMARK STYLES
   ============================================= */
.center-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.08); /* Mostly transparent */
  pointer-events: none; /* Allows clicking through to the map */
  z-index: 400;
  white-space: nowrap;
  text-transform: uppercase;
  user-select: none;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* =============================================
   TIMESTAMP STYLES
   ============================================= */
.last-updated {
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  color: #1a1a2e;
  font-weight: 500;
  white-space: nowrap;
}

/* =============================================
   LEAFLET CONTROL ADJUSTMENTS
   ============================================= */
.leaflet-control-zoom a {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #0f3460 !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 20px !important;
  border-radius: 4px !important;
  transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background: #4a9eff !important;
  color: white !important;
}

.leaflet-bar {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
  border: none !important;
}

.leaflet-bar a {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.leaflet-bar a:first-child {
  border-top-left-radius: 8px !important;
  border-top-right-radius: 8px !important;
}

.leaflet-bar a:last-child {
  border-bottom-left-radius: 8px !important;
  border-bottom-right-radius: 8px !important;
  border-bottom: none !important;
}

/* Tooltip styling */
.leaflet-tooltip {
  background: rgba(0, 0, 0, 0.85) !important;
  border: none !important;
  border-radius: 6px !important;
  color: white !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  padding: 6px 10px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  border-top-color: rgba(0, 0, 0, 0.85) !important;
  border-bottom-color: rgba(0, 0, 0, 0.85) !important;
  border-left-color: rgba(0, 0, 0, 0.85) !important;
  border-right-color: rgba(0, 0, 0, 0.85) !important;
}

/* =============================================
   TABLET STYLES (768px and below)
   ============================================= */
@media (max-width: 768px) {
  .header-content h1 {
    font-size: 1.75rem;
  }

  .header-subtitle {
    font-size: 0.9rem;
  }

  .map-container {
    height: 50vh;
    min-height: 350px;
  }

  /* Stack info section on tablets */
  .info-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .info-section {
    padding: 1.5rem 1rem;
  }

  .stats-panel,
  .favorites-panel {
    max-width: 180px;
    font-size: 12px;
  }

  .controls-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-container {
    max-width: 100%;
  }

  .legend {
    font-size: 13px;
    padding: 10px 14px;
    max-width: 240px;
  }

  .legend strong {
    font-size: 14px;
  }

  .legend span {
    width: 14px;
    height: 14px;
  }

  .custom-logo img {
    max-width: 150px;
    max-height: 50px;
  }

  .last-updated {
    font-size: 12px;
    padding: 6px 10px;
  }

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

/* =============================================
   MOBILE STYLES (640px and below)
   ============================================= */
@media (max-width: 640px) {
  .map-header {
    padding: 1rem 0.75rem;
  }

  .header-content h1 {
    font-size: 1.5rem;
  }

  .header-subtitle {
    font-size: 0.85rem;
  }

  .map-container {
    height: 50vh;
    min-height: 300px;
  }

  /* Mobile info section adjustments */
  .info-section {
    padding: 1rem 0.75rem;
  }

  .info-container {
    gap: 1rem;
  }

  .stats-table,
  .favorites-table {
    padding: 1rem;
  }

  .stats-table h3,
  .favorites-table h3 {
    font-size: 1.1rem;
  }

  .stats-table thead th {
    padding: 8px;
    font-size: 13px;
  }

  .stats-table tbody td {
    padding: 8px;
    font-size: 13px;
  }

  .stats-table tbody td:last-child {
    font-size: 16px;
  }

  .level-badge {
    font-size: 12px;
    padding: 4px 8px;
  }

  .legend {
    font-size: 12px;
    padding: 8px 12px;
  }

  .legend strong {
    font-size: 13px;
  }

  .custom-logo {
    padding: 8px;
    gap: 8px;
  }

  .custom-logo img {
    max-width: 120px;
    max-height: 40px;
  }

  .last-updated {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* =============================================
   SMALL MOBILE STYLES (480px and below)
   ============================================= */
@media (max-width: 480px) {
  .map-header {
    padding: 0.5rem;
  }

  .header-content h1 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
  }

  .header-subtitle {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
  }

  .controls-bar {
    flex-direction: row;
    gap: 0.5rem;
  }

  .search-container {
    min-width: 150px;
  }

  #county-search {
    font-size: 13px;
    padding: 8px 30px 8px 10px;
  }

  .map-container {
    height: 45vh;
    min-height: 250px;
  }

  /* Compact info section on small mobile */
  .info-section {
    padding: 1rem 0.5rem;
  }

  .stats-table,
  .favorites-table {
    padding: 0.75rem;
  }

  .stats-table h3,
  .favorites-table h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .stats-table thead th {
    padding: 6px;
    font-size: 12px;
  }

  .stats-table tbody td {
    padding: 6px;
    font-size: 12px;
  }

  .stats-table tbody td:last-child {
    font-size: 14px;
  }

  .level-badge {
    font-size: 11px;
    padding: 3px 6px;
  }

  .favorite-item {
    padding: 10px;
  }

  .favorite-name {
    font-size: 13px;
  }

  /* Hide old panels on mobile - they take up too much space */
  .stats-panel,
  .favorites-panel {
    display: none;
  }

  .icon-btn {
    padding: 6px 8px;
    min-width: 36px;
    min-height: 36px;
  }

  .icon-btn .icon {
    font-size: 14px;
  }

  /* Hide legend by default on mobile, show with toggle */
  .legend {
    display: none;
    position: fixed !important;
    bottom: 60px !important;
    right: 10px !important;
    left: 10px !important;
    max-width: calc(100% - 20px) !important;
    font-size: 11px;
    padding: 8px 10px;
    z-index: 1001;
    animation: slideUp 0.3s ease-out;
  }

  .legend.mobile-visible {
    display: block !important;
  }

  @keyframes slideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .legend-toggle {
    display: block;
  }

  .legend strong {
    font-size: 11px;
    margin-top: 4px;
    margin-bottom: 2px;
  }

  .legend span {
    width: 12px;
    height: 12px;
    margin-right: 6px;
  }

  .custom-logo {
    flex-direction: column;
    padding: 6px;
    gap: 6px;
  }

  .custom-logo img {
    max-width: 100px;
    max-height: 35px;
  }

  .last-updated {
    font-size: 10px;
    padding: 4px 6px;
  }

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

  /* Stack controls better on mobile */
  .leaflet-bottom.leaflet-left {
    bottom: 10px;
    left: 10px;
  }

  .leaflet-bottom.leaflet-right {
    bottom: 10px;
    right: 10px;
  }

  /* Make custom logo smaller on mobile */
  .custom-logo img {
    max-width: 80px !important;
    max-height: 30px !important;
  }

  .center-watermark {
    font-size: 1.5rem;
  }
}

/* =============================================
   VERY SMALL MOBILE STYLES (360px and below)
   ============================================= */
@media (max-width: 360px) {
  .header-content h1 {
    font-size: 1.1rem;
  }

  .header-subtitle {
    font-size: 0.7rem;
  }

  .map-container {
    min-height: 350px;
  }

  .custom-logo img {
    max-width: 80px;
    max-height: 30px;
  }

  .last-updated {
    font-size: 9px;
  }

  .legend {
    font-size: 10px;
    padding: 8px;
  }

  .legend strong {
    font-size: 11px;
  }

  .legend-toggle {
    font-size: 12px;
    padding: 10px 14px;
  }
}

/* =============================================
   LANDSCAPE MOBILE ORIENTATION
   ============================================= */
@media (max-height: 500px) and (orientation: landscape) {
  .map-header {
    padding: 0.5rem;
  }

  .header-content h1 {
    font-size: 1rem;
    margin-bottom: 0;
  }

  .header-subtitle {
    display: none;
  }

  .map-container {
    height: calc(100vh - 50px);
    min-height: 250px;
  }

  .legend {
    font-size: 10px;
    padding: 6px;
    line-height: 1.4;
  }

  .custom-logo img {
    max-width: 80px;
    max-height: 30px;
  }
}

/* =============================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ============================================= */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets on touch devices */
  .leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
  }

  .legend-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* =============================================
   STATISTICS PANEL
   ============================================= */
.stats-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  min-width: 180px;
  max-width: 220px;
  transition: all 0.3s ease;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.stats-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #0f3460;
  margin: 0;
}

#toggle-stats {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-content {
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.stats-panel.collapsed .stats-content {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 4px 0;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.stat-item:hover {
  background: rgba(74, 158, 255, 0.1);
}

.stat-color {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.stat-item.level-3 .stat-color {
  background: red;
}

.stat-item.level-2 .stat-color {
  background: orange;
}

.stat-item.level-1 .stat-color {
  background: yellow;
}

.stat-item.advisory .stat-color {
  background: purple;
}

.stat-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.stat-count {
  font-size: 16px;
  font-weight: 700;
  color: #0f3460;
  min-width: 30px;
  text-align: right;
}

/* =============================================
   FAVORITES PANEL
   ============================================= */
.favorites-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  min-width: 180px;
  max-width: 220px;
  max-height: 280px;
  transition: all 0.3s ease;
}

.favorites-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.favorites-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #0f3460;
  margin: 0;
}

#toggle-favorites {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.favorites-content {
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.favorites-panel.collapsed .favorites-content {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  margin: 4px 0;
  background: rgba(74, 158, 255, 0.05);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.favorite-item:hover {
  background: rgba(74, 158, 255, 0.15);
  transform: translateX(2px);
}

.favorite-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.favorite-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.remove-favorite {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.favorite-item:hover .remove-favorite {
  opacity: 1;
}

.remove-favorite:hover {
  color: #ff3b30;
}

.empty-state {
  text-align: center;
  color: #888;
  font-size: 12px;
  padding: 16px 8px;
  font-style: italic;
}

/* =============================================
   INFO SECTION (STATISTICS & FAVORITES)
   ============================================= */
.info-section {
  background: #16213e;
  padding: 1rem;
  border-top: 2px solid #0f3460;
  border-radius: 0 0 8px 8px;
}

.info-container {
  max-width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Statistics Table */
.stats-table {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stats-table h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f3460;
  margin-bottom: 1rem;
  text-align: center;
}

.stats-table table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table thead th {
  background: #0f3460;
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

.stats-table thead th:first-child {
  border-radius: 8px 0 0 0;
}

.stats-table thead th:last-child {
  border-radius: 0 8px 0 0;
  text-align: right;
}

.stats-table tbody tr {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease;
}

.stats-table tbody tr:last-child {
  border-bottom: none;
}

.stats-table tbody tr:hover {
  background: rgba(74, 158, 255, 0.1);
}

.stats-table tbody td {
  padding: 12px;
  color: #333;
}

.stats-table tbody td:last-child {
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: #0f3460;
}

.level-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  text-align: center;
}

.level-badge.level-3 {
  background: red;
}

.level-badge.level-2 {
  background: orange;
}

.level-badge.level-1 {
  background: yellow;
  color: #333;
}

.level-badge.advisory {
  background: purple;
}

/* Favorites Table */
.favorites-table {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.favorites-table h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f3460;
  margin-bottom: 1rem;
  text-align: center;
}

.favorites-content {
  max-height: 300px;
  overflow-y: auto;
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  margin: 8px 0;
  background: rgba(74, 158, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.favorite-item:hover {
  background: rgba(74, 158, 255, 0.15);
  transform: translateX(4px);
}

.favorite-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.favorite-status {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.remove-favorite {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.favorite-item:hover .remove-favorite {
  opacity: 1;
}

.remove-favorite:hover {
  color: #ff3b30;
}

.empty-state {
  text-align: center;
  color: #888;
  font-size: 14px;
  padding: 2rem 1rem;
  font-style: italic;
}

/* =============================================
   MODAL
   ============================================= */
.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: #0f3460;
  margin: 0;
}

#close-modal {
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

#close-modal:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-status {
  margin-bottom: 20px;
}

.status-badge {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  color: white;
  text-align: center;
}

.status-badge.level-0 {
  background: lightgray;
  color: #333;
}

.status-badge.level-1 {
  background: yellow;
  color: #333;
}

.status-badge.level-2 {
  background: orange;
}

.status-badge.level-3 {
  background: red;
}

.status-badge.level-4 {
  background: purple;
}

.status-badge.level-5 {
  background: black;
}

.modal-info {
  margin-bottom: 20px;
}

.modal-info p {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  background: #4a9eff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: #3a8eef;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4);
}

.action-btn:active {
  transform: translateY(0);
}

.action-btn.favorited {
  background: #ffa500;
}

/* =============================================
   SNOW EFFECT CANVAS
   ============================================= */
#snow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
  display: none;
}

#snow-canvas.active {
  display: block;
}

/* =============================================
   PULSE ANIMATION FOR RECENT CHANGES
   ============================================= */
@keyframes pulse {
  0%, 100% {
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

.county-changed {
  animation: pulse 2s ease-in-out 3;
}

/* =============================================
   PRINT STYLES
   ============================================= */
@media print {
  .map-header {
    background: white;
    color: black;
  }

  #loading-overlay,
  .legend-toggle,
  .controls-bar,
  .stats-panel,
  .favorites-panel,
  .modal {
    display: none !important;
  }

  .legend {
    display: block !important;
    background: white;
    border: 1px solid #ccc;
  }

  body {
    background: white;
  }
}
