/* Design System Tokens */
:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Color Palette - HSL Slate/Violet/Emerald/Rose */
  --bg-app: hsl(222, 47%, 6%);
  --bg-card: hsla(217, 33%, 12%, 0.7);
  --bg-card-hover: hsla(217, 33%, 16%, 0.8);
  --border-card: hsla(217, 20%, 25%, 0.4);
  --border-accent: hsla(250, 100%, 75%, 0.2);

  --text-primary: hsl(210, 40%, 96%);
  --text-secondary: hsl(215, 20%, 65%);
  --text-muted: hsl(215, 12%, 45%);

  --primary: hsl(250, 95%, 70%);
  --primary-glow: hsla(250, 95%, 70%, 0.35);
  --primary-hover: hsl(250, 95%, 76%);
  
  --secondary: hsl(217, 20%, 20%);
  --secondary-hover: hsl(217, 20%, 28%);

  --emerald: hsl(150, 86%, 43%);
  --emerald-glow: hsla(150, 86%, 43%, 0.25);
  --emerald-bg: hsla(150, 86%, 10%, 0.3);

  --rose: hsl(346, 84%, 61%);
  --rose-glow: hsla(346, 84%, 61%, 0.25);
  --rose-bg: hsla(346, 84%, 10%, 0.3);

  --yellow: hsl(40, 95%, 60%);
  --yellow-bg: hsla(40, 95%, 10%, 0.3);

  --red: hsl(0, 85%, 60%);
  --red-bg: hsla(0, 85%, 10%, 0.3);

  --gray: hsl(215, 12%, 55%);
  --gray-bg: hsla(215, 12%, 20%, 0.3);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, hsla(253, 80%, 12%, 0.35) 0px, transparent 50%),
    radial-gradient(at 100% 100%, hsla(220, 80%, 10%, 0.3) 0px, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Critical Warning Banner */
.critical-banner {
  background: linear-gradient(90deg, hsl(346, 84%, 35%), hsl(346, 84%, 48%));
  border-bottom: 2px solid var(--rose);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: slideDown 0.4s ease-out;
}

.critical-banner.hidden {
  display: none !important;
}

.banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.pulse-icon {
  font-size: 1.3rem;
  animation: pulseGlow 1.5s infinite;
}

.banner-text {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  color: #fff;
}

/* App Container */
.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 20px 60px 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-glow {
  position: absolute;
  width: 50px;
  height: 50px;
  background: var(--primary);
  filter: blur(35px);
  border-radius: 50%;
  left: -10px;
  z-index: -1;
  opacity: 0.6;
}

.brand h1 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand h1 span {
  background: linear-gradient(135deg, var(--primary), hsl(190, 90%, 65%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.year-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Buttons */
.btn {
  font-family: var(--font-heading);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: hsl(222, 47%, 4%);
  box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 28px var(--primary-glow);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header {
  padding: 24px 24px 16px 24px;
}

.card-header h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.card-body {
  padding: 24px;
}

.card-body.no-padding {
  padding: 0;
}

/* Dashboard Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.col-span-2 {
  grid-column: span 2;
}

/* Profile Card Specifics */
.student-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-item label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.info-value {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.info-value.accent {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 800;
}

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

.registered-status-section h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.registered-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.registered-item:last-child {
  margin-bottom: 0;
}

.reg-school-details h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.reg-school-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reg-badge-rank {
  background: var(--emerald-bg);
  border: 1px solid var(--emerald);
  color: var(--emerald);
  font-family: var(--font-heading);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 1rem;
}

.reg-badge-rank.kritis {
  background: var(--rose-bg);
  border: 1px solid var(--rose);
  color: var(--rose);
}

.reg-badge-rank.rawan {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow);
  color: var(--yellow);
}

.reg-badge-rank.bahaya {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
}

.reg-badge-rank.tereliminasi {
  background: var(--gray-bg);
  border: 1px solid var(--gray);
  color: var(--gray);
}

/* Radar Visual and Scan Card */
.scan-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.scan-body {
  display: flex;
  align-items: center;
  gap: 30px;
  height: 100%;
}

.scan-visual {
  flex-shrink: 0;
}

.radar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 1px solid hsla(250, 95%, 70%, 0.15);
  position: relative;
  background: radial-gradient(circle, hsla(250, 95%, 70%, 0.02) 20%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar::before {
  content: '';
  width: 90px;
  height: 90px;
  border: 1px solid hsla(250, 95%, 70%, 0.1);
  border-radius: 50%;
  position: absolute;
}

.radar::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 1px solid hsla(250, 95%, 70%, 0.05);
  border-radius: 50%;
  position: absolute;
}

.radar-sweep {
  width: 50%;
  height: 50%;
  background: linear-gradient(45deg, transparent 50%, var(--primary-glow) 100%);
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: bottom right;
  border-radius: 100% 0 0 0;
  animation: sweep 4s linear infinite;
}

.radar-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--primary);
  position: absolute;
  top: 40px;
  right: 45px;
  animation: pulseGlow 1.5s infinite;
}

.scan-details {
  flex-grow: 1;
}

.scan-details h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.scan-details p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.scan-meta {
  margin-bottom: 20px;
}

.meta-item {
  font-size: 0.85rem;
  display: flex;
  gap: 8px;
}

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

.meta-val {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Recommendations Card Table */
.flex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-card);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.table-actions {
  display: flex;
  gap: 12px;
}

.legend-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.legend-badge.aman {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid hsla(150, 86%, 43%, 0.2);
}

.legend-badge.rawan {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid hsla(40, 95%, 60%, 0.2);
}

.legend-badge.bahaya {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid hsla(0, 85%, 60%, 0.2);
}

.legend-badge.tereliminasi {
  background: var(--gray-bg);
  color: var(--gray);
  border: 1px solid hsla(215, 12%, 55%, 0.2);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-card);
}

.data-table td {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
}

.data-table tbody tr {
  transition: var(--transition-smooth);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.school-name-cell {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
}

.school-npsn {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 400;
  margin-top: 2px;
}

.jurusan-cell {
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

.badge-status {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
}

.badge-status.aman {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid hsla(150, 86%, 43%, 0.3);
}

.badge-status.rawan {
  background: var(--yellow-bg);
  color: var(--yellow);
  border: 1px solid hsla(40, 95%, 60%, 0.3);
}

.badge-status.bahaya {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid hsla(0, 85%, 60%, 0.3);
}

.badge-status.tereliminasi {
  background: var(--gray-bg);
  color: var(--gray);
  border: 1px solid hsla(215, 12%, 55%, 0.3);
}

.badge-status.registered {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid hsla(250, 95%, 70%, 0.3);
}

.margin-val {
  font-family: var(--font-heading);
  font-weight: 700;
}

.margin-val.aman {
  color: var(--emerald);
}

.margin-val.rawan {
  color: var(--yellow);
}

.margin-val.bahaya {
  color: var(--red);
}

.margin-val.tereliminasi {
  color: var(--gray);
}

/* Scan Status Badge Header */
.scan-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
}

.scan-status-badge.success {
  border-color: hsla(150, 86%, 43%, 0.3);
  color: var(--emerald);
}

.scan-status-badge.failed {
  border-color: hsla(346, 84%, 61%, 0.3);
  color: var(--rose);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.success .status-dot {
  background-color: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.failed .status-dot {
  background-color: var(--rose);
  box-shadow: 0 0 8px var(--rose);
}

.never-scanned .status-dot {
  background-color: var(--yellow);
  box-shadow: 0 0 8px var(--yellow);
}

/* Modals & Backdrop */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 20, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 1;
  transition: var(--transition-smooth);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal-card {
  transform: scale(0.9);
}

.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}

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

.modal-body {
  padding: 30px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: span 2;
}

label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

input, select, textarea {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  background: rgba(0, 0, 0, 0.4);
}

.input-help {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.block-help {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 10px;
}

.block-help ol {
  padding-left: 20px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.block-help a {
  color: var(--primary);
  text-decoration: none;
}

.block-help a:hover {
  text-decoration: underline;
}

.badge-warning {
  background: var(--yellow-bg);
  border: 1px solid var(--yellow);
  color: var(--yellow);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 30px;
}

/* Loading Spinners */
.loader {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top: 2px solid #000;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

.loader.hidden {
  display: none !important;
}

.loading-placeholder {
  animation: shimmer 1.5s infinite linear;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  color: transparent !important;
  border-radius: 4px;
}

/* Empty states */
.table-empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
}

.no-data-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Animations */
@keyframes sweep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes modalScaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.search-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  width: 240px;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  background: rgba(0, 0, 0, 0.4);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Media Queries */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .col-span-2 {
    grid-column: span 1;
  }
  .scan-body {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .flex-header {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  .table-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }
  .search-input {
    width: 100%;
  }
  .table-actions .legend-badge {
    text-align: center;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    gap: 20px;
    align-items: center;
    text-align: center;
  }
  .header-actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }
  .scan-status-badge {
    width: 100%;
    justify-content: center;
  }
  #btn-settings {
    width: 100%;
  }
  .student-info-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  .registered-item {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    text-align: center;
  }
  .reg-badge-rank {
    width: 100%;
    text-align: center;
  }
  .modal-card {
    width: 95%;
    max-height: 95vh;
  }
  .modal-body {
    padding: 20px;
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal-footer button {
    width: 100%;
    margin-right: 0 !important;
  }
  #btn-test-telegram {
    margin-right: 0 !important;
    border-color: var(--primary);
  }
  
  /* Scroll indicator helper for table */
  .table-responsive {
    position: relative;
  }
  .table-responsive::after {
    content: 'Geser horizontal untuk detail →';
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 10px;
    font-style: italic;
    background: rgba(0, 0, 0, 0.1);
  }
}

