/* ═══════════════════════════════════════════════════════════
   Student Union Election Portal — Design System
   Glassmorphism · Dark Mode · Professional Election UI
═══════════════════════════════════════════════════════════ */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.12);
  --secondary: #0ea5e9;
  --secondary-soft: rgba(14, 165, 233, 0.12);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --bg: #f0f2f8;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-sidebar: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #4c1d95 100%);
  --text: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;
  --border: rgba(148, 163, 184, 0.25);
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --sidebar-w: 280px;
  --topbar-h: 72px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-glass: rgba(17, 24, 39, 0.78);
  --bg-sidebar: linear-gradient(180deg, #020617 0%, #0f172a 50%, #1e1b4b 100%);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;
  --border: rgba(148, 163, 184, 0.12);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --primary-soft: rgba(99, 102, 241, 0.18);
  --secondary-soft: rgba(14, 165, 233, 0.18);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

/* ── Typography ──────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ── Glass Card ──────────────────────────────────────────── */

.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.glass-card.compact {
  padding: 1.1rem 1.25rem;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary-custom,
.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.15rem;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.btn-primary-custom:hover,
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
  color: #fff;
}

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  font-weight: 500;
  transition: background var(--transition);
}

.btn-ghost:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-sm-icon {
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

/* ── Forms ───────────────────────────────────────────────── */

.form-control,
.form-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-text {
  color: var(--text-muted);
}

.input-group-text {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text-muted);
}

/* ── Badges ──────────────────────────────────────────────── */

.badge-soft {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.35em 0.7em;
  border-radius: 999px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.badge-info {
  background: rgba(6, 182, 212, 0.15);
  color: #0891b2;
}

.badge-secondary {
  background: rgba(100, 116, 139, 0.15);
  color: #64748b;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

[data-theme="dark"] .badge-success { color: #34d399; }
[data-theme="dark"] .badge-danger { color: #f87171; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-info { color: #22d3ee; }
[data-theme="dark"] .badge-secondary { color: #94a3b8; }

/* ── Tables ──────────────────────────────────────────────── */

.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}

.table-modern thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-modern tbody td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  font-size: 0.925rem;
}

.table-modern tbody tr {
  transition: background var(--transition);
}

.table-modern tbody tr:hover {
  background: var(--primary-soft);
}

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

.table-responsive {
  border-radius: var(--radius);
  overflow: auto;
}

/* ── Stat Cards ──────────────────────────────────────────── */

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 130px;
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0.15rem 0;
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0;
}

.stat-card .stat-glow {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.35;
  right: -30px;
  top: -30px;
  pointer-events: none;
}

/* ── Empty State ─────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  opacity: 0.35;
  margin-bottom: 1rem;
  display: block;
}

.empty-state h5 {
  color: var(--text);
  margin-bottom: 0.35rem;
}

/* ── Progress ────────────────────────────────────────────── */

.progress-modern {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.progress-modern .bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease;
}

/* ── Modal overrides (footer always visible) ─────────────── */

.modal {
  padding-right: 0 !important;
}

.modal-dialog {
  margin: 0.75rem auto;
  max-width: min(800px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
}

.modal-dialog.modal-lg {
  max-width: min(800px, calc(100vw - 1.5rem));
}

/* Prefer top alignment on short viewports so footer is not clipped */
.modal-dialog-centered {
  min-height: calc(100% - 1.5rem);
  align-items: center;
}

@media (max-height: 720px), (max-width: 575.98px) {
  .modal-dialog-centered {
    align-items: flex-start !important;
    min-height: 0;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }
}

.modal-content,
form.modal-content {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 1.5rem);
  overflow: hidden;
}

/* Scrollable body; header + footer stay pinned */
.modal-dialog-scrollable {
  height: auto;
  max-height: calc(100dvh - 1.5rem);
}

.modal-dialog-scrollable .modal-content,
.modal-dialog-scrollable form.modal-content {
  max-height: calc(100dvh - 1.5rem);
  overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-header {
  border-bottom-color: var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
}

.modal-footer {
  border-top-color: var(--border);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--bg-elevated);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.85rem 1rem;
}

.modal-footer > * {
  margin: 0;
}

.modal-title {
  font-weight: 700;
}

.btn-close {
  filter: var(--bs-btn-close-white, none);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Ensure modal sits above admin chrome */
.modal,
.modal-backdrop {
  z-index: 2000;
}

.modal-backdrop {
  z-index: 1990;
}

/* ── Auth pages ──────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(79, 70, 229, 0.18), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.15), transparent 50%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 2.25rem;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-brand .logo-circle {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.75rem;
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.35);
}

.auth-brand h1 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.auth-brand p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ── Utilities ───────────────────────────────────────────── */

.text-muted-custom {
  color: var(--text-muted) !important;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
}

.avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 14px;
}

.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.symbol-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 4px;
  display: block;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Frame that keeps symbol fully inside a card/box */
.symbol-box {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-sizing: border-box;
  overflow: hidden;
}

.symbol-box img,
.symbol-box .symbol-badge {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: none;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

[data-theme="dark"] .symbol-box,
[data-theme="dark"] .symbol-badge {
  background: #1e293b;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 1px var(--border);
}

.fw-800 { font-weight: 800; }

.gap-2-custom { gap: 0.5rem; }

.cursor-pointer { cursor: pointer; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--border) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

.animate-in {
  animation: fadeInUp 0.4s ease both;
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }

/* Print */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .glass-card { box-shadow: none; border: 1px solid #ddd; }
}
