/* ==========================================================================
   E-VOTING OSIS - MODERN UI DESIGN SYSTEM
   Theme: Purple, Blue, Black (Hitam) with Clean White Background & Gradients
   ========================================================================== */

:root {
  /* Core Color Palette */
  --primary-purple: #7c3aed;
  --primary-indigo: #4f46e5;
  --primary-blue: #2563eb;
  --accent-cyan: #0ea5e9;
  --dark-slate: #0f172a;
  --deep-black: #090d16;
  
  /* Gradients */
  --grad-primary: linear-gradient(135deg, #7c3aed 0%, #4f46e5 50%, #2563eb 100%);
  --grad-primary-hover: linear-gradient(135deg, #6d28d9 0%, #4338ca 50%, #1d4ed8 100%);
  --grad-purple: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --grad-blue: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --grad-dark: linear-gradient(180deg, #090d16 0%, #0f172a 60%, #1e1b4b 100%);
  --grad-dark-h: linear-gradient(135deg, #090d16 0%, #111827 50%, #1e1b4b 100%);
  --grad-accent-subtle: linear-gradient(135deg, rgba(124, 58, 237, 0.08) 0%, rgba(37, 99, 235, 0.05) 100%);
  --grad-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15), transparent 70%);

  /* Neutrals & Surfaces */
  --body-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #818cf8;
  --text-main: #0f172a;
  --text-muted: #64748b;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 20px 35px -8px rgba(15, 23, 42, 0.1), 0 10px 15px -6px rgba(15, 23, 42, 0.05);
  --shadow-btn: 0 4px 14px rgba(79, 70, 229, 0.3);
  --shadow-btn-hover: 0 6px 20px rgba(79, 70, 229, 0.45);
}

/* Base resets & typography */
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--body-bg);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.text-wrap {
  white-space: normal !important;
}

/* ==========================================================================
   Admin Layout & Sidebar
   ========================================================================== */
.admin-sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--grad-dark);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
}

.brand-block {
  padding: 0.5rem 0.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  margin-bottom: 0.75rem;
}

.brand-logo {
  max-width: 90px;
  max-height: 58px;
  object-fit: contain;
  display: block;
}

.brand-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  line-height: 1.35;
}

.brand-badge {
  display: inline-block;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: #c4b5fd;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-top: 0.5rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.admin-sidebar .nav-link {
  color: rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  padding: 0.62rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.admin-sidebar .nav-link svg {
  flex-shrink: 0;
  opacity: 0.8;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.admin-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(3px);
}

.admin-sidebar .nav-link:hover svg {
  opacity: 1;
}

.admin-sidebar .nav-link.active {
  background: var(--grad-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.35);
}

.admin-sidebar .nav-link.active svg {
  opacity: 1;
}

.admin-sidebar .nav-link.text-warning:hover {
  background: rgba(234, 179, 8, 0.15);
  color: #fde047;
}

.admin-main {
  min-width: 0;
  background-color: var(--body-bg);
  background-image: var(--grad-glow);
  background-repeat: no-repeat;
  background-size: 100% 400px;
}

/* ==========================================================================
   Public & Bilik Navbar
   ========================================================================== */
.app-navbar {
  background: var(--grad-dark-h) !important;
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  padding: 0.6rem 0;
}

.nav-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 4px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-logo {
  max-height: 42px;
  max-width: 42px;
  object-fit: contain;
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */
.card-soft, .card {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  background: var(--card-bg);
  transition: border-color 0.2s ease;
}

.card-soft:hover {
  border-color: #cbd5e1;
}

/* KPI Cards */
.kpi-card {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  background: #ffffff;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

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

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-card.kpi-primary::before { background: var(--grad-primary); }
.kpi-card.kpi-purple::before { background: var(--grad-purple); }
.kpi-card.kpi-blue::before { background: var(--grad-blue); }
.kpi-card.kpi-success::before { background: linear-gradient(135deg, #10b981, #059669); }
.kpi-card.kpi-warning::before { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-card.kpi-info::before { background: linear-gradient(135deg, #06b6d4, #0284c7); }
.kpi-card.kpi-secondary::before { background: linear-gradient(135deg, #64748b, #475569); }
.kpi-card.kpi-dark::before { background: linear-gradient(135deg, #0f172a, #1e293b); }

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */
.btn-primary {
  background: var(--grad-primary);
  border: none;
  color: #ffffff;
  box-shadow: var(--shadow-btn);
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--grad-primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn-hover);
}

.btn-outline-primary {
  border-color: #6366f1;
  color: #4f46e5;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-outline-primary:hover {
  background: var(--grad-primary);
  border-color: transparent;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: none;
  color: #ffffff;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border: none;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.touch-btn {
  min-height: 56px;
  font-size: 1.1rem;
  border-radius: 14px;
}

/* ==========================================================================
   Form Controls
   ========================================================================== */
.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3.5px rgba(99, 102, 241, 0.15);
}

.form-control-lg {
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
}

/* Form Tabs */
.nav-tabs-custom {
  border-bottom: 2px solid var(--border-color);
  gap: 0.5rem;
}

.nav-tabs-custom .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 0;
  background: transparent;
  transition: all 0.2s ease;
}

.nav-tabs-custom .nav-link:hover {
  color: var(--primary-indigo);
}

.nav-tabs-custom .nav-link.active {
  color: var(--primary-purple);
  border-bottom-color: var(--primary-purple);
  background: transparent;
}

/* ==========================================================================
   Badges & Tags
   ========================================================================== */
.badge-guru {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  letter-spacing: 0.5px;
  font-size: 0.75rem;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
}

.badge-siswa {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.75rem;
}

/* ==========================================================================
   Candidate & Voting booth styles
   ========================================================================== */
.candidate-card {
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  background: #ffffff;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.candidate-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.candidate-photo {
  width: 100%;
  height: 230px;
  object-fit: cover;
  background: #eef2f7;
}

.candidate-badge-no {
  background: var(--grad-primary);
  color: #fff;
  font-weight: 800;
  border-radius: 12px;
  padding: 0.4rem 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.token-input {
  font-size: 2rem;
  letter-spacing: 0.2rem;
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
  height: 72px;
  border-radius: 16px;
  border: 2px solid #cbd5e1;
  background: #ffffff;
}

.token-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   Admin Login Card
   ========================================================================== */
.login-card {
  max-width: 460px;
  margin: 6vh auto 2rem;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.12), 0 10px 20px -5px rgba(124, 58, 237, 0.08);
  background: #ffffff;
}

.login-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.15);
  border: 2px solid rgba(124, 58, 237, 0.15);
}

.login-logo {
  max-height: 85px;
  max-width: 160px;
  object-fit: contain;
}

/* ==========================================================================
   COMPACT TOKEN PRINTING (Hemat Kertas)
   Optimized for 24+ tokens per A4 sheet
   ========================================================================== */
.print-page {
  max-width: 210mm;
  margin: 0 auto;
}

/* Default 3-column compact grid */
.token-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3.5mm;
}

.token-grid.grid-4col {
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5mm;
}

.token-grid.grid-2col {
  grid-template-columns: repeat(2, 1fr);
  gap: 5mm;
}

/* Compact Token Card */
.token-card-compact {
  border: 1px dashed #64748b;
  border-radius: 3mm;
  padding: 2.5mm 3mm;
  min-height: 28mm;
  max-height: 32mm;
  page-break-inside: avoid;
  break-inside: avoid;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.token-card-compact .tc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dotted #cbd5e1;
  padding-bottom: 1.2mm;
  margin-bottom: 1.2mm;
  font-size: 7pt;
  line-height: 1;
}

.token-card-compact .tc-school {
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.token-card-compact .tc-class {
  font-weight: 700;
  background: #f1f5f9;
  color: #0f172a;
  padding: 0.8mm 1.5mm;
  border-radius: 1mm;
  font-size: 6.5pt;
  line-height: 1;
}

.token-card-compact .tc-class.guru {
  background: #ede9fe;
  color: #5b21b6;
}

.token-card-compact .tc-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}

.token-card-compact .tc-name {
  font-weight: 800;
  font-size: 9.5pt;
  color: #0f172a;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-card-compact .tc-nis {
  font-size: 7pt;
  color: #64748b;
  margin-top: 0.8mm;
  font-family: monospace;
}

.token-card-compact .tc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1.5mm;
  padding: 1mm 2mm;
  margin-top: 1.5mm;
}

.token-card-compact .tc-label {
  font-size: 6pt;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
}

.token-card-compact .tc-code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-weight: 900;
  font-size: 11pt;
  letter-spacing: 1.2px;
  color: #1e1b4b;
}

/* Chart container */
.chart-box {
  position: relative;
  height: 360px;
}

/* ==========================================================================
   Responsive & Print Rules
   ========================================================================== */
@media (max-width: 991px) {
  .admin-sidebar {
    width: 230px;
    flex-basis: 230px;
  }
}

@media (max-width: 768px) {
  .admin-sidebar {
    display: none;
  }
  .token-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .token-grid {
    grid-template-columns: 1fr;
  }
}

/* Dedicated Print Styles */
@media print {
  @page {
    size: A4 portrait;
    margin: 6mm 8mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9pt;
  }

  .no-print, .navbar, .admin-sidebar, .btn, .alert, .pagination, footer {
    display: none !important;
  }

  .print-page {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .token-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3mm !important;
  }

  .token-grid.grid-4col {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 2mm !important;
  }

  .token-card-compact {
    border: 1px dashed #222222 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    min-height: 27mm !important;
    max-height: 30mm !important;
  }

  .token-card-compact .tc-footer {
    background: #ffffff !important;
    border: 1px solid #777777 !important;
  }

  .token-card-compact .tc-code {
    color: #000000 !important;
    font-size: 10.5pt !important;
  }

  .token-card-compact .tc-school,
  .token-card-compact .tc-name {
    color: #000000 !important;
  }
}
