/* 
 * PoliSay - Main Stylesheet
 * A modern, card-based political leader rating platform
 */

/* Base Styles & Variables */
:root {
  --primary-color: #3498db;
  --secondary-color: #2c3e50;
  --accent-color: #e74c3c;
  --light-gray: #f5f5f5;
  --medium-gray: #e0e0e0;
  --dark-gray: #333333;
  --success-color: #2ecc71;
  --warning-color: #f39c12;
  --card-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  --transition-speed: 0.3s;
  --border-radius: 8px;
}

body {
  font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--dark-gray);
  background-color: var(--light-gray);
  margin: 0;
  padding: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  margin-top: 0;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-speed);
}

a:hover {
  color: var(--accent-color);
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Header */
.site-header {
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary-color);
}

.logo span {
  color: var(--secondary-color);
}

.search-bar {
  flex-grow: 1;
  max-width: 500px;
  margin: 0 2rem;
}

.search-bar input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--medium-gray);
  border-radius: var(--border-radius);
  font-size: 1rem;
}

.filters {
  display: flex;
  gap: 1rem;
}

.filter-dropdown select {
  padding: 0.6rem;
  border: 1px solid var(--medium-gray);
  border-radius: var(--border-radius);
  background-color: white;
  font-size: 0.9rem;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 2rem 0;
}

.leader-card {
  background-color: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
  display: flex;
  flex-direction: column;
  height: 500px; /* Fixed height for all cards */
  position: relative; /* For absolute positioning of compare button */
}

.leader-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.card-photo-container {
  width: 100%;
  height: 200px; /* Fixed height for image container */
  overflow: hidden;
}

.card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Make image cover the container */
  object-position: center; /* Center the image */
  cursor: pointer;
}

.card-content {
  padding: 1.5rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.leader-name {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.leader-demographics {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
}

.leader-bio {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.leader-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  border-top: 1px solid var(--medium-gray);
  padding-top: 0.8rem;
}

.leader-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-color);
}

.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--primary-color);
  color: white;
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-speed), visibility var(--transition-speed);
}

/* Lightbox Compare Button */
.lightbox-compare-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 8px 15px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color var(--transition-speed);
  width: 100%;
  margin-top: 10px;
}

.lightbox-compare-btn:hover {
  background-color: var(--accent-color);
}

.lightbox-compare-btn.active {
  background-color: var(--success-color);
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  background-color: white;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.lightbox-header {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--medium-gray);
}

.close-lightbox {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--dark-gray);
}

.lightbox-body {
  display: flex;
  padding: 1rem;
}

.leader-profile {
  flex: 0 0 40%;
}

.leader-photo-large {
  width: 100%;
  border-radius: var(--border-radius);
}

.leader-info {
  margin-top: 1rem;
}

.spider-graph-container {
  flex: 0 0 60%;
  padding-left: 1rem;
}

.spider-graph {
  width: 100%;
  height: 300px;
  margin-bottom: 1rem;
  cursor: pointer; /* Change cursor to pointer to indicate clickable */
}

.back-button {
  display: inline-block;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.back-button:hover {
  background-color: var(--primary-color);
}

.position-panel {
  border-top: 1px solid var(--medium-gray);
  padding-top: 1rem;
}

.position-tabs {
  display: flex;
  border-bottom: 1px solid var(--medium-gray);
  margin-bottom: 1rem;
}

.position-tab {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.position-tab.active {
  border-bottom-color: var(--primary-color);
  font-weight: bold;
}

.evidence-list {
  max-height: 300px;
  overflow-y: auto;
}

.evidence-item {
  padding: 1rem;
  border-bottom: 1px solid var(--medium-gray);
}

.evidence-content {
  margin-bottom: 0.5rem;
}

.evidence-source {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.evidence-votes {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
}

.vote-buttons {
  display: flex;
  margin-left: 1rem;
}

.vote-button {
  background: none;
  border: 1px solid var(--medium-gray);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  margin-right: 0.5rem;
  cursor: pointer;
}

.vote-button:hover {
  background-color: var(--light-gray);
}

.add-evidence {
  display: block;
  width: 100%;
  padding: 0.8rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  margin-top: 1rem;
  cursor: pointer;
  font-weight: bold;
}

.add-evidence:hover {
  background-color: #2980b9;
}

/* Comparison Mode */
.comparison-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-speed), visibility var(--transition-speed);
}

.comparison-overlay.active {
  opacity: 1;
  visibility: visible;
}

.comparison-content {
  background-color: white;
  border-radius: var(--border-radius);
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scrolling */
  display: flex;
  flex-direction: column;
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--medium-gray);
}

.comparison-title {
  font-size: 1.5rem;
  margin: 0;
}

.add-to-comparison {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.comparison-body {
  display: flex;
  flex-direction: row; /* Side by side layout for desktop */
  padding: 1rem;
  height: auto; /* Auto height to fit content */
  min-height: 600px; /* Minimum height */
  max-height: 80vh; /* Maximum height relative to viewport */
}

.comparison-leaders-left {
  flex: 0 0 10%; /* 10% width for left leaders */
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
}

.comparison-leaders-right {
  flex: 0 0 10%; /* 10% width for right leaders */
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
}

.comparison-graph-container {
  flex: 0 0 80%; /* 80% width for graph */
  height: 500px; /* Fixed height for the graph */
  max-height: 60vh; /* Maximum height relative to viewport */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Mobile layout */
@media (max-width: 768px) {
  .comparison-body {
    flex-direction: column;
    height: auto;
    min-height: 700px;
  }
  
  .comparison-leaders-left, .comparison-leaders-right {
    flex: none;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
  }
  
  .comparison-leaders-left {
    order: 1; /* Show at top */
    display: flex;
    margin-bottom: 0.5rem;
  }
  
  .comparison-leaders-right {
    order: 2; /* Show below left leaders */
    display: flex;
    margin-bottom: 1rem;
  }
  
  .comparison-graph-container {
    flex: none;
    width: 100%;
    height: 400px;
    order: 3; /* Show at bottom */
  }
  
  .comparison-slot {
    width: 45%;
    min-width: 120px;
  }
}

.comparison-slot {
  text-align: center;
  padding: 1rem;
  border: 1px dashed var(--medium-gray);
  border-radius: var(--border-radius);
  width: 120px; /* Smaller width to fit better */
  max-width: 100%; /* Ensure it doesn't overflow */
}

.comparison-slot.filled {
  border: 1px solid var(--medium-gray);
  background-color: var(--light-gray);
}

.comparison-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.5rem;
}

.comparison-name {
  font-weight: bold;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.comparison-demographics {
  font-size: 0.8rem;
  color: #666;
}

.comparison-footer {
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--medium-gray);
}

.close-comparison {
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 2rem;
  cursor: pointer;
}

/* Comparison Indicator */
.comparison-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 0.5rem;
  z-index: 90;
  display: flex;
  align-items: center;
}

.comparison-indicator-title {
  margin-right: 0.5rem;
  font-weight: bold;
  font-size: 0.9rem;
}

.comparison-indicator-slots {
  display: flex;
  gap: 0.5rem;
}

.indicator-slot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px dashed var(--medium-gray);
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--light-gray);
  font-size: 1.2rem;
  color: var(--medium-gray);
}

.indicator-slot.filled {
  border: none;
  overflow: hidden;
  position: relative;
}

.indicator-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.indicator-slot.filled .remove-from-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(231, 76, 60, 0.8); /* Semi-transparent red */
  color: white;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-speed);
}

.indicator-slot.filled:hover .remove-from-indicator {
  opacity: 1;
}

.view-comparison-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  margin-left: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Card Compare Button */
.card-compare-btn {
  margin-top: 10px;
  align-self: center;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 15px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color var(--transition-speed);
  width: 100%;
}

/* Fling Animation */
@keyframes fling-to-compare {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: scale(0.1) translate(500px, 300px);
    opacity: 0;
  }
}

.fling-circle {
  position: fixed;
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  border-radius: 50%;
  z-index: 1000;
  pointer-events: none;
  animation: fling-to-compare 0.8s ease-in-out forwards;
}

.card-compare-btn:hover {
  background-color: var(--accent-color);
}

.card-compare-btn.active {
  background-color: var(--success-color);
}

/* Infinite Scroll */
.loading-spinner {
  text-align: center;
  padding: 2rem 0;
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

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

/* Footer */
.site-footer {
  background-color: var(--secondary-color);
  color: white;
  padding: 1rem 0;
  text-align: center;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links a {
  color: white;
  margin-left: 1rem;
}

.footer-links a:hover {
  text-decoration: underline;
}

.powered-by {
  font-size: 0.9rem;
}

/* Verified Badge */
.verified-badge {
  display: inline-block;
  background-color: var(--success-color);
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  margin-left: 0.5rem;
}

.under-review-badge {
  display: inline-block;
  background-color: var(--warning-color);
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  margin-left: 0.5rem;
}

/* Filter Toggle Button */
.filter-toggle {
  display: none; /* Hidden by default on desktop */
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  margin-left: 1rem;
}

.filter-toggle:hover {
  background-color: var(--accent-color);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    position: relative;
  }
  
  .logo {
    text-align: center;
    margin-bottom: 1rem;
  }
  
  .search-bar {
    margin: 1rem 0;
    max-width: 100%;
    display: flex;
  }
  
  .filter-toggle {
    display: block; /* Show on mobile */
    margin: 0.5rem 0;
    width: 100%;
  }
  
  .filters {
    flex-direction: column;
    display: none; /* Hidden by default on mobile */
    background-color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    margin-top: 0.5rem;
    z-index: 50;
  }
  
  .filters.active {
    display: flex; /* Show when active */
  }
  
  .filter-dropdown {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .filter-dropdown select {
    width: 100%;
  }
  
  .lightbox-body {
    flex-direction: column;
  }
  
  .leader-profile, .spider-graph-container {
    flex: 0 0 100%;
    padding-left: 0;
  }
  
  .leader-photo-large {
    max-width: 200px;
    margin: 0 auto;
    display: block;
  }
  
  .leader-info {
    text-align: center;
  }
  
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    flex-direction: column;
    gap: 1rem;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

.toast {
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.3s, transform 0.3s;
  overflow: hidden;
  position: relative;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.hide {
  opacity: 0;
  transform: translateX(50px);
}

.toast-icon {
  margin-right: 12px;
  font-size: 1.2rem;
}

.toast-message {
  flex-grow: 1;
  font-size: 0.9rem;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--dark-gray);
  padding: 0;
  margin-left: 8px;
}

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

.toast-info .toast-icon {
  color: var(--info-color);
}

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

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

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

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

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

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

@media (max-width: 480px) {
  .toast-container {
    left: 20px;
    right: 20px;
    max-width: calc(100% - 40px);
  }
}

