/* Heat Map Component Styles */

.heat-map-container {
  position: relative;
  width: 100%;
  height: 500px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.heat-map-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

.heat-map-svg:active {
  cursor: grabbing;
}

/* Geographic Region Styles */
.state,
.district {
  transition: all 0.3s ease;
  stroke-linejoin: round;
  stroke-linecap: round;
  cursor: pointer;
}

.state:hover,
.district:hover {
  stroke-width: 3px !important;
  stroke: var(--accent-primary) !important;
  filter: brightness(1.15) saturate(1.3)
    drop-shadow(0 2px 8px rgba(59, 130, 246, 0.3));
  transform: scale(1.02);
  transform-origin: center;
  z-index: 10;
}

/* Boundary Highlighting */
.boundary-highlight {
  stroke: var(--accent-primary) !important;
  stroke-width: 2px !important;
  stroke-dasharray: 5, 5;
  animation: dashOffset 1s linear infinite;
}

@keyframes dashOffset {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: 10;
  }
}

/* Adjacent Region Highlighting */
.adjacent-highlight {
  stroke: var(--warning) !important;
  stroke-width: 2px !important;
  opacity: 0.8;
}

/* Geographic Level Transition */
.heat-map-svg.transitioning {
  pointer-events: none;
}

.heat-map-svg.transitioning .state,
.heat-map-svg.transitioning .district {
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tooltip Styles */
.heat-map-tooltip {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 1000;
  max-width: 200px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
}

.heat-map-tooltip strong {
  color: var(--accent-primary);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

/* Legend Styles */
.legend-group text {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  fill: var(--text-primary);
}

.legend-group rect {
  stroke: var(--border-color);
  stroke-width: 1px;
}

/* Heat Map Header */
.heat-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.heat-map-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.heat-map-title h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.heat-map-title i {
  color: var(--accent-primary);
  font-size: 1.375rem;
}

.heat-map-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* Geographic Level Toggle */
.geographic-level-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.toggle-buttons {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border-color);
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
}

.toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.toggle-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.toggle-btn.active:hover {
  background: var(--accent-secondary);
  color: white;
}

.toggle-btn i {
  font-size: 0.75rem;
}

/* Transition Loading State */
.toggle-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.toggle-btn.loading i {
  animation: spin 1s linear infinite;
}

/* Control Buttons */
.heat-map-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.heat-map-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.heat-map-btn.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* Data Selector */
.data-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.data-selector label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.data-selector select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.data-selector select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Heat Map Stats */
.heat-map-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  padding: 1rem 2rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.heat-map-stat {
  text-align: center;
}

.heat-map-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.25rem;
}

.heat-map-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Loading State */
.heat-map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.heat-map-loading i {
  margin-right: 0.5rem;
  animation: spin 1s linear infinite;
}

/* Error State */
.heat-map-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg-secondary);
  color: var(--error);
  text-align: center;
  padding: 2rem;
}

.heat-map-error i {
  font-size: 2rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.heat-map-error h4 {
  margin-bottom: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.heat-map-error p {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.zoom-btn:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

.zoom-btn:active {
  transform: scale(0.95);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .heat-map-container {
    height: 400px;
  }

  .heat-map-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 1rem;
  }

  .heat-map-controls {
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
  }

  .geographic-level-toggle {
    justify-content: center;
    width: 100%;
  }

  .toggle-buttons {
    flex: 1;
    max-width: 300px;
  }

  .toggle-btn {
    flex: 1;
    justify-content: center;
  }

  .heat-map-stats {
    grid-template-columns: repeat(2, 1fr);
    padding: 1rem;
  }

  .heat-map-tooltip {
    font-size: 12px;
    padding: 8px;
    max-width: 150px;
  }

  .zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    flex-direction: row;
  }

  .zoom-btn {
    width: 35px;
    height: 35px;
  }

  /* Touch-friendly hover states */
  .state:hover {
    stroke-width: 3px !important;
  }
}

@media (max-width: 480px) {
  .heat-map-container {
    height: 300px;
  }

  .heat-map-header {
    padding: 0.75rem;
  }

  .heat-map-title h3 {
    font-size: 1rem;
  }

  .heat-map-controls {
    flex-direction: column;
    width: 100%;
  }

  .heat-map-btn {
    width: 100%;
    justify-content: center;
  }

  .heat-map-stats {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .data-selector {
    width: 100%;
    justify-content: space-between;
  }

  .data-selector select {
    flex: 1;
    margin-left: 0.5rem;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .state {
    stroke-width: 2px;
  }

  .heat-map-tooltip {
    border-width: 2px;
  }

  .heat-map-btn {
    border-width: 2px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .state,
  .heat-map-btn,
  .zoom-btn {
    transition: none;
  }

  .heat-map-loading i {
    animation: none;
  }
}

/* Dark Theme Adjustments */
[data-theme="dark"] .heat-map-tooltip {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(15px);
}

[data-theme="dark"] .legend-group text {
  fill: var(--text-primary);
}

/* Focus Styles for Accessibility */
.heat-map-btn:focus,
.data-selector select:focus,
.zoom-btn:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Region Details Panel */
.region-details-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.region-details-panel:not(.hidden) {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.panel-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.panel-close-btn:hover {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

.panel-content {
  padding: 1.5rem;
}

.region-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.region-stat {
  text-align: center;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.region-stat .stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}

.region-stat .stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.region-breakdown {
  margin-top: 2rem;
}

.region-breakdown h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.breakdown-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 100px;
}

.breakdown-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.breakdown-fill.verified {
  background: var(--success);
}

.breakdown-fill.basic {
  background: var(--accent-secondary);
}

.breakdown-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 50px;
  text-align: right;
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 2rem;
  z-index: 100;
}

.breadcrumb-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.breadcrumb-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.breadcrumb-item.active {
  background: var(--accent-primary);
  color: white;
  cursor: default;
}

.breadcrumb-item.active:hover {
  background: var(--accent-primary);
  color: white;
}

.breadcrumb-separator {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Access Notice */
.access-notice {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.access-notice.basic-access {
  background: linear-gradient(90deg, #fef3c7, #fffbeb);
  border-left: 4px solid #f59e0b;
}

.access-notice.pro-access {
  background: linear-gradient(90deg, #dbeafe, #eff6ff);
  border-left: 4px solid #3b82f6;
}

.access-notice.admin-access {
  background: linear-gradient(90deg, #d1fae5, #ecfdf5);
  border-left: 4px solid #10b981;
}

.notice-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notice-content i {
  font-size: 1.25rem;
  opacity: 0.8;
}

.access-notice.basic-access .notice-content i {
  color: #f59e0b;
}

.access-notice.pro-access .notice-content i {
  color: #3b82f6;
}

.access-notice.admin-access .notice-content i {
  color: #10b981;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.toast-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-success .toast-content i {
  color: var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-error .toast-content i {
  color: var(--error);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-warning .toast-content i {
  color: var(--warning);
}

.toast-info {
  border-left: 4px solid var(--accent-primary);
}

.toast-info .toast-content i {
  color: var(--accent-primary);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-spinner {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-xl);
  min-width: 200px;
}

.loading-spinner i {
  font-size: 2rem;
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.loading-spinner p {
  margin: 0;
  color: var(--text-primary);
  font-weight: 500;
}

/* Animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .region-details-panel {
    width: 100%;
    height: 100vh;
  }

  .breadcrumb-nav {
    padding: 0.5rem 1rem;
  }

  .breadcrumb-container {
    gap: 0.25rem;
  }

  .breadcrumb-item {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }

  .breadcrumb-item i {
    font-size: 0.625rem;
  }

  .region-stat-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .breakdown-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .breakdown-label {
    min-width: auto;
  }

  .breakdown-value {
    text-align: left;
    min-width: auto;
  }

  .toast-container {
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .access-notice {
    padding: 0.75rem 1rem;
  }

  .notice-content {
    gap: 0.5rem;
  }

  .notice-content i {
    font-size: 1rem;
  }

  .panel-header {
    padding: 1rem;
  }

  .panel-content {
    padding: 1rem;
  }
}

/* Print Styles */
@media print {
  .heat-map-container {
    height: auto;
    box-shadow: none;
    border: 1px solid #000;
  }

  .zoom-controls,
  .heat-map-controls {
    display: none;
  }

  .heat-map-tooltip {
    display: none;
  }

  .region-details-panel,
  .loading-overlay,
  .toast-container,
  .breadcrumb-nav {
    display: none;
  }
}
