/* ============================================
   Class Voting System — Professional Theme
   ============================================ */

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

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

[hidden], .modal-overlay[hidden] {
  display: none !important;
}

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-glow: rgba(99,102,241,0.35);
  --accent: #a78bfa;
  --accent2: #f472b6;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 40px -8px rgba(0,0,0,.15);
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f472b6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--gray-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Animated background blobs */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  z-index: -1;
  animation: float 20s ease-in-out infinite;
}
body::before {
  width: 500px; height: 500px;
  background: #818cf8;
  top: -100px; left: -100px;
}
body::after {
  width: 400px; height: 400px;
  background: #f472b6;
  bottom: -50px; right: -50px;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ---------- Layout ---------- */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */
header {
  text-align: center;
  margin-bottom: 2rem;
  color: white;
}

.logo {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.2));
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(0,0,0,.2);
}

.subtitle {
  opacity: 0.9;
  font-size: 1.05rem;
  font-weight: 400;
  margin-top: 0.25rem;
}

/* ---------- Cards ---------- */
.card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-xl);
  margin-bottom: 1.5rem;
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.login-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--gray-900);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  margin-bottom: 0.4rem;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
  background: white;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-group .input-hint {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

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

.info-text {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
  border-left: 4px solid var(--danger);
  animation: shake 0.4s ease;
}

.success-msg {
  background: var(--success-light);
  color: #065f46;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
  border-left: 4px solid var(--success);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-xs);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  font-size: 1rem;
}

/* ---------- Ballot Sections ---------- */
.ballot-section {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-xl);
  margin-bottom: 1.5rem;
  animation: slideUp 0.5s ease-out;
}

.ballot-section:nth-child(2) { animation-delay: 0.1s; }

.ballot-section.voted { opacity: 0.6; }

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--gray-900);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.85rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge-cr {
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  color: #3730a3;
}

.badge-lr {
  background: linear-gradient(135deg, #fce7f3, #fae8ff);
  color: #9d174d;
}

/* ---------- Candidate Cards ---------- */
.candidates-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.candidate-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  background: white;
}

.candidate-card:hover {
  border-color: var(--primary-light);
  background: var(--gray-50);
  transform: translateX(4px);
}

.candidate-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.candidate-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
  transform: translateX(4px);
}

.candidate-card:has(input:checked) .check-mark {
  opacity: 1;
  transform: scale(1);
}

.candidate-card:has(input:checked) .candidate-avatar {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  border-color: transparent;
}

.candidate-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.candidate-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  transition: var(--transition);
  border: 2px solid var(--gray-200);
  flex-shrink: 0;
  overflow: hidden;
}

.candidate-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.candidate-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-800);
}

.check-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition);
  flex-shrink: 0;
}

.already-voted {
  text-align: center;
  color: var(--success);
  font-weight: 600;
  padding: 1.5rem;
  font-size: 0.95rem;
}

/* ---------- Vote Actions ---------- */
.vote-actions {
  text-align: center;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.vote-actions .btn { max-width: 420px; margin: 0 auto; }

/* ---------- Thank You ---------- */
.thank-you-card {
  text-align: center;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  padding: 3rem 2rem;
}

.thank-you-card .success-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: popIn 0.6s cubic-bezier(.68,-.55,.27,1.55);
}

@keyframes popIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.thank-you-card h2 {
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--success), #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.thank-you-card p {
  margin-bottom: 0.5rem;
  color: var(--gray-600);
}

.thank-you-card .btn { margin-top: 2rem; }

/* ---------- Confirmation Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.3s cubic-bezier(.68,-.55,.27,1.55);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h3 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.modal p {
  margin-bottom: 0.5rem;
  color: var(--gray-700);
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn { flex: 1; }

/* ---------- Admin Tabs ---------- */
.admin-tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab:hover { color: white; background: rgba(255,255,255,0.1); }

.tab.active {
  background: white;
  color: var(--gray-900);
  box-shadow: var(--shadow);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: slideUp 0.3s ease; }

/* ---------- Stats ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-sm);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.3);
}

.stat-number {
  display: block;
  font-size: 2.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.25rem;
}

/* ---------- Results ---------- */
.results-card { margin-bottom: 1.5rem; }

.results-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-row { position: relative; }

.result-row.leading .result-name { color: var(--primary); }

.result-row.leading .result-bar {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.result-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.result-name { font-weight: 600; font-size: 0.95rem; }

.result-votes {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
}

.result-bar-bg {
  height: 12px;
  background: var(--gray-100);
  border-radius: 50px;
  overflow: hidden;
}

.result-bar {
  height: 100%;
  background: var(--gray-300);
  border-radius: 50px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
  min-width: 6px;
}

/* ---------- Admin Lists ---------- */
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.admin-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: var(--radius-xs);
  border: 1px solid var(--gray-200);
  font-size: 0.9rem;
}

.admin-list-item .item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-600);
  flex-shrink: 0;
  overflow: hidden;
}

.admin-list-item .item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-list-item .item-info {
  flex: 1;
  min-width: 0;
}

.admin-list-item .item-name {
  font-weight: 600;
  color: var(--gray-800);
}

.admin-list-item .item-meta {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.admin-list-item .item-actions { flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--gray-400);
  font-size: 0.9rem;
}

/* ---------- Voter Table ---------- */
.voter-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--gray-200);
}

.voter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.voter-table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.voter-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.voter-table tr:last-child td { border-bottom: none; }

.voter-table .code {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.25rem;
}

.status-dot.voted { background: var(--success); }
.status-dot.pending { background: var(--gray-300); }

/* ---------- Photo Upload ---------- */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gray-100);
  border: 2px dashed var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--gray-400);
  overflow: hidden;
  flex-shrink: 0;
  transition: var(--transition);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview.has-photo {
  border-style: solid;
  border-color: var(--primary);
}

/* ---------- Button Row ---------- */
.btn-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-row .btn { flex: 1; min-width: 120px; }

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 1.5rem 0;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  margin-top: auto;
  padding-top: 2rem;
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
}

footer strong { color: white; }

.admin-link {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 0.8rem;
  display: inline-block;
  margin-top: 0.5rem;
  transition: var(--transition);
}

.admin-link:hover { color: white; }

/* ---------- Loading ---------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: white;
  gap: 0.75rem;
  font-weight: 500;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding: 1rem 0.75rem; }
  header h1 { font-size: 1.5rem; }
  .card { padding: 1.5rem; }
  .ballot-section { padding: 1.25rem; }
  .stats-row { grid-template-columns: 1fr; gap: 0.75rem; }
  .stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    padding: 1rem 1.25rem;
  }
  .stat-number { font-size: 1.5rem; }
  .modal-actions { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .admin-tabs { overflow-x: auto; }
  .btn-row { flex-direction: column; }
}
