/* County Map Page Styles */

/* Main container */
.county-map-wrapper {
  position: relative;
  width: 100%;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.county-map-container {
  width: 100%;
  height: 100%;
}

/* Stats Panel */
.county-stats-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
  background: var(--card-bg, rgb(30 30 35 / 95%));
  backdrop-filter: blur(12px);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
  border: 1px solid var(--border-color, rgb(255 255 255 / 10%));
  z-index: 100;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color, rgb(255 255 255 / 10%));
}

.stats-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #fff);
  display: flex;
  align-items: center;
}

.stats-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.stats-toggle-btn:hover {
  background: var(--hover-bg, rgb(255 255 255 / 10%));
  color: var(--text-primary, #fff);
}

.stats-toggle-btn i {
  transition: transform 0.3s ease;
}

.stats-panel--collapsed .stats-toggle-btn i {
  transform: rotate(180deg);
}

.stats-content {
  padding: 1.25rem;
  max-height: 500px;
  overflow-y: auto;
}

.stats-panel--collapsed .stats-content {
  display: none;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface-elevated, rgb(255 255 255 / 5%));
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 20%);
}

.stat-card--primary {
  background: linear-gradient(
    135deg,
    rgb(16 185 129 / 20%),
    rgb(16 185 129 / 10%)
  );
  border: 1px solid rgb(16 185 129 / 30%);
}

.stat-card--secondary {
  background: linear-gradient(
    135deg,
    rgb(99 102 241 / 20%),
    rgb(99 102 241 / 10%)
  );
  border: 1px solid rgb(99 102 241 / 30%);
}

.stat-card--accent {
  background: linear-gradient(
    135deg,
    rgb(245 158 11 / 20%),
    rgb(245 158 11 / 10%)
  );
  border: 1px solid rgb(245 158 11 / 30%);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cache info / recalculate */
.cache-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--surface-elevated, rgb(255 255 255 / 3%));
  border-radius: 8px;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-secondary, rgb(255 255 255 / 50%));
  flex: 1;
}

#recalculate-btn {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
}

.recalculate-prompt {
  background: linear-gradient(
    135deg,
    rgb(59 130 246 / 20%),
    rgb(59 130 246 / 10%)
  );
  border: 1px solid rgb(59 130 246 / 30%);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.recalculate-prompt p {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary, #fff);
}

/* Legend */
.map-legend {
  background: var(--surface-elevated, rgb(255 255 255 / 3%));
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

/* State-by-State Stats Section */
.state-stats-section {
  margin-top: 1rem;
  border-top: 1px solid rgb(255 255 255 / 10%);
  padding-top: 1rem;
}

.state-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface-elevated, rgb(255 255 255 / 5%));
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  color: var(--text-primary, #fff);
}

.state-stats-header:hover {
  background: var(--hover-bg, rgb(255 255 255 / 10%));
}

.state-stats-title {
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.state-stats-chevron {
  transition: transform 0.3s ease;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
}

.state-stats-content {
  margin-top: 0.75rem;
}

.state-stats-filter {
  margin-bottom: 0.75rem;
}

.state-stats-filter .form-select {
  background-color: var(--surface-elevated, rgb(255 255 255 / 5%));
  border: 1px solid rgb(255 255 255 / 10%);
  color: var(--text-primary, #fff);
  font-size: 0.75rem;
}

.state-stats-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.state-stat-item {
  background: var(--surface-elevated, rgb(255 255 255 / 3%));
  border: 1px solid rgb(255 255 255 / 5%);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.state-stat-item:hover {
  background: var(--hover-bg, rgb(255 255 255 / 8%));
  border-color: rgb(255 255 255 / 10%);
}

.state-stat-item--complete {
  border-color: rgb(16 185 129 / 30%);
  background: linear-gradient(
    135deg,
    rgb(16 185 129 / 10%),
    rgb(16 185 129 / 5%)
  );
}

.state-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.state-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
}

.state-coverage {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-secondary, rgb(255 255 255 / 50%));
}

.state-coverage--visited {
  color: #10b981;
}

.state-stat-details {
  margin-bottom: 0.5rem;
}

.state-counties {
  font-size: 0.75rem;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
}

.state-progress-bar {
  height: 4px;
  background: rgb(255 255 255 / 10%);
  border-radius: 2px;
  overflow: hidden;
}

.state-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.state-date {
  font-size: 0.7rem;
  color: var(--text-secondary, rgb(255 255 255 / 50%));
  margin-top: 0.5rem;
}

.legend-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
  margin: 0 0 0.75rem;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.legend-color--visited {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 0 8px rgb(16 185 129 / 50%);
}

.legend-color--unvisited {
  background: rgb(255 255 255 / 5%);
  border: 1px solid rgb(255 255 255 / 20%);
}

.legend-color--state-border {
  background: transparent;
  border: 2px solid rgb(255 255 255 / 40%);
}

.legend-label {
  font-size: 0.875rem;
  color: var(--text-primary, #fff);
}

/* County Tooltip */
.county-tooltip {
  position: absolute;
  background: var(--card-bg, rgb(30 30 35 / 95%));
  backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 30%);
  border: 1px solid var(--border-color, rgb(255 255 255 / 10%));
  pointer-events: none;
  z-index: 200;
  max-width: 250px;
  transform: translate(-50%, -100%);
  margin-top: -10px;
}

.tooltip-county-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
  margin-bottom: 0.25rem;
}

.tooltip-state-name {
  font-size: 0.875rem;
  color: var(--text-secondary, rgb(255 255 255 / 60%));
  margin-bottom: 0.5rem;
}

.tooltip-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
}

.tooltip-status--visited {
  background: rgb(16 185 129 / 20%);
  color: #10b981;
  border: 1px solid rgb(16 185 129 / 30%);
}

.tooltip-status--unvisited {
  background: rgb(255 255 255 / 5%);
  color: var(--text-secondary, rgb(255 255 255 / 60%));
  border: 1px solid rgb(255 255 255 / 10%);
}

/* Tooltip dates */
.tooltip-dates {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgb(255 255 255 / 10%);
}

.tooltip-date {
  font-size: 0.75rem;
  color: var(--text-secondary, rgb(255 255 255 / 70%));
  margin-bottom: 0.125rem;
}

.tooltip-date .date-label {
  color: var(--text-secondary, rgb(255 255 255 / 50%));
  margin-right: 0.25rem;
}

/* Map Loading Overlay - uses global loading styles from loading-styles.css */
.map-loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-primary, #121212);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

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

/* Mobile Responsive */
@media (width <= 768px) {
  .county-stats-panel {
    inset: auto 1rem 1rem;
    width: auto;
    max-height: 50vh;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stats-content {
    max-height: 300px;
  }

  .cache-info {
    flex-direction: column;
    text-align: center;
  }

  .last-updated {
    margin-bottom: 0.5rem;
  }
}

/* Light mode adjustments */
[data-bs-theme="light"] .county-stats-panel,
.light-mode .county-stats-panel {
  background: rgb(255 255 255 / 95%);
  border-color: rgb(0 0 0 / 10%);
  box-shadow: 0 8px 32px rgb(0 0 0 / 10%);
}

[data-bs-theme="light"] .stats-title,
.light-mode .stats-title,
[data-bs-theme="light"] .stat-value,
.light-mode .stat-value,
[data-bs-theme="light"] .legend-label,
.light-mode .legend-label {
  color: #1f2937;
}

[data-bs-theme="light"] .stat-label,
.light-mode .stat-label,
[data-bs-theme="light"] .legend-title,
.light-mode .legend-title {
  color: #6b7280;
}

[data-bs-theme="light"] .county-tooltip,
.light-mode .county-tooltip {
  background: rgb(255 255 255 / 95%);
  border-color: rgb(0 0 0 / 10%);
}

[data-bs-theme="light"] .tooltip-county-name,
.light-mode .tooltip-county-name {
  color: #1f2937;
}

[data-bs-theme="light"] .tooltip-state-name,
.light-mode .tooltip-state-name {
  color: #6b7280;
}

[data-bs-theme="light"] .map-loading-overlay,
.light-mode .map-loading-overlay {
  background: #f9fafb;
}

[data-bs-theme="light"] .loading-text,
.light-mode .loading-text {
  color: #1f2937;
}

[data-bs-theme="light"] .last-updated,
.light-mode .last-updated {
  color: #6b7280;
}

[data-bs-theme="light"] .recalculate-prompt p,
.light-mode .recalculate-prompt p {
  color: #1f2937;
}
