
/* ═══════════════════════════════════════════════════════════════════════════
   TONGA ELECTORAL COMMISSION — UNIFIED DESIGN SYSTEM
   Red (#C8102E) & White Theme — Professional, Clean, Mobile-First
   ═════════════════════════════════════════════════════════════════════════════ */

:root {
  --primary:      #C8102E;
  --primary-dark: #9B0B22;
  --primary-light:#F5D0D8;
  --white:        #FFFFFF;
  --gray-50:      #FAFBFC;
  --gray-100:     #F3F4F6;
  --gray-200:     #E5E7EB;
  --gray-300:     #D1D5DB;
  --gray-400:     #9CA3AF;
  --gray-500:     #6B7280;
  --gray-600:     #4B5563;
  --gray-700:     #374151;
  --gray-800:     #1F2937;
  --gray-900:     #111827;
  --success:      #10B981;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --info:         #3B82F6;
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:    0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg:    0 10px 15px rgba(0,0,0,0.1);
  --radius-sm:    4px;
  --radius-md:    6px;
  --radius-lg:    8px;
  --radius-xl:    12px;
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* NAVIGATION BAR */
/* ─────────────────────────────────────────────────────────────────────────── */
.navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  border-bottom: 3px solid var(--primary-dark);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-seal {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
  display: block;
}

.nav-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a, .nav-links button {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: none;
}

.nav-links a:hover, .nav-links a.active, .nav-links button:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,0.25);
}

.nav-user span {
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.5);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* MAIN CONTENT */
/* ─────────────────────────────────────────────────────────────────────────── */
.main-content {
  padding: 32px 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.main-content.full-height {
  max-width: 100%;
  padding: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* HEADERS & TYPOGRAPHY */
/* ─────────────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { color: var(--gray-900); font-weight: 700; margin: 0; }
h1 { font-size: 2rem; line-height: 1.2; }
h2 { font-size: 1.5rem; line-height: 1.3; }
h3 { font-size: 1.2rem; line-height: 1.4; }
h4 { font-size: 1rem; }

.page-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}

.page-header h1 { margin-bottom: 6px; }
.page-header p { color: var(--gray-500); font-size: 0.95rem; margin: 0; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* BUTTONS */
/* ─────────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: 2px solid var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(200,16,46,0.3);
}

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

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

.btn-success {
  background: var(--success);
  color: white;
  border: 2px solid var(--success);
}

.btn-success:hover {
  filter: brightness(0.9);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: 2px solid var(--danger);
}

.btn-danger:hover {
  filter: brightness(0.9);
}

.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* FORMS */
/* ─────────────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  color: var(--gray-800);
  background: white;
  transition: all 0.2s ease;
  font-family: inherit;
}

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

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 6px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* CARDS & CONTAINERS */
/* ─────────────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--gray-50);
}

.card-header h3 {
  font-size: 1.05rem;
  margin: 0;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  gap: 8px;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* STATS & METRICS */
/* ─────────────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.blue { border-left-color: var(--info); }
.stat-card.red { border-left-color: var(--primary); }

.stat-num {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-sub {
  font-size: 0.85rem;
  color: var(--gray-600);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* TABLES */
/* ─────────────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

thead th {
  background: var(--gray-100);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-300);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.9rem;
  color: var(--gray-700);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--gray-50);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* BADGES & STATUS */
/* ─────────────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-green { background: #D1FAE5; color: #065F46; }
.badge-red { background: #FEE2E2; color: #991B1B; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* ALERTS */
/* ─────────────────────────────────────────────────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-success {
  background: #ECFDF5;
  border-left-color: var(--success);
  color: #065F46;
}

.alert-error, .alert-danger {
  background: #FEF2F2;
  border-left-color: var(--danger);
  color: #7F1D1D;
}

.alert-warning {
  background: #FFFBEB;
  border-left-color: var(--warning);
  color: #78350F;
}

.alert-info {
  background: #EFF6FF;
  border-left-color: var(--info);
  color: #082F49;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* LOGIN PAGE */
/* ─────────────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: var(--radius-xl);
  padding: 48px 36px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid var(--primary-light);
  background: var(--gray-50);
  display: block;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(200,16,46,0.2);
}

.login-logo h1 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 6px;
}

.login-logo p {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin: 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 24px 0;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* EMPTY STATE */
/* ─────────────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state .icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--gray-600);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.95rem;
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* GRID LAYOUTS */
/* ─────────────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* RESPONSIVE */
/* ─────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--primary-dark);
    padding: 8px 0;
    box-shadow: var(--shadow-lg);
    align-items: stretch;
    border-radius: 0;
    gap: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { padding: 14px 20px; border-radius: 0; display: block; }
  .nav-user { flex-direction: column; align-items: flex-start;
              padding: 12px 20px; border: none; margin: 0; width: 100%;
              border-top: 1px solid rgba(255,255,255,0.15); }
  .nav-user span { width: 100%; }
  .main-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { margin-bottom: 20px; }
  h1 { font-size: 1.5rem; }
  .login-box { padding: 32px 24px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .navbar { height: 56px; padding: 0 12px; }
  .nav-title { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px 12px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .login-box { padding: 24px 16px; }
  .stat-num { font-size: 1.8rem; }
  h1 { font-size: 1.3rem; }
  .page-header { padding-bottom: 16px; }
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* UTILITY CLASSES */
/* ─────────────────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.p-0 { padding: 0; }
.p-2 { padding: 8px; }
.p-4 { padding: 16px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
