/* Compare Page Styles */
.compare-page {
  padding: 24px;
  width: 100%;
}

.compare-header {
  margin-bottom: 32px;
}

.compare-header h1 {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.compare-header p {
  margin: 0;
  font-size: 16px;
  color: var(--text-secondary);
}

/* Comparison Controls */
.comparison-controls {
  margin-bottom: 32px;
}

.two-step-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 12px 0;
}

.two-step-header .step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
}

.two-step-header .step.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.two-step-header .step.complete {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: currentColor;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.step-text {
  font-size: 13px;
  font-weight: 600;
}

.selection-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e5e7eb;
  background: white;
  padding: 6px 10px;
  border-radius: 999px;
}

.chip-text {
  font-size: 12px;
  color: #374151;
  font-weight: 600;
}

.chip-remove {
  border: none;
  background: #fee2e2;
  color: #dc2626;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.selection-actions {
  display: flex;
  gap: 8px;
}

.compare-cta {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.compare-cta[disabled], .compare-cta[aria-disabled="true"] {
  background: #93c5fd;
  cursor: not-allowed;
}

.clear-selection {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.modal-chips {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-left: 8px;
}

.two-step-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #f3f4f6;
  color: #6b7280;
}

.inline-step.active { background: #eff6ff; color: #1d4ed8; }
.inline-step.complete { background: #ecfdf5; color: #047857; }

.mp-selector h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.selected-mps {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.selected-mp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  min-width: 280px;
}

.mp-info {
  flex: 1;
}

.mp-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.mp-constituency {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.mp-party {
  font-size: 12px;
  color: var(--text-tertiary);
}

.remove-mp {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-mp:hover {
  background: #fecaca;
}

.add-mp-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: 2px dashed #d1d5db;
  background: #f9fafb;
  color: #6b7280;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
  min-height: 80px;
}

.add-mp-button:hover {
  border-color: #9ca3af;
  background: #f3f4f6;
  color: #374151;
}

/* MP Selector Modal */
.mp-selector-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal-backdrop);
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Mobile modal optimizations */
@media (max-width: 768px) {
  .mp-selector-modal {
    padding: 10px;
    align-items: flex-start;
    padding-top: 20px;
  }
  
  .modal-content {
    max-height: 90vh;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  
  .search-input {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.close-modal {
  background: none;
  border: none;
  font-size: 20px;
  color: #6b7280;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}

.close-modal:hover {
  background: #f3f4f6;
}

.search-container {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
}

.mp-search-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: default;
  transition: all 0.2s ease;
  position: relative;
}

.mp-search-result.selectable {
  cursor: pointer;
}

.mp-search-result.selectable:hover {
  border-color: #3b82f6;
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mp-search-result.already-selected {
  background: #ecfdf5;
  border-color: #10b981;
  opacity: 0.8;
}

.mp-search-result.already-selected::after {
  content: "✓ Selected";
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 11px;
  color: #059669;
  font-weight: 600;
  background: #d1fae5;
  padding: 2px 6px;
  border-radius: 4px;
}

.mp-search-result.disabled {
  opacity: 0.4;
  background: #f9fafb;
  cursor: not-allowed;
}

.mp-basic-info .mp-name {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.mp-details {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 2px;
}

.mp-quick-stats .utilization {
  font-size: 14px;
  font-weight: 500;
  color: #059669;
}

/* Comparison Results */
.comparison-results {
  margin-top: 32px;
}

.comparison-summary {
  margin-bottom: 32px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.card-icon {
  background: #f0f9ff;
  padding: 12px;
  border-radius: 8px;
  color: #0369a1;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-value.positive {
  color: #059669;
}

.card-value.negative {
  color: #dc2626;
}

/* Comparison Charts */
.comparison-charts {
  margin-bottom: 32px;
}

.chart-section {
  margin-bottom: 32px;
}

.chart-section h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Comparison Table */
.comparison-table h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.table-container {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

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

.comparison-data-table th,
.comparison-data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.comparison-data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

.comparison-data-table td {
  font-size: 14px;
  color: var(--text-primary);
}

.mp-cell .mp-name {
  font-weight: 600;
  margin-bottom: 2px;
}

.mp-cell .mp-constituency,
.mp-cell .mp-party {
  font-size: 12px;
  color: var(--text-secondary);
}

.utilization-badge {
  font-weight: 600;
  font-size: 12px;
}

/* Insights */
.comparison-insights h3 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.insight-card {
  padding: 20px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  text-align: center;
}

.insight-card h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.insight-mp {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.insight-value {
  font-size: 20px;
  font-weight: 700;
  color: #059669;
  margin-bottom: 8px;
}

.insight-context {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
  font-style: italic;
}

/* Empty State */
.empty-comparison {
  text-align: center;
  padding: 60px 20px;
}

.empty-content {
  max-width: 400px;
  margin: 0 auto;
}

.empty-content h3 {
  margin: 16px 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-content p {
  margin: 0 0 24px 0;
  font-size: 16px;
  color: var(--text-secondary);
}

.start-comparing-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.start-comparing-btn:hover {
  background: #2563eb;
}

/* Mobile-First Design Enhancements */

/* Mobile MP Carousel */
.mobile-mp-carousel {
  margin-bottom: 1.5rem;
}

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.5rem 0.5rem 0 0;
  border-bottom: 1px solid #e2e8f0;
}

.carousel-nav-btn {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #374151;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.carousel-nav-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.carousel-nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.carousel-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.carousel-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #374151;
}

.current-mp {
  color: #3b82f6;
  font-size: 1.125rem;
}

.separator {
  color: #9ca3af;
  font-size: 0.875rem;
}

.total-mps {
  color: #6b7280;
  font-size: 1rem;
}

.mobile-mp-container {
  background: white;
  border-radius: 0 0 0.5rem 0.5rem;
  overflow: hidden;
  touch-action: pan-y;
}

.mobile-selected-mp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.5rem;
  background: white;
  min-height: 120px;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: #f8fafc;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: #d1d5db;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 44px; /* Accessibility: larger touch target */
  min-height: 44px;
  position: relative;
}

.dot::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.dot.active::before {
  background: #3b82f6;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.5);
}

.swipe-hint {
  text-align: center;
  padding: 0.75rem;
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
}

.swipe-hint small {
  color: #64748b;
  font-size: 0.8rem;
  font-style: italic;
}

/* Mobile Add MP Button */
.mobile-add-mp-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-add-mp-button:hover {
  background: #2563eb;
}

.mobile-add-mp-button:active {
  transform: translateY(1px);
  background: #1d4ed8;
}

/* Mobile Comparison Section */
.mobile-comparison-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.comparison-chart-mobile h3 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-comparison-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mobile-comparison-cards h3 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

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

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

.comparison-card-header .mp-info {
  flex: 1;
}

.comparison-card-header .mp-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
}

.comparison-card-header .mp-info p {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: #6b7280;
}

.mp-party-tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: #f3f4f6;
  color: #6b7280;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.utilization-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.large-utilization-badge {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  text-align: center;
  min-width: 80px;
}

.comparison-metrics {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.metric-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Touch Optimizations */
.mobile-mp-container {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .carousel-nav-btn:active:not(:disabled),
  .mobile-add-mp-button:active,
  .mobile-mp-comparison-card:hover {
    transform: none;
  }
  
  .dot.active::before {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .compare-page {
    padding: 12px;
  }
  
  .carousel-header {
    padding: 0.75rem;
  }
  
  .mobile-selected-mp-card {
    padding: 1rem;
    min-height: 100px;
  }
  
  .mobile-mp-comparison-card {
    padding: 1rem;
  }
  
  .metric-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

@media (max-width: 768px) {
  .compare-page {
    padding: 16px;
  }
  
  .selected-mps {
    flex-direction: column;
    align-items: stretch;
  }
  
  .selected-mp-card {
    min-width: unset;
  }
  
  .summary-cards {
    grid-template-columns: 1fr;
  }
  
  .insights-grid {
    grid-template-columns: 1fr;
  }
  
  .table-container {
    font-size: 12px;
  }
  
  /* Hide desktop elements */
  .comparison-data-table,
  .chart-section {
    display: none;
  }
  
  /* Show mobile elements */
  .mobile-comparison-section {
    display: flex;
  }
}

@media (min-width: 769px) {
  /* Hide mobile elements on desktop */
  .mobile-mp-carousel,
  .mobile-add-mp-button,
  .mobile-comparison-section {
    display: none;
  }
}