/* ==========================================================================
   Bantukerjain.com — Organisir & Susun Halaman PDF (Client-Side Interactive)
   Standar Desain Mutlak Komisaris: Human-Crafted, Anti-AI-Slop, Task-First
   ========================================================================== */

:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #0f172a;
  background-color: #f8fafc;
  font-size: 16px;
}

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

body {
  margin: 0;
  line-height: 1.5;
  background-color: #f8fafc;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #2563eb;
  text-underline-offset: 3px;
}

button, input, select {
  font: inherit;
  font-variant-numeric: tabular-nums;
}

button, select, input:not([type="file"]), .btn-download, .btn-action {
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Reserve the compact sticky header and the full focus ring, including before
   a result preview exists. Native Tab scrolling remains browser-controlled. */
html:has(#action-sidebar) {
  scroll-padding-block: 72px 12px;
}
main :is(button, .btn-download) {
  scroll-margin-block: 8px;
}

[hidden] {
  display: none !important;
}

/* --- Topbar (Strict 56px-64px single line) --- */
.topbar {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1140px;
  margin: auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  color: #0f172a;
  font-weight: 750;
  text-decoration: none;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin-right: auto;
}

.nav-inner nav {
  display: flex;
  gap: 16px;
}

.nav-inner nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.92rem;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
}

.nav-inner nav a:hover,
.nav-inner nav a.active {
  color: #0f172a;
  font-weight: 650;
}

/* --- Main Layout Container --- */
main {
  max-width: 1140px;
  margin: auto;
  padding: 16px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 6px;
}

.breadcrumb a {
  color: #64748b;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: #0f172a;
  text-decoration: underline;
}

h1 {
  font-size: clamp(1.4rem, 3.5vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 6px;
  letter-spacing: -0.025em;
  color: #0f172a;
  font-weight: 800;
}

.intro {
  margin: 0 0 18px;
  color: #475569;
  font-size: 0.95rem;
  max-width: 820px;
  line-height: 1.55;
}

/* --- Task-First Workspace Grid --- */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 36px;
}

/* Min-content must not expand the workspace at 200% CSS layout zoom. */
main { overflow-wrap: anywhere; }
.workspace-grid > *, .dropzone-box, .doc-toolbar, .doc-title-badge {
  min-width: 0;
  max-width: 100%;
}
main :is(button, .btn-download, .btn-secondary-action) {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.doc-title-badge, .stat-row, .result-header { flex-wrap: wrap; }
.doc-title-badge .doc-name { white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
}

/* --- Dropzone / File Picker --- */
.dropzone-box {
  background: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 24px 18px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
  margin-bottom: 18px;
}

.dropzone-box:hover,
.dropzone-box.dragover {
  border-color: #2563eb;
  background-color: #f0f7ff;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-icon svg {
  width: 36px;
  height: 36px;
}

.dropzone-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 4px;
}

.dropzone-hint {
  font-size: 0.86rem;
  color: #64748b;
  margin: 0 0 14px;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn-select-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 8px;
  padding: 0 20px;
  font-size: 0.94rem;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
}

.btn-select-file:hover {
  background: #1e293b;
}

/* --- Document Toolbar (Batch Actions) --- */
.doc-toolbar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.doc-title-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.doc-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.doc-meta {
  font-size: 0.82rem;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.doc-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 44px;
  transition: all 0.15s ease;
}

.btn-tool:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-tool svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Sortable Page Cards Grid --- */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 16px;
  min-height: 180px;
}

@media (max-width: 480px) {
  .pages-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
    gap: 12px;
  }
}

/* Page-local header reflow; preserve both brand text and menu control. */
#siteHeader { container-type: inline-size; }
#siteHeader .site-header__brand { flex-shrink: 1; min-width: 0; }
#siteHeader .site-header__brand-text { white-space: normal; overflow-wrap: anywhere; }
#siteHeader .site-header__bar { min-width: 0; }
@container (max-width: 768px) {
  #siteHeader :is(.site-header__nav--desktop, .site-header__search--desktop, .site-header__cta--desktop) { display: none !important; }
  #siteHeader .site-header__toggle { display: inline-flex !important; }
  #siteHeader .site-header__drawer:not([hidden]) { display: block !important; }
  #siteHeader .site-header__search--mobile { display: block !important; }
  #siteHeader .site-header__nav-link--mobile { white-space: normal; overflow-wrap: anywhere; }
}

/* --- Individual Page Card --- */
.page-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.page-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.page-card.is-dragging {
  opacity: 0.35;
  border: 2px dashed #2563eb;
  transform: scale(0.98);
}

.page-card.drop-before {
  border-left: 3px solid #2563eb;
}

.page-card.drop-after {
  border-right: 3px solid #2563eb;
}

.page-card.is-deleted {
  opacity: 0.45;
  background-color: #f8fafc;
  border-color: #fca5a5;
}

.page-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  gap: 4px;
}

.badge-page-num {
  font-size: 0.82rem;
  font-weight: 750;
  background: #0f172a;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 5px;
}

.page-card.is-deleted .badge-page-num {
  background: #ef4444;
}

.badge-orig-num {
  font-size: 0.75rem;
  color: #64748b;
}

.badge-rotation {
  font-size: 0.75rem;
  color: #2563eb;
  font-weight: 700;
  background: #eff6ff;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #bfdbfe;
}

/* --- Card Thumbnail Canvas Container --- */
.page-thumb-wrap {
  width: 100%;
  aspect-ratio: 1 / 1.35;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
}

.page-thumb-wrap:active {
  cursor: grabbing;
}

.page-thumb-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.deleted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b91c1c;
  font-weight: 750;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(1px);
}

/* --- Card Action Buttons Row --- */
.page-card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 88px), 1fr));
  gap: 6px;
  margin-top: 10px;
}

.page-card-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 88px), 1fr));
  gap: 6px;
  margin-top: 6px;
}

.btn-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 44px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  padding: 0 6px;
  transition: background 0.1s ease;
}

/* Reflow the control group, not the short action words or their icons. */
main .btn-card-action {
  min-width: 44px;
  white-space: nowrap;
  overflow-wrap: normal;
}

.btn-card-action svg {
  flex-shrink: 0;
}

.btn-card-action:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-card-action.btn-delete {
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-card-action.btn-delete:hover {
  background: #fef2f2;
}

.btn-card-action.btn-restore {
  color: #16a34a;
  border-color: #86efac;
}

.btn-card-action.btn-restore:hover {
  background: #f0fdf4;
}

/* --- Right Column / Sidebar Controls & Result --- */
.sidebar-panel {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  position: sticky;
  top: 76px;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 750;
  color: #0f172a;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  color: #475569;
}

.stat-value {
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* Primary Action Button */
.btn-primary-action {
  width: 100%;
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #2563eb;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease;
}

.btn-primary-action:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

/* Progress Box */
.progress-box {
  margin-top: 16px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: #2563eb;
  width: 0%;
  transition: width 0.15s ease;
}

.progress-text {
  font-size: 0.84rem;
  color: #475569;
  text-align: center;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Result Box */
.result-box [hidden] { display: none !important; }

.result-box {
  margin-top: 18px;
  padding: 16px 0 0;
  background: transparent;
  border: 0;
  border-top: 1px solid #e2e8f0;
  border-radius: 0;
  overflow-wrap: anywhere;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #166534;
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.result-info {
  font-size: 0.86rem;
  color: #15803d;
  margin: 0 0 14px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-download {
  width: 100%;
  background: #16a34a;
  color: #ffffff;
  border: 1px solid #16a34a;
  border-radius: 6px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-download:hover {
  background: #15803d;
}

.btn-secondary-action {
  width: 100%;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary-action:hover {
  background: #f8fafc;
}

.privacy-badge {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.45;
}

.privacy-badge svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #16a34a;
  margin-top: 2px;
}

/* --- Below the Fold: Theory, Math Formulas, & FAQ --- */
.content-guide {
  margin-top: 40px;
  border-top: 1px solid #e2e8f0;
  padding-top: 28px;
}

.content-guide h2 {
  font-size: 1.25rem;
  color: #0f172a;
  font-weight: 750;
  margin: 0 0 12px;
  letter-spacing: -0.015em;
}

.theory-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.theory-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}

.theory-card p {
  color: #334155;
  font-size: 0.93rem;
  line-height: 1.65;
  margin: 0 0 12px;
}

.theory-card p:last-child {
  margin-bottom: 0;
}

.formula-box {
  background: #f8fafc;
  border-left: 3px solid #2563eb;
  padding: 10px 16px;
  margin: 12px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  color: #1e293b;
  overflow-x: auto;
}

/* Accordion FAQ */
.faq-section {
  margin-bottom: 32px;
}

details {
  border-bottom: 1px solid #e2e8f0;
}

summary {
  font-weight: 650;
  font-size: 0.96rem;
  color: #0f172a;
  padding: 16px 4px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  color: #64748b;
  flex-shrink: 0;
  margin-left: 12px;
}

details[open] summary::after {
  content: "−";
}

.faq-body {
  padding: 0 4px 16px;
  color: #475569;
  font-size: 0.92rem;
  line-height: 1.6;
}

.faq-body p {
  margin: 0 0 8px;
}

.faq-body p:last-child {
  margin-bottom: 0;
}

/* References List */
.ref-list {
  padding-left: 20px;
  margin: 12px 0 0;
  color: #475569;
  font-size: 0.88rem;
  line-height: 1.65;
}

.ref-list li {
  margin-bottom: 6px;
}

/* --- Footer --- */
footer {
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 24px 16px;
  font-size: 0.86rem;
  color: #64748b;
  text-align: center;
  margin-top: 48px;
}

footer a {
  color: #475569;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
  color: #0f172a;
}
