/**
 * @file
 * Styles for Election Map Block.
 */

.election-map-block {
  max-width: 1400px;
}

.election-map-block .map-container {
  min-height: 400px;
}

.election-map-block .map-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.election-map-block #bangladesh-map-svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Hide constituency labels in SVG */
.election-map-block svg .constituency-label,
.election-map-block svg text.constituency-label {
  display: none !important;
}

/* Hide dark city marker elements */
.election-map-block svg polygon:not([data-name])[fill="#1f3f3f"],
.election-map-block svg path:not([data-name])[fill="#1f3f3f"] {
  display: none !important;
}

/* SVG constituency styling - target elements with data-name attribute */
.election-map-block svg [data-name]:not([data-name^="layer_"]),
.election-map-block object svg [data-name]:not([data-name^="layer_"]),
.election-map-block embed svg [data-name]:not([data-name^="layer_"]) {
  fill: #e2e8f0 !important;
  stroke: #334155 !important;
  stroke-width: 1 !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
}

.election-map-block svg [data-name]:not([data-name^="layer_"]):hover,
.election-map-block svg [data-name]:not([data-name^="layer_"]):focus,
.election-map-block object svg [data-name]:not([data-name^="layer_"]):hover,
.election-map-block object svg [data-name]:not([data-name^="layer_"]):focus {
  fill: #bfdbfe !important;
  stroke: #0284c7 !important;
  stroke-width: 1.5 !important;
  outline: none;
}

/* Alliance-based constituency colors */
/* BNP Alliance - Purple */
.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="bnp"],
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="bnp"] {
  fill: #7c3aed !important;
  opacity: 0.7;
}

.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="bnp"]:hover,
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="bnp"]:hover {
  opacity: 0.9;
}

/* Jamaat Alliance - Orange-Red */
.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="jamaat"],
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="jamaat"] {
  fill: #ff5722 !important;
  opacity: 0.7;
}

.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="jamaat"]:hover,
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="jamaat"]:hover {
  opacity: 0.9;
}

/* Others - Cyan */
.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="others"],
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="others"] {
  fill: #0097a7 !important;
  opacity: 0.7;
}

.election-map-block
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="others"]:hover,
.election-map-block
  object
  svg
  [data-name]:not([data-name^="layer_"])[data-alliance="others"]:hover {
  opacity: 0.9;
}

/* Popover/Tooltip styles - added to body so no parent selector needed */
.constituency-popover {
  position: fixed;
  z-index: 9999;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  min-width: 250px;
  max-width: 350px;
  pointer-events: none;
  animation: fadeInPopover 0.2s ease-in;
  /* Ensure popover stays within viewport */
  max-width: calc(100vw - 20px);
  word-wrap: break-word;
}

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

.constituency-popover .popover-header {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.constituency-popover .popover-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.constituency-popover .popover-location {
  font-size: 12px;
  color: #6b7280;
}

.constituency-popover .popover-body {
  margin-top: 8px;
}

.constituency-popover .popover-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}

.constituency-popover .popover-label {
  color: #6b7280;
  font-weight: 500;
}

.constituency-popover .popover-value {
  color: #1f2937;
  font-weight: 600;
}

.constituency-popover .winner-info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.constituency-popover .winner-label {
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.constituency-popover .winner-name {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 2px;
}

.constituency-popover .winner-party {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.constituency-popover .winner-votes {
  font-size: 13px;
  color: #10b981;
  font-weight: 600;
}

/* Division summary hover effects */
.election-map-block [data-division]:hover {
  background-color: #f8f9fa;
  transition: background-color 0.2s ease;
}

/* Map legend styling */
.election-map-block .map-container + div {
  padding: 1rem;
  background-color: white;
  border-radius: 4px;
}

/* Alliance tab styling */
.election-map-block .alliance-tabs-wrapper {
  position: relative;
}

.election-map-block .alliance-tab {
  position: relative;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  background-color: transparent;
  border: none;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.election-map-block .alliance-tab:hover {
  background-color: #e5e7eb;
  color: #374151;
}

.election-map-block .alliance-tab[aria-selected="true"] {
  background-color: #2563eb;
  color: white;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.election-map-block .alliance-tab[aria-selected="true"]:hover {
  background-color: #1d4ed8;
}

/* Animated tab indicator */
.election-map-block .tab-indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background-color: #2563eb;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 3px 3px 0 0;
}

/* Alliance count display colors */
.election-map-block .count-display {
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 700;
}

.election-map-block .count-display[data-alliance="bnp"] {
  background-color: #ede9fe;
  color: #7c3aed;
}

.election-map-block .count-display[data-alliance="jamaat"] {
  background-color: #ffebe6;
  color: #ff5722;
}

.election-map-block .count-display[data-alliance="others"] {
  background-color: #e0f2f1;
  color: #0097a7;
}

/* Recent Results Section */
.election-map-block .recent-results-scroll {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.election-map-block .recent-results-scroll::-webkit-scrollbar {
  width: 6px;
}

.election-map-block .recent-results-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.election-map-block .recent-results-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.election-map-block .recent-results-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.election-map-block .result-card {
  position: relative;
  text-decoration: none;
  color: inherit;
}

.election-map-block .result-card:hover {
  text-decoration: none;
}

.election-map-block .result-card[data-alliance="bnp"] {
  border-left: 3px solid #7c3aed;
}

.election-map-block .result-card[data-alliance="jamaat"] {
  border-left: 3px solid #ff5722;
}

.election-map-block .result-card[data-alliance="others"] {
  border-left: 3px solid #0097a7;
}

.election-map-block .alliance-badge {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
}

.election-map-block .alliance-badge[data-alliance="bnp"] {
  background-color: #ede9fe;
  color: #6d28d9;
}

.election-map-block .alliance-badge[data-alliance="jamaat"] {
  background-color: #ffebe6;
  color: #d84315;
}

.election-map-block .alliance-badge[data-alliance="others"] {
  background-color: #e0f2f1;
  color: #00695c;
}

/* Statistics cards */
.election-map-block .border {
  transition: box-shadow 0.2s ease;
}

.election-map-block .border:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .election-map-block {
    overflow-x: hidden;
  }

  .election-map-block .map-container {
    min-height: 300px;
    overflow: hidden;
  }

  .election-map-block h3 {
    font-size: 1.25rem;
  }

  .constituency-popover {
    min-width: 200px;
    max-width: calc(100vw - 20px);
    font-size: 12px;
    padding: 10px 12px;
  }

  /* Force popover content to wrap properly */
  .constituency-popover .popover-title {
    font-size: 14px;
    word-wrap: break-word;
  }

  .constituency-popover .popover-location {
    font-size: 11px;
  }
}
