/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:        #0d0f1a;
  --bg-card:        rgba(255,255,255,0.04);
  --bg-card-hover:  rgba(255,255,255,0.07);
  --border:         rgba(255,255,255,0.10);
  --border-focus:   #6366f1;

  --accent1: #6366f1;   /* indigo */
  --accent2: #8b5cf6;   /* violet */
  --accent3: #06b6d4;   /* cyan   */

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  --success: #10b981;
  --danger:  #ef4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 8px 40px rgba(0,0,0,0.45);
  --shadow-btn:  0 4px 20px rgba(99,102,241,0.4);

  --font-body:    'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ============================================================
   BACKGROUND ORBS
   ============================================================ */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 12s ease-in-out infinite alternate;
}
.orb1 { width: 600px; height: 600px; background: var(--accent1); top: -150px; left: -200px; }
.orb2 { width: 500px; height: 500px; background: var(--accent2); top: 40%; right: -150px; animation-delay: 3s; }
.orb3 { width: 400px; height: 400px; background: var(--accent3); bottom: -100px; left: 30%; animation-delay: 6s; }

@keyframes orbFloat {
  from { transform: translateY(0) scale(1); }
  to   { transform: translateY(40px) scale(1.08); }
}

/* ============================================================
   APP WRAPPER
   ============================================================ */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 2.5rem;
  animation: fadeDown 0.6s ease both;
}
.header-icon {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 0 18px rgba(99,102,241,0.7));
}
.header-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  background: linear-gradient(135deg, #e0e7ff 0%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.header-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ============================================================
   FORM CARD
   ============================================================ */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.2rem 2rem;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  animation: fadeUp 0.65s ease both;
  animation-delay: 0.1s;
}
.form-card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   FORM GRID
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.label-hint {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

/* Inputs & Select */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: #141626;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.93rem;
  padding: 0.72rem 1rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  color-scheme: dark;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }

/* Dark dropdown options */
.form-select option {
  background: #1a1d2e;
  color: var(--text-primary);
  padding: 6px;
}
.form-select optgroup {
  background: #0d0f1a;
  color: var(--accent3);
  font-weight: 700;
  font-style: normal;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent1);
  background: rgba(99,102,241,0.08);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}

.form-textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.7;
}

/* Select wrapper */
.select-wrapper { position: relative; }
.select-wrapper .form-select { appearance: none; cursor: pointer; padding-right: 2.5rem; }
.select-arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Textarea footer */
.textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.count-badge {
  background: rgba(99,102,241,0.18);
  color: #a5b4fc;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.8rem;
  border: 1px solid rgba(99,102,241,0.3);
}
.textarea-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.8rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  letter-spacing: 0.02em;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(99,102,241,0.55); }
.btn-primary:active { transform: translateY(0); }
.btn-icon { font-size: 1.1rem; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.07);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.48rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: rgba(255,255,255,0.13); color: var(--text-primary); border-color: rgba(255,255,255,0.22); }
.btn-secondary.danger:hover { background: rgba(239,68,68,0.14); color: #fca5a5; border-color: rgba(239,68,68,0.35); }

.form-footer { display: flex; justify-content: flex-end; margin-top: 2rem; }

/* ============================================================
   PREVIEW SECTION
   ============================================================ */
.preview-section {
  margin-top: 2.5rem;
  animation: fadeUp 0.6s ease both;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.preview-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
}
.toolbar-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

/* Print container */
.print-container {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.print-page {
  padding: 2.8rem 3rem;
  font-family: 'Times New Roman', Times, serif;
  color: #000;
}

/* Document header */
.doc-header {
  text-align: center;
  margin-bottom: 1.6rem;
  border-bottom: 3px double #000;
  padding-bottom: 1.2rem;
}
.doc-title {
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.5;
}
.doc-school {
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.5;
}
.doc-kelas {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.5;
}

/* Receipt Table */
.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.receipt-table th {
  background: #d0d7e8;
  border: 1.5px solid #333;
  padding: 7px 8px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.receipt-table td {
  border: 1px solid #555;
  padding: 0 8px;
  height: 25px;
  vertical-align: middle;
}
.receipt-table th {
  height: 25px;
  vertical-align: middle;
}
.col-no    { width: 1%; white-space: nowrap; text-align: center; }
.col-nama  { width: 1%; white-space: nowrap; }
.col-penerima { width: 50%; }
.col-ttd   { width: 48%; }

.receipt-table tbody tr:nth-child(even) td { background: #f7f8fc; }
.receipt-table tbody tr:hover td { background: #eef0fb; }

.td-no       { text-align: center; font-weight: 700; white-space: nowrap; }
.td-nama     { font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.td-penerima { }
.td-ttd      { color: #333; font-size: 11px; vertical-align: middle; font-weight: 700; }
.td-ttd strong { display: inline-block; width: 50%; }
.td-ttd-odd strong  { text-align: left;  padding-left:  8px; }
.td-ttd-even strong { text-align: right; padding-right: 8px; }

/* Document footer — centered block, left-aligned text */
.doc-footer {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  font-size: 13px;
}
.signature-block {
  text-align: left;
  min-width: 200px;
  line-height: 1.9;
}
.doc-city        { font-size: 13px; }
.doc-wali-label  { font-size: 13px; }
.signature-space { height: 72px; }
/* border-bottom instead of text-decoration — fixes comma gap */
.doc-wali-name {
  font-weight: 900;
  font-size: 14px;
  display: inline-block;
  border-bottom: 2px solid #000;
  padding-bottom: 1px;
  line-height: 1.4;
}
.doc-nip { font-size: 12px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  padding: 0.85rem 2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(99,102,241,0.45);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PRINT MEDIA — Folio F4 (21cm × 33cm) — 1 HALAMAN MAKS 34 SISWA
   Menggunakan zoom:0.80 (mempengaruhi layout, bukan hanya visual)
   ============================================================ */
@media print {
  @page {
    size: 21cm 33cm;
    margin: 1.2cm 1cm;
    /* area pakai: 19cm × 30.6cm */
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
  }

  /* ── Sembunyikan semua elemen UI ── */
  .bg-orb, .app-header, .form-card,
  .preview-toolbar, .toast {
    display: none !important;
  }

  /* ── Reset wrapper & section ── */
  .app-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .preview-section {
    display: block !important;
    margin: 0 !important;
    animation: none !important;
  }
  .print-container {
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  /*
   * zoom: 0.72 — kunci utama 1 halaman.
   * Konten akan diperkecil sehingga tinggi total aman dalam 1 halaman.
   */
  .print-page {
    padding: 0 !important;
    color: #000 !important;
    zoom: 0.95;
    page-break-inside: avoid;
    break-inside:   avoid;
  }

  /* ── Header judul ── */
  .doc-header {
    border-bottom: 3px double #000 !important;
    margin-bottom: 8px !important;
    padding-bottom: 8px !important;
  }
  .doc-title  { font-size: 14px !important; line-height: 1.4 !important; }
  .doc-school { font-size: 14px !important; line-height: 1.4 !important; }
  .doc-kelas  { font-size: 13px !important; line-height: 1.4 !important; }

  /* ── Tabel ── */
  .receipt-table {
    width: 100% !important;
    font-size: 11px !important;
    border-collapse: collapse !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .receipt-table thead { display: table-header-group; }
  .receipt-table th {
    height: 25px !important;
    padding: 0 6px !important;
    font-size: 10px !important;
    letter-spacing: 0.03em !important;
    background: #d0d7e8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    vertical-align: middle !important;
  }
  .receipt-table td {
    height: 25px !important;
    padding: 0 6px !important;
    border: 0.8px solid #555 !important;
    font-size: 11px !important;
    vertical-align: middle !important;
  }
  .td-no   { font-weight: 700 !important; text-align: center !important; white-space: nowrap !important; }
  .td-nama { font-size: 11px !important; font-weight: 700 !important; white-space: nowrap !important; }
  .receipt-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .receipt-table tbody tr:hover td { background: transparent !important; }
  .receipt-table tbody tr:nth-child(even) td {
    background: #f4f5fb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Nomor TTD: zigzag menggunakan display inline-block width 50% ── */
  .td-ttd { font-size: 11px !important; font-weight: 700 !important; vertical-align: middle !important; }
  .td-ttd strong { display: inline-block !important; width: 50% !important; }
  .td-ttd-odd strong  { text-align: left !important; padding-left: 6px !important; }
  .td-ttd-even strong { text-align: right !important; padding-right: 6px !important; }

  /* ── Footer tanda tangan ── */
  .doc-footer {
    margin-top: 10px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .signature-block {
    line-height: 1.6 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .doc-city       { font-size: 12px !important; }
  .doc-wali-label { font-size: 12px !important; }
  .signature-space { height: 55px !important; }
  .doc-wali-name  {
    font-size: 13px !important;
    border-bottom: 1.5px solid #000 !important;
  }
  .doc-nip { font-size: 11px !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .app-wrapper { padding: 1.2rem 0.9rem 3rem; }
  .form-card   { padding: 1.4rem 1.1rem; }
  .print-page  { padding: 1.2rem 1rem; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn-primary,
  .toolbar-actions .btn-secondary { flex: 1; justify-content: center; }
}
