/* ==========================================================================
   APLIKASI MODUL AJAR & RPP KURIKULUM MERDEKA - SMA PLUS AL-HIDAYAH CILAWU
   Global, Thematic Cover & High-Fidelity Print Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800;900&family=Cinzel:wght@600;700;800;900&family=Merriweather:wght@300;400;700;900&display=swap');

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --secondary: #059669;
  --accent: #f59e0b;
  --dark: #0f172a;
  --light-bg: #f8fafc;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1e293b;
  background-color: #f1f5f9;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Signature Canvas */
.signature-pad-canvas {
  touch-action: none;
  background-color: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 0.75rem;
  cursor: crosshair;
}

/* Kop Surat Styling */
.kop-surat {
  border-bottom: 3px double #000;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.kop-logo {
  width: 75px;
  height: auto;
  object-fit: contain;
}

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

.animate-fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Badge QR Verification */
.qr-seal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Cover A4 Screen Card Preview */
.cover-a4-preview {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1.414; /* A4 Ratio */
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1rem;
}

/* Print Only & Screen Only Logic */
.print-only {
  display: none !important;
}

/* ==========================================================================
   THEMATIC COVER PALETTES (SCREEN & PRINT COMPATIBLE)
   ========================================================================== */

/* 1. Emerald Nature (Biologi & Sains) */
.cover-theme-emerald {
  background: linear-gradient(145deg, #022c22 0%, #064e3b 35%, #047857 70%, #0f766e 100%) !important;
  color: #ffffff !important;
  --cover-accent: #34d399;
  --cover-badge-bg: rgba(16, 185, 129, 0.25);
  --cover-badge-border: rgba(52, 211, 153, 0.45);
  --cover-border-color: #059669;
}

/* 2. Ocean Cyan (Informatika & Bahasa) */
.cover-theme-sky {
  background: linear-gradient(145deg, #082f49 0%, #0c4a6e 35%, #0369a1 70%, #0284c7 100%) !important;
  color: #ffffff !important;
  --cover-accent: #38bdf8;
  --cover-badge-bg: rgba(14, 165, 233, 0.25);
  --cover-badge-border: rgba(56, 189, 248, 0.45);
  --cover-border-color: #0284c7;
}

/* 3. Royal Indigo (Matematika & Fisika) */
.cover-theme-indigo {
  background: linear-gradient(145deg, #1e1b4b 0%, #2e1065 35%, #3730a3 70%, #4f46e5 100%) !important;
  color: #ffffff !important;
  --cover-accent: #818cf8;
  --cover-badge-bg: rgba(99, 102, 241, 0.25);
  --cover-badge-border: rgba(129, 140, 248, 0.45);
  --cover-border-color: #4f46e5;
}

/* 4. Crimson Ruby (IPS, Sejarah & Pancasila) */
.cover-theme-crimson {
  background: linear-gradient(145deg, #4c0519 0%, #701a75 35%, #9f1239 70%, #e11d48 100%) !important;
  color: #ffffff !important;
  --cover-accent: #fb7185;
  --cover-badge-bg: rgba(244, 63, 94, 0.25);
  --cover-badge-border: rgba(251, 113, 133, 0.45);
  --cover-border-color: #e11d48;
}

/* 5. Golden Amber (PAI, Seni Budaya & PKWU) */
.cover-theme-amber {
  background: linear-gradient(145deg, #451a03 0%, #713f12 35%, #92400e 70%, #b45309 100%) !important;
  color: #ffffff !important;
  --cover-accent: #fbbf24;
  --cover-badge-bg: rgba(245, 158, 11, 0.25);
  --cover-badge-border: rgba(251, 191, 36, 0.45);
  --cover-border-color: #d97706;
}

/* 6. Midnight Sapphire (Akademik & Manajerial) */
.cover-theme-sapphire {
  background: linear-gradient(145deg, #020617 0%, #0f172a 35%, #1e293b 70%, #1e3a8a 100%) !important;
  color: #ffffff !important;
  --cover-accent: #60a5fa;
  --cover-badge-bg: rgba(59, 130, 246, 0.25);
  --cover-badge-border: rgba(96, 165, 250, 0.45);
  --cover-border-color: #3b82f6;
}

/* 7. Classic Islamic Slate (Formal Al-Hidayah) */
.cover-theme-classic {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 40%, #047857 85%, #065f46 100%) !important;
  color: #ffffff !important;
  --cover-accent: #facc15;
  --cover-badge-bg: rgba(250, 204, 21, 0.2);
  --cover-badge-border: rgba(250, 204, 21, 0.4);
  --cover-border-color: #eab308;
}

/* ==========================================================================
   PRINT MEDIA STYLES (A4 Document Export & High-Fidelity Hardcopy)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 0; /* Full bleed control */
  }

  html, body {
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    overflow: visible !important;
    display: block !important;
    position: static !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Hide screen elements */
  .no-print,
  #sidebar,
  #topbar,
  .btn,
  .toast-container,
  nav,
  aside,
  header,
  section,
  #main-content > section,
  #view-portal-gateway,
  #modal-user-form,
  #modal-create-tugas,
  #modal-kerjakan-tugas,
  #modal-nilai-submission,
  #modal-modul-detail,
  #modal-signature,
  #modal-print-options,
  #modal-cover-editor {
    display: none !important;
  }

  /* Show only the print area */
  .print-only,
  #print-area {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }

  /* Page Break Utilities */
  .page-break {
    page-break-before: always !important;
    break-before: page !important;
  }

  .page-break-after {
    page-break-after: always !important;
    break-after: page !important;
  }

  .avoid-break {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Document Body Page (A4 with 15mm Margins) */
  .print-content-page {
    width: 210mm !important;
    min-height: 297mm !important;
    box-sizing: border-box !important;
    padding: 15mm 15mm 15mm 15mm !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Times New Roman', Times, serif !important;
    font-size: 10.5pt !important;
    line-height: 1.4 !important;
    page-break-after: always !important;
    break-after: page !important;
  }

  /* ========================================================================
     FULL COLOR PRINT COVER (Exact A4 210mm x 297mm)
     ======================================================================== */
  .print-cover-page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    padding: 18mm 16mm 16mm 16mm !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    text-align: center !important;
    position: relative !important;
    overflow: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
  }

  /* Document Table Styles */
  .doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
    margin-bottom: 10px;
    font-family: 'Times New Roman', Times, serif !important;
  }

  .doc-table th,
  .doc-table td {
    border: 1px solid #000;
    padding: 5px 8px;
    font-size: 9.5pt;
    text-align: left;
    vertical-align: top;
  }

  .doc-table th {
    background-color: #f2f2f2 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-weight: bold;
  }

  /* Kop Surat Print */
  .kop-surat-print {
    border-bottom: 3px double #000;
    padding-bottom: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
  }

  .kop-surat-print .kop-logo {
    width: 75px;
    height: auto;
  }

  .kop-surat-print .kop-text {
    flex: 1;
    text-align: center;
  }

  .kop-surat-print .kop-text h2 {
    font-size: 11pt;
    font-weight: bold;
    margin: 0;
    text-transform: uppercase;
  }

  .kop-surat-print .kop-text h1 {
    font-size: 14pt;
    font-weight: 800;
    margin: 2px 0;
    color: #000;
  }

  .kop-surat-print .kop-text p {
    font-size: 8pt;
    margin: 0;
    line-height: 1.25;
  }

  /* Signature Layout in Print */
  .signature-grid {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .signature-box {
    width: 45%;
    text-align: center;
    font-size: 10pt;
  }

  .signature-img {
    height: 65px;
    object-fit: contain;
    margin: 4px auto;
    display: block;
  }

  .qr-code-img {
    width: 75px;
    height: 75px;
    margin: 4px auto;
    display: block;
  }
}
