/**
 * @file
 * Styles for Know Your MP map.
 */
:root {
  --bg-panel: #f2f2f2;
  --text-main: #000000;
  --text-muted: #333333;
  --accent: #2563eb;
  --color-bnp: hsl(280, 80%, 45%);
  --color-jamaat: hsl(30, 90%, 45%);
  --color-ncp: hsl(200, 85%, 45%);
  --color-others: hsl(135, 60%, 40%); /* Deeper Forest Green */
}

body {
  font-family: inherit, serif;
  margin: 0;
  padding: 30px;
  color: var(--text-main);
}

.masthead {
  text-align: center;
  padding: 40px 20px 20px 20px;
}

.masthead h1 {
  margin: 0;
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.mission-container {
  max-width: 900px;
  margin: 0 auto 40px auto;
  background-color: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  padding: 30px 40px;
  text-align: center;
  color: #444;
}

.mission-container .lead-questions {
  display: block;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.5rem;
  font-weight: bold;
  color: #111;
  margin-bottom: 15px;
  line-height: 1.3;
}

.mission-container .mission-body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
}

.filters-container {
  max-width: 1400px;
  margin: 0 auto 30px auto;
  padding: 20px 30px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.filter-group label {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select {
  font-family: inherit;
  padding: 12px 16px;
  font-size: 15px;
  color: #1e293b;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748B%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat, repeat;
  background-position:
    right 0.7em top 50%,
    0 0;
  background-size:
    0.65em auto,
    100%;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-group select:hover {
  border-color: #94a3b8;
}

.filter-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-group select:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  background-image: none;
}

.global-reset-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  height: 48px;
  width: 48px;
}

.global-reset-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

@media (max-width: 768px) {
  .filters-container {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    min-width: 100%;
  }
  .global-reset-btn {
    width: fit-content;
    margin: 0 auto;
  }
}

.layout-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  align-items: stretch;
}

.map-section {
  flex: 2;
  background: #fff;
  padding: 20px;
  position: relative;
  overflow: hidden;
  min-height: 600px;
}

/* Floating Legend Styles */
.floating-legend {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  width: 240px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.legend-title {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #111;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition:
    background 0.2s,
    transform 0.1s;
}
.legend-item:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.02);
}
.legend-item.active {
  background: rgba(0, 0, 0, 0.1);
  outline: 1px solid rgba(0, 0, 0, 0.2);
}

.color-box {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  flex-shrink: 0;
}

.intensity-section {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: 10px;
  margin-bottom: 10px;
}

.intensity-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #f8f9fa, #445566);
  margin-bottom: 5px;
}

.intensity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: bold;
  color: #666;
  text-transform: uppercase;
}

/* Reset Button Styling */
.reset-filter-btn {
  display: none;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 8px 0 0 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
  text-decoration: none;
}
.reset-filter-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

.map-footer-context {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 12px;
  font-style: italic;
  color: #777;
  pointer-events: none;
}

.sidebar-section {
  flex: 1;
  min-width: 380px;
  max-width: 450px;
  background: #eaeaea;
  border-left: 1px solid #eee;
  padding: 40px;
  overflow-y: auto;
  max-height: 850px;
}

/* Region Dimming */
.map-region {
  transition:
    stroke 0.15s,
    fill 0.25s,
    opacity 0.3s,
    filter 0.3s;
  cursor: pointer;
}
.map-region.dimmed {
  opacity: 0.15;
  filter: grayscale(0.6) blur(0.5px);
}

.map-region:hover {
  stroke: #000 !important;
  stroke-width: 1.5 !important;
  filter: brightness(0.9);
}
.map-region.active {
  stroke: #000 !important;
  stroke-width: 2 !important;
  filter: brightness(0.85);
}

#tooltip {
  position: absolute;
  background: #000;
  color: white;
  padding: 5px 12px;
  pointer-events: none;
  display: none;
  z-index: 1000;
  font-size: 16px;
  font-weight: bold;
  transform: translate(-50%, -100%);
  margin-top: -12px;
}

.mp-profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 30px;
}
.mp-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border: 2px solid #000;
  background-color: #fff;
  margin-bottom: 20px;
}
.mp-name {
  font-size: 28px;
  font-weight: bold;
  margin: 0 0 10px 0;
}
.badge {
  display: inline-block;
  background: #fff;
  color: var(--accent);
  padding: 5px 15px;
  border: 1px solid var(--accent);
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}
.party-name {
  font-size: 18px;
  font-weight: bold;
}
.party-bnp {
  color: var(--color-bnp);
}
.party-jamaat {
  color: var(--color-jamaat);
}
.party-ncp {
  color: var(--color-ncp);
}
.party-others {
  color: var(--color-others);
}

.details-section {
  background: #fff;
  border: 1px solid #ccc;
  padding: 15px;
}
.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  gap: 15px;
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-label {
  font-weight: bold;
  width: 50%;
  padding-right: 10px;
}
.detail-value {
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.special-status {
  color: #800;
  font-weight: bold;
  font-size: 18px;
  padding: 15px;
  background: #fff;
  border: 1px solid #800;
  text-align: center;
  margin: 20px 0;
}

.sidebar-empty {
  text-align: center;
  color: #666;
  margin-top: 100px;
}

.sidebar-empty .instruction {
  font-size: 1rem;
  margin-bottom: 30px;
  opacity: 0.8;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

.sidebar-empty .quote {
  font-size: 1.8rem;
  font-weight: bold;
  color: #222;
  line-height: 1.3;
}

.data-source-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: bold;
  color: #666;
  margin-bottom: 8px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.close-sidebar-btn {
  display: none;
  position: absolute;
  top: 15px;
  right: 20px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 28px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2010;
  color: #333;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.close-sidebar-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Safety guard: never show mobile close control on desktop widths. */
@media (min-width: 901px) {
  .close-sidebar-btn {
    display: none !important;
  }
}

.sidebar-section::-webkit-scrollbar {
  width: 8px;
}
.sidebar-section::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-section::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.sidebar-section::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile adjustments */
@media (max-width: 900px) {
  body {
    padding: 0;
    margin: 0;
    overflow-x: hidden;
  }
  .layout-container {
    flex-direction: column;
    overflow: visible !important;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
  .sidebar-section {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    transform: translateX(100%);
    width: 100% !important;
    max-width: 400px !important;
    height: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 60px 20px 20px 20px !important;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    z-index: 9999 !important;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2) !important;
    border: none !important;
    overflow-x: hidden !important;
  }
  .sidebar-section.mobile-open {
    transform: translateX(0) !important;
  }
  .close-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
  }
  .map-section {
    min-height: unset;
    height: 500px;
    padding: 10px;
    border: none;
  }
  .masthead {
    padding: 30px 15px 15px 15px;
  }
  .masthead h1 {
    font-size: 2.2rem;
  }
}

@media (max-width: 768px) {
  .floating-legend {
    position: relative;
    top: unset;
    right: unset;
    margin: 10px auto;
    width: 100%;
    max-width: 400px;
    background: var(--bg-panel);
    border: 1px solid #ccc;
    box-shadow: none;
  }
  .map-footer-context {
    position: relative;
    bottom: unset;
    left: unset;
    text-align: center;
    margin-top: 5px;
  }
  .reset-filter-btn {
    padding: 10px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }
}
