/* ==========================================================================
   SISTEM SIJIL KEHADIRAN SEKOLAH PPD BESUT - STYLESHEET
   Design Theme: Tema Rasmi Kerajaan (Professional Government Light Theme)
   Cerah, Ceria, Berwibawa, Kemas & Eksklusif
   ========================================================================== */

:root {
  /* Warna Latar & Permukaan Rasmi (Light Government Theme) */
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-light: #e2e8f0;
  --border-focus: #0284c7;
  --border-gold: #c59b27;

  /* Warna Diraja & Autoriti (Royal Navy & Gold) */
  --navy-header: #0a1f44;
  --navy-dark: #0f274a;
  --navy-primary: #1e3a8a;
  --blue-accent: #0284c7;
  --blue-sky: #0ea5e9;

  /* Emas Rasmi (Official Gold & Accents) */
  --gold-primary: #b8860b;
  --gold-light: #dfb743;
  --gold-dark: #8c620c;
  --gold-gradient: linear-gradient(135deg, #c59b27 0%, #fae69e 45%, #d4af37 70%, #996515 100%);
  --gold-text-gradient: linear-gradient(135deg, #996515 0%, #b8860b 50%, #784e08 100%);

  /* Warna Status (Ceria & Jelas) */
  --emerald-success: #059669;
  --emerald-bg: #ecfdf5;
  --amber-warning: #d97706;
  --amber-bg: #fffbeb;
  --rose-danger: #dc2626;
  --rose-bg: #fef2f2;

  /* Tipografi Gelap & Kontras Tinggi (Mudah Dibaca) */
  --text-main: #0f172a;
  --text-heading: #0a192f;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #f8fafc;

  --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  --font-cert-title: 'Cinzel', 'Playfair Display', serif;
  --font-cert-body: 'Playfair Display', Georgia, serif;

  /* Bayang Lembut & Kemas */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
  --shadow-cert: 0 12px 35px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(2, 132, 199, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 15%, rgba(184, 134, 11, 0.05) 0%, transparent 35%),
    linear-gradient(180deg, #edf2f7 0%, #f1f5f9 100%);
  background-attachment: fixed;
}

/* Scrollbar Kemas */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #e2e8f0;
}
::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

button, input, select {
  font-family: inherit;
}

/* ==========================================================================
   HEADER & NAVBAR (NAVBAR DIRAJA RASMI)
   ========================================================================== */
.main-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #091a36 0%, #0f2b57 100%);
  border-bottom: 3px solid var(--gold-primary);
  padding: 0.85rem 1.5rem;
  box-shadow: 0 4px 18px rgba(9, 26, 54, 0.25);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.brand-logos {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.25s ease;
}

.brand-logo-img:hover {
  transform: scale(1.05);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.76rem;
  color: #94a3b8;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2px;
}

.brand-text .badge-slogan {
  background: rgba(212, 175, 55, 0.2);
  color: #fae69e;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 1px 7px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 700;
}

/* Header Action Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: var(--gold-gradient);
  color: #0a192f;
  border-color: var(--gold-primary);
  transform: translateY(-2px);
}

.badge-live-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
  100% { transform: scale(0.9); opacity: 1; }
}

/* ==========================================================================
   HERO / BANNER & FILTER BAR (LIGHT & CRISP)
   ========================================================================== */
.hero-section {
  padding: 1.5rem 1.5rem 0.75rem;
  max-width: 1440px;
  margin: 0 auto;
}

.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(2, 132, 199, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.hero-title-box h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.3px;
}

.hero-title-box p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 0.25rem;
}

/* Period Selectors (Bulan & Tahun) */
.period-selectors {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f8fafc;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-lg);
  border: 1px solid #cbd5e1;
}

.period-selectors label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.custom-select {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
}

.custom-select:hover, .custom-select:focus {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Smart Search Bar (Self-Search Sekolah) */
.search-container {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon-left {
  position: absolute;
  left: 1.25rem;
  color: var(--navy-primary);
  font-size: 1.15rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.95rem 3.5rem 0.95rem 3.25rem;
  font-size: 1rem;
  font-weight: 600;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-lg);
  color: var(--text-main);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.search-input:focus {
  border-color: var(--blue-accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.15);
}

.clear-search-btn {
  position: absolute;
  right: 1.15rem;
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.clear-search-btn:hover {
  background: #fee2e2;
  color: var(--rose-danger);
}

/* Autocomplete Suggestion Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.15);
  display: none;
}

.autocomplete-item {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: #f0f7ff;
  border-left: 4px solid var(--blue-accent);
}

.item-main-info {
  display: flex;
  flex-direction: column;
}

.item-school-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.95rem;
}

.item-school-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.item-school-rate {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--emerald-bg);
  color: var(--emerald-success);
  border: 1px solid #a7f3d0;
}

/* Quick Filter Pills */
.filter-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-pill {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: var(--text-secondary);
  padding: 0.4rem 0.9rem;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-smooth);
}

.filter-pill:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--navy-primary);
  color: #ffffff;
  border-color: var(--navy-primary);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
  font-weight: 700;
}

/* ==========================================================================
   DASHBOARD STATS CARDS (CRISP WHITE LIGHT THEME)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  max-width: 1440px;
  margin: 1.25rem auto 1.5rem;
  padding: 0 1.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.icon-blue { background: #e0f2fe; color: #0284c7; }
.icon-emerald { background: #d1fae5; color: #059669; }
.icon-gold { background: #fef3c7; color: #b45309; }
.icon-purple { background: #f3e8ff; color: #7e22ce; }

.stat-value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.1;
}

.stat-footer {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-trend-up {
  color: var(--emerald-success);
  font-weight: 700;
}

/* ==========================================================================
   MAIN CONTENT & TABS
   ========================================================================== */
.main-content {
  max-width: 1440px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}

/* Active Selected School Profile Banner (Crisp White with Gold Accent) */
.school-banner-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left: 6px solid var(--gold-primary);
  border-radius: var(--radius-xl);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

.school-info-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.school-crest-badge {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  background: #fef3c7;
  border: 2px solid var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--gold-dark);
}

.school-text-wrap h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy-dark);
  letter-spacing: -0.3px;
}

.school-meta-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
}

.meta-chip {
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid #cbd5e1;
}

.meta-chip.code {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.meta-chip.kpi-pass {
  background: #d1fae5;
  color: #047857;
  border-color: #a7f3d0;
}

.school-info-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.attendance-score-box {
  text-align: right;
}

.attendance-score-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.attendance-score-num {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--navy-primary);
  line-height: 1;
}

.ranking-badge-box {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 0.65rem 1.15rem;
  text-align: center;
}

.ranking-badge-box .rank-num {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 900;
  color: #92400e;
}

.ranking-badge-box .rank-text {
  font-size: 0.72rem;
  color: #78350f;
  font-weight: 700;
}

/* Nav Tabs */
.tabs-navigation {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid #cbd5e1;
  padding-bottom: 0.75rem;
  margin-bottom: 1.75rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover {
  color: var(--navy-primary);
  background: #e2e8f0;
}

.tab-btn.active {
  color: var(--navy-primary);
  background: #e0f2fe;
  border: 1px solid #bae6fd;
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -0.85rem;
  left: 15%;
  right: 15%;
  height: 3px;
  background: var(--navy-primary);
  border-radius: 3px;
}

/* Tab Content Panes */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================================================
   SCHOOL CERTIFICATE DOWNLOAD & PREVIEW CONTAINER
   ========================================================================== */
.school-download-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Toolbar Khas untuk Sekolah Self-Download */
.school-actions-toolbar {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.badge-official-cert {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-size: 0.8rem;
  font-weight: 700;
}

.cert-issue-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.btn-primary {
  background: linear-gradient(135deg, #0f2b57 0%, #1a365d 100%);
  color: #ffffff;
  border: 1px solid #0f2b57;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(15, 43, 87, 0.25);
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #163d7a 0%, #234e85 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 43, 87, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

/* Certificate Preview Wrapper (Soft Blueprint Mat Backdrop) */
.cert-preview-wrapper {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  width: 100%;
}

.cert-scale-container {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding: 10px 0;
}

/* ==========================================================================
   THE OFFICIAL CERTIFICATE TEMPLATE (A4 LANDSCAPE 297mm x 210mm)
   Authentic Cream/Parchment Paper with Luxury Gold Guilloché Border
   ========================================================================== */
.certificate-sheet {
  width: 1000px;
  min-width: 1000px;
  height: 707px;
  min-height: 707px;
  background-color: #fcfbf7;
  color: #0f172a;
  position: relative;
  box-shadow: var(--shadow-cert);
  padding: 22px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.035) 0%, transparent 65%),
    repeating-linear-gradient(45deg, rgba(212, 175, 55, 0.015) 0, rgba(212, 175, 55, 0.015) 1px, transparent 0, transparent 40px);
  user-select: none;
}

/* Guilloché Double Gold Border */
.cert-outer-border {
  border: 4px solid #8c620c;
  outline: 2px solid #dfb743;
  outline-offset: 4px;
  width: 100%;
  height: 100%;
  padding: 12px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cert-inner-border {
  border: 1px solid #b8860b;
  width: 100%;
  height: 100%;
  padding: 20px 36px 18px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
}

/* Corner Filigree Accents */
.cert-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: #8c620c;
  pointer-events: none;
}
.cert-corner-tl { top: -2px; left: -2px; border-top: 4px solid #8c620c; border-left: 4px solid #8c620c; }
.cert-corner-tr { top: -2px; right: -2px; border-top: 4px solid #8c620c; border-right: 4px solid #8c620c; }
.cert-corner-bl { bottom: -2px; left: -2px; border-bottom: 4px solid #8c620c; border-left: 4px solid #8c620c; }
.cert-corner-br { bottom: -2px; right: -2px; border-bottom: 4px solid #8c620c; border-right: 4px solid #8c620c; }

/* Tera Air Lembut (Subtle Watermark) */
.cert-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  opacity: 0.045;
  pointer-events: none;
  z-index: 1;
}

/* HEADER: JATA NEGARA TUNGGAL DI ATAS TENGAH (KEKANANAN LOGO KPM) */
.cert-header {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
}

.cert-jata-wrapper {
  margin-bottom: 6px;
  display: flex;
  justify-content: center;
}

.cert-jata-logo {
  height: 76px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.cert-header-text h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #1e3a8a;
  text-transform: uppercase;
}

.cert-header-text h4 {
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #0f172a;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Certificate Title */
.cert-title-section {
  text-align: center;
  margin: 8px 0 4px;
  position: relative;
  z-index: 2;
}

.cert-title-decor-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
  max-width: 500px;
}

.cert-line-side {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, #b8860b, transparent);
}

.cert-title-text {
  font-family: var(--font-cert-title);
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #0a1f44;
  text-shadow: 1px 1px 0px rgba(212, 175, 55, 0.4);
}

.cert-subtitle-text {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #92400e;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Certificate Body Details */
.cert-body-section {
  text-align: center;
  position: relative;
  z-index: 2;
  padding: 0 40px;
}

.cert-pemberitahuan {
  font-family: var(--font-cert-body);
  font-size: 0.95rem;
  color: #475569;
  font-style: italic;
  margin-bottom: 4px;
}

.cert-recipient-name {
  font-family: var(--font-cert-title);
  font-size: 1.85rem;
  font-weight: 800;
  color: #091a36;
  letter-spacing: 0.5px;
  padding: 2px 20px;
  border-bottom: 2px solid #b8860b;
  display: inline-block;
  min-width: 480px;
  margin-bottom: 6px;
}

.cert-recipient-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: #334155;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 6px;
}

.cert-achievement-highlight {
  background: #fefce8;
  border: 1px dashed #b8860b;
  border-radius: 8px;
  padding: 5px 18px;
  display: inline-block;
  margin-bottom: 6px;
}

.cert-achievement-rate {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e3a8a;
}

.cert-citation-paragraph {
  font-family: var(--font-cert-body);
  font-size: 0.92rem;
  color: #1e293b;
  line-height: 1.45;
  max-width: 760px;
  margin: 0 auto;
}

/* Certificate Footer & Signatures */
.cert-footer-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

/* QR Code & Security Block */
.cert-qr-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cert-qr-frame {
  background: #ffffff;
  padding: 5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  width: 66px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-qr-info {
  text-align: left;
}

.cert-qr-info .siri-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: #0f172a;
  font-family: monospace;
}

.cert-qr-info .siri-label {
  font-size: 0.62rem;
  color: #64748b;
  text-transform: uppercase;
}

/* Logo Moto PBT (Pendidikan Besut Terbilang) di bahagian bawah tengah */
.cert-pbt-motto-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 2px;
}

.cert-pbt-motto-img {
  height: 56px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

/* Signature & Officer Block */
.cert-signature-block {
  text-align: center;
  min-width: 240px;
}

.cert-signature-img {
  height: 52px;
  width: auto;
  object-fit: contain;
  margin-bottom: -6px;
}

.cert-officer-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
  border-top: 1px solid #334155;
  padding-top: 4px;
}

.cert-officer-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: #334155;
}

.cert-officer-dept {
  font-size: 0.68rem;
  color: #64748b;
}

/* ==========================================================================
   RANKING & LEADERBOARD TAB (TAB 2 - LIGHT THEME)
   ========================================================================== */
.analysis-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.category-leaderboard-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.category-leaderboard-card h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy-dark);
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.leaderboard-list {
  list-style: none;
  margin-top: 0.85rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: #f8fafc;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.leaderboard-item:hover {
  background: #f0f7ff;
  border-color: #cbd5e1;
  transform: translateX(4px);
}

.leaderboard-rank-pill {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  margin-right: 0.6rem;
}

.rank-1 { background: #fef08a; color: #854d0e; }
.rank-2 { background: #e2e8f0; color: #334155; }
.rank-3 { background: #fed7aa; color: #9a3412; }
.rank-other { background: #f1f5f9; color: #64748b; }

.leaderboard-school-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
}

.leaderboard-rate {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--emerald-success);
}

/* ==========================================================================
   MODAL DIALOGS (ADMIN PANEL & VERIFICATION)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modalFade 0.25s ease;
}

.modal-overlay.active {
  display: flex;
}

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

.modal-dialog {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-xl);
  max-width: 540px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy-dark);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-close-btn {
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: var(--rose-danger);
}

.control-group {
  margin-bottom: 1.15rem;
}

.control-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:focus {
  background: #ffffff;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Verification Result Card */
.verify-result-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.verify-badge-valid {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 30px;
  font-weight: 800;
  font-size: 0.85rem;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  margin-bottom: 0.85rem;
}

/* ==========================================================================
   CUSTOM TOAST ALERTS (LIGHT THEME)
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  width: calc(100% - 3rem);
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  position: relative;
  overflow: hidden;
  border-left: 5px solid;
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

.custom-toast.hide {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(50px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(50px) scale(0.9); }
}

.toast-success { border-left-color: var(--emerald-success); }
.toast-success .toast-icon { color: var(--emerald-success); }

.toast-warning { border-left-color: var(--amber-warning); }
.toast-warning .toast-icon { color: var(--amber-warning); }

.toast-error { border-left-color: var(--rose-danger); }
.toast-error .toast-icon { color: var(--rose-danger); }

.toast-info { border-left-color: var(--blue-accent); }
.toast-info .toast-icon { color: var(--blue-accent); }

.toast-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.4;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px;
  transition: color 0.2s;
}

.toast-close-btn:hover {
  color: var(--text-main);
}

.toast-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #cbd5e1;
  width: 100%;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 768px) {
  .header-container {
    flex-wrap: wrap;
  }
  .brand-text h1 {
    font-size: 1rem;
  }
  .hero-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .period-selectors {
    width: 100%;
    justify-content: space-between;
  }
  .school-banner-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .school-info-right {
    width: 100%;
    justify-content: space-between;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tabs-navigation {
    width: 100%;
  }
  .school-actions-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .toolbar-buttons {
    width: 100%;
  }
  .toolbar-buttons button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .brand-logos .brand-logo-img {
    height: 38px;
  }
  .brand-text .badge-slogan {
    display: none;
  }
  .filter-pills-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
  }
}

/* ==========================================================================
   PRINT SPECIFIC STYLES (@media print)
   Menjamin cetakan terus A4 Landskap tepat tanpa elemen web lain
   ========================================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  body * {
    visibility: hidden;
  }

  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #certificate-preview-container,
  #certificate-preview-container * {
    visibility: visible;
  }

  #certificate-preview-container {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    background: #ffffff !important;
  }

  .certificate-sheet {
    width: 297mm !important;
    height: 210mm !important;
    min-width: 297mm !important;
    min-height: 210mm !important;
    box-shadow: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .main-header,
  .hero-section,
  .stats-grid,
  .tabs-navigation,
  .school-actions-toolbar,
  .school-banner-card,
  #toast-container,
  .modal-overlay {
    display: none !important;
  }
}

/* ==========================================================================
   MODUL PENGISIAN DATA KEHADIRAN (UI/UX DATA ENTRY)
   ========================================================================== */
.data-entry-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.data-entry-header {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.data-entry-title h3 {
  font-size: 1.3rem;
  color: var(--navy-primary);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.data-entry-title p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.data-entry-subnav {
  display: inline-flex;
  background: #e2e8f0;
  padding: 0.3rem;
  border-radius: 30px;
  gap: 0.25rem;
}

.data-subnav-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1.15rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: #475569;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.data-subnav-btn:hover {
  color: var(--navy-primary);
}

.data-subnav-btn.active {
  background: #ffffff;
  color: var(--navy-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.data-entry-subpane {
  display: none;
}

.data-entry-subpane.active {
  display: block;
}

/* Borang 2 Lajur */
.form-dual-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .form-dual-columns {
    grid-template-columns: 1fr;
  }
}

.form-box-main {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

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

@media (max-width: 600px) {
  .form-grid-2cols {
    grid-template-columns: 1fr;
  }
}

.form-box-preview {
  background: linear-gradient(135deg, #0d274c 0%, #173868 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(13, 39, 76, 0.2);
}

.preview-cert-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}

.preview-cert-title {
  font-size: 0.78rem;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.preview-cert-school {
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0.35rem;
  color: #ffffff;
}

.preview-cert-meta {
  font-size: 0.82rem;
  color: #94a3b8;
}

.preview-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
}

.preview-stat-label {
  color: #cbd5e1;
}

.preview-stat-val {
  font-weight: 800;
  color: #ffffff;
}

/* Drag & Drop Import Pukal */
.drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 1.5rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.drop-zone i {
  font-size: 3rem;
  color: #3b82f6;
  margin-bottom: 0.75rem;
}

.drop-zone h4 {
  font-size: 1.1rem;
  color: var(--navy-primary);
  margin-bottom: 0.35rem;
}

.drop-zone p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Jadual Data APDM & Pengurusan */
.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.app-table th {
  background: #f1f5f9;
  color: var(--navy-primary);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.app-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.app-table tr:hover {
  background: #f8fafc;
}

.btn-action-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-edit-sm {
  background: #dbeafe;
  color: #1e40af;
}

.btn-edit-sm:hover {
  background: #bfdbfe;
}

.btn-delete-sm {
  background: #fee2e2;
  color: #991b1b;
}

.btn-delete-sm:hover {
  background: #fecaca;
}

