@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #7c3aed;
  --green-dark: #5b21b6;
  --green-light: #8b5cf6;
  --gold: #ffcc18;
  --gold-dark: #e6b800;
  --bg: #faf5ff;
  --white: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --card-bg: #ffffff;
  --selected: #ede9fe;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-card: 0 2px 6px rgba(0,0,0,0.08);
}

html, body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

/* =========  LAYOUT  ========= */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 100px;
  min-height: 100vh;
}

/* =========  HEADER  ========= */
.app-header {
  background: var(--green);
  color: var(--white);
  text-align: center;
  padding: 20px 16px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 2px;
}

/* =========  VOTER COUNTER  ========= */
.voter-counter {
  background: var(--gold);
  color: var(--green-dark);
  text-align: center;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* =========  PROGRESS BAR  ========= */
.progress-wrap {
  background: var(--white);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 72px;
  z-index: 99;
}
.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.progress-bar-outer {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-inner {
  background: var(--green);
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* =========  ROLE INFO  ========= */
.role-info {
  padding: 16px 0 8px;
}
.role-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 4px;
}
.role-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* =========  SEARCH BAR  ========= */
.search-wrap {
  position: sticky;
  top: 136px;
  z-index: 98;
  background: var(--bg);
  padding: 8px 0;
}
.search-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 12px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: var(--green);
}

/* =========  LIVE CHART  ========= */
.chart-wrap {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  margin: 10px 0;
  box-shadow: var(--shadow-card);
}
.chart-heading {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chart-canvas-wrap {
  height: 140px;
}

/* =========  CANDIDATE CARDS  ========= */
.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 0;
}
.candidate-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-card);
}
.candidate-card:active {
  transform: scale(0.98);
}
.candidate-card.selected {
  border-color: var(--green);
  background: var(--selected);
}
.candidate-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.candidate-card.selected .candidate-avatar {
  background: var(--green-dark);
}
.candidate-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}
.candidate-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.candidate-card.selected .candidate-check {
  background: var(--green);
  border-color: var(--green);
}
.candidate-check svg {
  opacity: 0;
  transition: opacity 0.15s;
}
.candidate-card.selected .candidate-check svg {
  opacity: 1;
}
.no-results {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* =========  SELECTION COUNTER  ========= */
.selection-counter {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  padding: 6px 0;
}

/* =========  FIXED NEXT BUTTON  ========= */
.fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 200;
}
.fixed-bottom-inner {
  max-width: 480px;
  margin: 0 auto;
}
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--green);
  color: var(--white);
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}
.btn-gold {
  background: var(--gold);
  color: var(--green-dark);
}
.btn-gold:hover { background: var(--gold-dark); }

/* =========  WELCOME / INDEX PAGES  ========= */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 130px);
  padding: 32px 16px;
  text-align: center;
}
.hero-icon {
  width: 80px;
  height: 80px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
}
.hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}
.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}
.form-group {
  width: 100%;
  max-width: 360px;
  margin-bottom: 16px;
  text-align: left;
}
.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-family: inherit;
  text-align: center;
  letter-spacing: 0.2em;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--green); }
.error-msg {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 8px;
  min-height: 20px;
  font-weight: 500;
}

/* =========  CONFIRMATION PAGE  ========= */
.confirm-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin: 16px 0;
}
.confirm-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.confirm-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-role {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 130px;
  flex-shrink: 0;
  padding-top: 1px;
}
.confirm-names {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.email-notice {
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--green);
  margin: 12px 0;
  text-align: center;
}

/* =========  LOADING / SPINNER  ========= */
.loading {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
