.state-detail-page {
  width: 100%;
}

.state-detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 1rem;
  color: #718096;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: #2c5282;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.state-detail-header {
  background: white;
  border-radius: 0.75rem;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #2c5282;
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: color 0.2s ease;
}

.back-link:hover {
  color: #2a4e7c;
}

.state-title-section {
  margin-bottom: 2rem;
}

.state-title-section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}

.state-title-section p {
  color: #666;
  font-size: 1.125rem;
}

.state-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  padding: 2rem 0;
  border-top: 2px solid #f1f5f9;
  margin-top: 1rem;
}

.summary-stat {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.summary-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06d6a0, #f59e0b);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.summary-stat:hover::before {
  transform: translateX(0);
}

.summary-stat:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border-color: #cbd5e1;
}

.stat-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 2px solid #f1f5f9;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
  transition: all 0.3s ease;
  line-height: 0; /* prevent inline gap around SVG */
}
/* Ensure nested SVGs (Lucide) size and align consistently */
.stat-icon svg {
  width: 1.75rem;
  height: 1.75rem;
  vertical-align: middle;
  display: block;
}

.summary-stat:hover .stat-icon {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #3b82f6;
  color: #3b82f6;
  transform: scale(1.05);
}
/* Text block next to icon should vertically center to icon height */
.summary-stat > div {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.summary-stat > div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 64px;
  justify-content: center;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.1;
  letter-spacing: -0.025em;
  transition: color 0.3s ease;
}

.summary-stat:hover .stat-value {
  color: #0f172a;
}

.stat-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.3s ease;
}

.summary-stat:hover .stat-label {
  color: #475569;
}

.utilization-high {
  color: #059669 !important;
  font-weight: 800 !important;
}

.utilization-medium {
  color: #d97706 !important;
  font-weight: 800 !important;
}

.utilization-low {
  color: #dc2626 !important;
  font-weight: 800 !important;
}

.state-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e2e8f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.state-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 1rem;
  font-weight: 500;
  color: #718096;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #2c5282;
  background: #f7fafc;
}

.tab-btn.active {
  color: #2c5282;
  border-bottom-color: #2c5282;
}

.state-content {
  min-height: 400px;
}

.overview-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

.chart-container {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1rem;
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.financial-breakdown {
  background: white;
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.financial-breakdown h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1.5rem;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: #f7fafc;
  border-radius: 0.5rem;
}

.breakdown-label {
  font-size: 0.875rem;
  color: #718096;
}

.breakdown-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
}

.mps-section {
  background: white;
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mps-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1.5rem;
}

.mps-table {
  overflow-x: auto;
}

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

.mps-table th {
  background: #f7fafc;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid #e2e8f0;
}

.mps-table td {
  padding: 1rem;
  border-bottom: 1px solid #f7fafc;
}

.mp-link {
  color: #2c5282;
  text-decoration: none;
  font-weight: 500;
}

.mp-link:hover {
  text-decoration: underline;
}

.utilization-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.utilization-badge.utilization-high {
  background: #c6f6d5;
  color: #22543d;
}

.utilization-badge.utilization-medium {
  background: #fed7aa;
  color: #c05621;
}

.utilization-badge.utilization-low {
  background: #feb2b2;
  color: #c53030;
}

.constituencies-section,
.projects-section {
  background: white;
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.constituencies-section h3,
.projects-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 1.5rem;
}

.coming-soon {
  text-align: center;
  padding: 3rem;
  background: #f7fafc;
  border-radius: 0.5rem;
  color: #718096;
}

.coming-soon p {
  margin: 0.5rem 0;
}

.loading,
.no-data {
  text-align: center;
  padding: 2rem;
  color: #718096;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .mobile-summary-expanded,
  .card-content {
    animation: none;
  }
  
  .mobile-mp-card:hover {
    transform: none;
  }
  
  .summary-card-header:active,
  .card-header:active {
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mobile-summary-card,
  .mobile-card,
  .mobile-mp-card {
    border: 2px solid;
  }
  
  .summary-card-header,
  .card-header {
    border-bottom: 2px solid;
  }
}

/* Mobile-First Responsive Design */

/* Mobile Collapsible Cards */
.mobile-summary-card,
.mobile-card {
  background: white;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.summary-card-header,
.card-header {
  width: 100%;
  padding: 1rem 1.5rem;
  background: white;
  border: none;
  border-bottom: 1px solid #f7fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  transition: all 0.2s ease;
  text-align: left;
  min-height: 56px; /* Minimum touch target */
}

.summary-card-header:hover,
.card-header:hover {
  background: #f7fafc;
}

.summary-card-header:active,
.card-header:active {
  background: #e2e8f0;
  transform: translateY(1px);
}

.mobile-summary-expanded {
  padding: 1.5rem;
  animation: slideDown 0.3s ease-out;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  /* Arrange summary stats side-by-side on mobile */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.mobile-summary-expanded .summary-stat {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  /* Use grid gap instead of bottom margin */
  margin: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.mobile-summary-expanded .summary-stat:last-child {
  margin-bottom: 0;
}

.mobile-summary-expanded .stat-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.mobile-summary-expanded .stat-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.mobile-summary-expanded .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
}

.mobile-summary-expanded .stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-content {
  padding: 1.5rem;
  animation: slideDown 0.3s ease-out;
}

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

/* Mobile Overview Layout */
.mobile-overview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mobile-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Mobile MP Cards */
.mobile-mp-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mobile-mp-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #f7fafc;
  transition: all 0.2s ease;
}

.mobile-mp-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.mp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f7fafc;
}

.mp-primary-info {
  flex: 1;
}

.mp-name-link {
  text-decoration: none;
  color: inherit;
}

.mp-name-link h4 {
  margin: 0 0 0.25rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #2c5282;
  transition: color 0.2s ease;
}

.mp-name-link:hover h4 {
  color: #2a4e7c;
}

.mp-constituency {
  margin: 0;
  font-size: 0.875rem;
  color: #718096;
}

.mp-card-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.mp-detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.75rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.detail-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a1a1a;
}

/* Swipe Navigation */
.swipe-indicator {
  padding: 0.5rem;
  text-align: center;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
}

.swipe-indicator small {
  color: #718096;
  font-size: 0.75rem;
}

/* Touch Optimization */
.state-tabs {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Improved Touch Targets */
.tab-btn,
.summary-card-header,
.card-header,
.mp-name-link {
  min-height: 44px;
  min-width: 44px;
}

/* Mobile Responsive Breakpoints */
@media (max-width: 480px) {
  .state-detail-header {
    padding: 1rem;
  }

  .state-title-section h1 {
    font-size: 1.75rem;
  }

  .tab-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }

  .mp-card-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .state-detail-header {
    padding: 1.5rem;
  }

  .state-title-section h1 {
    font-size: 2rem;
  }

  .state-summary-stats {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem 0;
  }

  /* Ensure expanded mobile summary shows two columns */
  .state-summary-stats.mobile-summary-expanded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-stat {
    padding: 1rem;
    gap: 1rem;
  }
  
  .stat-icon {
    width: 48px;
    height: 48px;
  }
  .stat-icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }

  .state-tabs {
    gap: 0;
    position: relative;
  }

  .tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .mps-table {
    font-size: 0.875rem;
  }

  .mps-table th,
  .mps-table td {
    padding: 0.5rem;
  }

  /* Hide desktop table on mobile */
  .mps-table {
    display: none;
  }

  .mobile-mp-list {
    display: flex;
  }
}

/* Remove nested card look on mobile for Constituencies and Projects sections */
@media (max-width: 768px) {
  .constituencies-section,
  .projects-section {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }

  /* Also flatten inner project wrappers to avoid card-in-card inside Projects tab */
  .state-detail-page .projects-section .project-listing,
  .state-detail-page .projects-section .project-filters {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
}

/* Sortable headers for MP table */
.mps-table .sortable-header {
  background: #f7fafc !important;
  border-bottom: 2px solid #e2e8f0 !important;
  position: relative;
  transition: background-color 0.2s ease;
}

.mps-table .sortable-header:hover {
  background: #edf2f7 !important;
}

.mps-table .sortable-header.active {
  background: #e2e8f0 !important;
  color: #2c5282;
  font-weight: 700;
}

@media (min-width: 769px) {
  /* Hide mobile components on desktop */
  .mobile-summary-card,
  .mobile-overview,
  .mobile-mp-list,
  .swipe-indicator {
    display: none;
  }
}