:root {
  --primary: #10b981;
  --primary-dark: #047857;
  --accent: #f59e0b;
  --bg: #f0fdf4;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  height: 100%;
}

/* Header */
header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  z-index: 40;
  backdrop-filter: blur(5px);
}

.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: var(--text-muted);
}

/* Main */
main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 100px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Components */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
  transition: 0.2s;
  cursor: pointer;
  position: relative;
}

.card:active {
  transform: scale(0.98);
  background: #f9fafb;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pill {
  background: #d1fae5;
  color: #065f46;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 12px;
}

/* Footer Nav (Glass) */
footer {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.nav-item {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
  transition: all 0.3s ease;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: 0.2s;
}

.nav-item span {
  font-size: 10px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(5px);
  transition: all 0.3s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  transform: translateY(-5px);
}

.nav-item.active span {
  opacity: 1;
  transform: translateY(0);
}

/* Toast & Cert */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: rgba(31, 41, 55, 0.95);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  pointer-events: auto;
  animation: slideUp 0.3s ease-out;
  backdrop-filter: blur(5px);
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Utils */
.loading-state {
  text-align: center;
  margin-top: 50px;
  color: var(--text-muted);
}

.spinner {
  font-size: 40px;
  animation: spin 1s infinite linear;
  display: inline-block;
  margin-bottom: 10px;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.strong {
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* --- STARS INTERACTION --- */
.stars {
  display: flex;
  gap: 5px;
}

.stars div {
  transition: transform 0.2s;
}

.stars div:hover {
  transform: scale(1.2);
}

.stars div:active {
  transform: scale(0.9);
}

/* --- ACTION BAR (Sticky Footer) --- */
.action-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid #e5e7eb;
  padding: 15px 20px;
  display: flex;
  gap: 10px;
  z-index: 100;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
  margin-top: 20px;
  /* Separation from content */
}

.btn-report {
  flex: 1;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-report:active {
  transform: scale(0.98);
  background: #e5e7eb;
}

.btn-promote {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* State: Locked (< 90%) */
.btn-disabled {
  background: #e5e7eb;
  color: #9ca3af;
  pointer-events: none;
  opacity: 0.7;
}

/* State: Unlocked (>= 90%) */
.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.02);
  }

  100% {
    transform: scale(1);
  }
}

/* --- CERTIFICATE STYLES (Hidden Wrapper) --- */
#certificate-hidden {
  position: fixed;
  top: -9999px;
  left: -9999px;
  /* A4 Landscape Dimensions */
  width: 1123px;
  height: 794px;
  background: #ffffff;
  color: #1f2937;
  font-family: 'Segoe UI', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cert-frame {
  width: 1000px;
  height: 670px;
  border: 6px double #f59e0b;
  /* Golden Double Border */
  padding: 50px;
  position: relative;
  text-align: center;
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(240, 253, 244, 0.3) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 4px solid #10b981;
}

.tl {
  top: 15px;
  left: 15px;
  border-right: none;
  border-bottom: none;
}

.tr {
  top: 15px;
  right: 15px;
  border-left: none;
  border-bottom: none;
}

.bl {
  bottom: 15px;
  left: 15px;
  border-right: none;
  border-top: none;
}

.br {
  bottom: 15px;
  right: 15px;
  border-left: none;
  border-top: none;
}

.cert-logo {
  width: 100px;
  margin-bottom: 15px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.1));
}

.cert-academy {
  font-size: 18px;
  font-weight: 800;
  color: #047857;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.cert-title {
  font-family: 'Times New Roman', serif;
  font-size: 58px;
  font-weight: bold;
  color: #f59e0b;
  margin: 0;
  line-height: 1;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.05);
}

.cert-subtitle {
  font-size: 22px;
  color: #6b7280;
  margin-top: 10px;
  letter-spacing: 1px;
}

.cert-name {
  font-size: 65px;
  font-weight: 900;
  color: #10b981;
  margin: 20px 0;
  padding: 5px 60px;
  border-bottom: 3px solid #e5e7eb;
  display: inline-block;
}

.cert-text {
  font-size: 26px;
  color: #4b5563;
}

.cert-level {
  font-size: 48px;
  font-weight: 800;
  color: #f59e0b;
  margin-top: 10px;
  text-transform: uppercase;
}

.cert-footer {
  margin-top: auto;
  width: 80%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 20px;
}

.sig-line {
  width: 250px;
  border-top: 2px solid #374151;
  margin-bottom: 10px;
}

.sig-label {
  font-size: 18px;
  font-weight: bold;
  color: #374151;
  text-transform: uppercase;
}

/* --- MODAL SYSTEM --- */
/* Ensure Modal is ALWAYS on top */
.modal-overlay {
  z-index: 99999 !important;
  background: rgba(0, 0, 0, 0.9);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 20px;
}

.modal-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.modal-header {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: space-between;
  color: white;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 30px;
  cursor: pointer;
}

/* --- A4 SIMULATION --- */
.a4-paper {
  background: white;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.preview-center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

/* --- BUTTONS --- */
.btn-download {
  background: #10b981;
  color: white;
  border: none;
  padding: 15px 50px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
}

/* --- REALISTIC SIGNATURE (INK BLACK) --- */
.signature-text {
  font-family: 'Great Vibes', cursive;
  font-size: 45px;
  color: #000000;
  /* Pure Black Ink */
  margin-bottom: -15px;
  transform: rotate(-10deg);
  display: inline-block;
  text-shadow: 0.5px 0.5px 0px rgba(0, 0, 0, 0.1);
}

/* --- FILTER PILLS --- */
.filter-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 5px;
  margin-bottom: 15px;
  scrollbar-width: none;
  /* Hide scrollbar */
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  flex-shrink: 0;
}

.filter-pill.active {
  background: #10b981;
  color: white;
  border-color: #10b981;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}