/* ============================================================
   e-Rapor PAUD — Dokumentasi Sistem
   Style & Print CSS
   ============================================================ */

:root {
  --primary: #1f594f;
  --primary-light: #2d7a6a;
  --primary-dark: #143b34;
  --accent: #d4a853;
  --bg: #f8faf8;
  --bg-card: #ffffff;
  --text: #24332f;
  --text-secondary: #5a726b;
  --text-muted: #87948f;
  --border: #e2e8e6;
  --sidebar-bg: #143b34;
  --sidebar-text: #c7ddd6;
  --success: #1f9d5a;
  --warning: #d4a853;
  --danger: #d94a4a;
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.doc-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.doc-sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.doc-sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.doc-sidebar-header p {
  font-size: 0.75rem;
  color: var(--sidebar-text);
  margin-top: 0.25rem;
  opacity: 0.7;
}

.doc-sidebar-nav { padding: 0.75rem 0; flex: 1; }

.doc-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.doc-sidebar-nav a:hover,
.doc-sidebar-nav a.active {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-left-color: var(--accent);
}

.doc-sidebar-nav a .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 0.65rem;
  font-weight: 600;
  flex-shrink: 0;
}

.doc-sidebar-nav a:hover .num,
.doc-sidebar-nav a.active .num {
  background: var(--accent);
  color: var(--primary-dark);
}

.doc-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ============ MAIN CONTENT ============ */
.doc-main {
  margin-left: 260px;
  flex: 1;
  max-width: 100%;
  padding: 0;
}

.doc-cover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: #fff;
  padding: 4rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.doc-cover::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
}

.doc-cover .logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.doc-cover h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.doc-cover .subtitle {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 2rem;
}

.doc-cover .meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  opacity: 0.7;
}

.doc-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ============ TOC ============ */
.doc-toc { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; margin-bottom: 2.5rem; }

.doc-toc h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--primary); }

.doc-toc ol { list-style: none; counter-reset: toc; }

.doc-toc ol li { counter-increment: toc; margin-bottom: 0.4rem; }

.doc-toc ol li::before {
  content: counter(toc) ".";
  display: inline-block;
  width: 1.8rem;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
}

.doc-toc ol li a {
  color: var(--primary-light);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.doc-toc ol li a:hover { border-bottom-color: var(--primary-light); }

/* ============ BAB / SECTION ============ */
.doc-section {
  margin-bottom: 3rem;
  padding-top: 1rem;
}

.doc-section .anchor { display: block; position: relative; top: -80px; visibility: hidden; }

.doc-section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-section h2 .badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  background: var(--accent);
  color: var(--primary-dark);
}

.doc-section h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary);
  margin: 1.5rem 0 0.75rem;
}

.doc-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.5rem;
}

.doc-section p, .doc-section li { font-size: 0.92rem; line-height: 1.8; color: var(--text-secondary); }

.doc-section p { margin-bottom: 0.75rem; }

.doc-section ul, .doc-section ol { padding-left: 1.5rem; margin-bottom: 1rem; }

.doc-section li { margin-bottom: 0.3rem; }

.doc-section strong { color: var(--text); }

.doc-section a { color: var(--primary-light); }

/* ============ TIPS / NOTES ============ */
.doc-note, .doc-tip, .doc-warning {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  margin: 1rem 0;
  font-size: 0.88rem;
  border-left: 4px solid;
}

.doc-note { background: #eef6f3; border-left-color: var(--primary); }

.doc-tip { background: #fef9ee; border-left-color: var(--accent); }

.doc-warning { background: #fdeeee; border-left-color: var(--danger); }

.doc-note strong, .doc-tip strong, .doc-warning strong { display: block; margin-bottom: 0.25rem; }

/* ============ TABLES ============ */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.85rem;
}

.doc-table th, .doc-table td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.doc-table th { background: var(--primary); color: #fff; font-weight: 600; font-size: 0.82rem; }

.doc-table td { background: var(--bg-card); }

.doc-table tr:nth-child(even) td { background: var(--bg); }

.doc-table .col-yes { color: var(--success); font-weight: 600; }
.doc-table .col-no { color: var(--danger); }

/* ============ COMPARISON TABLE ============ */
.doc-table-comparison th:first-child,
.doc-table-comparison td:first-child { width: 28%; font-weight: 600; color: var(--text); }

/* ============ STEP LIST ============ */
.doc-steps { list-style: none; counter-reset: step; padding-left: 0 !important; }

.doc-steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.8rem;
  margin-bottom: 1.25rem;
  min-height: 2rem;
}

.doc-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-steps li strong { display: block; margin-bottom: 0.15rem; }

/* ============ SCREENSHOT PLACEHOLDER ============ */
.doc-screenshot {
  margin: 1.25rem 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.doc-screenshot .placeholder {
  background: linear-gradient(135deg, #e8efe8 0%, #d5e2d5 100%);
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.5rem;
}

.doc-screenshot .placeholder .icon { font-size: 2rem; opacity: 0.5; }
.doc-screenshot .placeholder .label { font-size: 0.8rem; font-weight: 500; }
.doc-screenshot .placeholder .hint { font-size: 0.7rem; opacity: 0.5; }

.doc-screenshot .caption {
  padding: 0.6rem 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ============ CODE ============ */
.doc-code {
  background: #1a2b26;
  color: #d4e8df;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 1rem 0;
  white-space: pre-wrap;
}

.doc-code-inline {
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* ============ VERSION TABS / BADGES ============ */
.doc-version-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.doc-version-tab {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.doc-version-tab.active,
.doc-version-tab:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.doc-version-content { display: none; }
.doc-version-content.active { display: block; }

.doc-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.doc-badge-win { background: #e8f0fe; color: #1967d2; }
.doc-badge-host { background: #fef7e0; color: #e37400; }

/* ============ GALLERY ============ */
.doc-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

/* ============ FOOTER ============ */
.doc-footer {
  margin-top: 3rem;
  padding: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.doc-footer strong { color: var(--text-secondary); }

/* ============ MOBILE SIDEBAR TOGGLE ============ */
.doc-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .doc-sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .doc-sidebar.open { transform: translateX(0); }
  .doc-main { margin-left: 0; }
  .doc-toggle { display: flex; }
  .doc-cover { padding: 2.5rem 1.5rem; }
  .doc-cover h1 { font-size: 1.6rem; }
  .doc-container { padding: 1.5rem 1rem; }
  .doc-table { font-size: 0.8rem; }
  .doc-table th, .doc-table td { padding: 0.4rem 0.5rem; }
  .doc-screenshot .placeholder { height: 140px; }
}

@media (max-width: 480px) {
  .doc-cover .meta { flex-direction: column; gap: 0.5rem; }
  .doc-cover { padding: 2rem 1rem; }
}

/* ============================================================
   PRINT STYLING — untuk output PDF via browser
   ============================================================ */
@media print {
  @page {
    size: A4;
    margin: 1.5cm 2cm 1.5cm 2cm;
  }

  @page :first {
    margin: 0;
  }

  body { background: #fff; display: block; }

  .doc-sidebar { display: none !important; }
  .doc-toggle { display: none !important; }
  .doc-main { margin-left: 0 !important; max-width: 100% !important; }

  .doc-cover {
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #143b34 0%, #1f594f 50%, #2d7a6a 100%) !important;
  }

  .doc-cover::before { display: none; }
  .doc-cover .logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-cover h1 { font-size: 24pt; }
  .doc-cover .subtitle { font-size: 12pt; }

  .doc-container { max-width: 100%; padding: 0; }

  .doc-section { page-break-inside: avoid; }
  .doc-section h2 { page-break-after: avoid; }
  .doc-section h3 { page-break-after: avoid; }

  .doc-table { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-table th { background: #1f594f !important; color: #fff !important; }
  .doc-table tr:nth-child(even) td { background: #f8faf8 !important; }

  .doc-screenshot { page-break-inside: avoid; }
  .doc-screenshot .placeholder { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-screenshot .placeholder { background: #e8efe8 !important; }

  .doc-note, .doc-tip, .doc-warning { page-break-inside: avoid; }
  .doc-note { background: #eef6f3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-tip { background: #fef9ee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-warning { background: #fdeeee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .doc-code { background: #1a2b26 !important; color: #d4e8df !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; page-break-inside: avoid; }

  .doc-toc { page-break-after: always; }

  .doc-steps li::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .doc-footer { page-break-after: always; }

  a { color: #1f594f !important; text-decoration: none !important; }

  .no-print { display: none !important; }

  .doc-section .anchor { top: 0; visibility: visible; display: none; }

  /* Avoid orphan lines */
  p, li { orphans: 3; widows: 3; }

  img { max-width: 100% !important; page-break-inside: avoid; }
}
