/* ==========================================================
   ScanDoc — style.css  (Premium Dark Edition)
   Desain: Dark mode glassmorphism, Inter font, animasi halus
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warna utama */
  --bg:           #0c0e1a;
  --bg2:          #111327;
  --surface:      rgba(255,255,255,0.05);
  --surface-hover:rgba(255,255,255,0.09);
  --border:       rgba(255,255,255,0.10);
  --border-glow:  rgba(99,102,241,0.40);

  /* Aksen */
  --indigo:       #6366f1;
  --indigo-light: #818cf8;
  --indigo-dark:  #4f46e5;
  --violet:       #8b5cf6;
  --cyan:         #06b6d4;
  --emerald:      #10b981;
  --rose:         #f43f5e;
  --amber:        #f59e0b;
  --orange:       #f97316;

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

  /* Gradien */
  --grad-main:    linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --grad-button:  linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-orange:  linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  --grad-rose:    linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);

  /* Shadow */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
  --shadow-glow:0 0 24px rgba(99,102,241,0.25);
  --shadow-glow-green:0 0 24px rgba(16,185,129,0.30);

  /* Radius */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated mesh gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139,92,246,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 60% 30%, rgba(6,182,212,0.07) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ── Header ───────────────────────────────────────────────── */
header {
  background: rgba(12,14,26,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--grad-main);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.tagline {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ── Stepper (progress langkah) ─────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.3s;
  position: relative;
}

.step.active {
  background: rgba(99,102,241,0.15);
  color: var(--indigo-light);
}

.step.done {
  color: var(--emerald);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.3s;
}

.step.active .step-num {
  background: var(--grad-button);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 10px rgba(99,102,241,0.5);
}

.step.done .step-num {
  background: var(--grad-success);
  border-color: transparent;
  color: #fff;
}

.step-sep {
  width: 20px;
  height: 1px;
  background: var(--border);
}

/* ── Main Layout ─────────────────────────────────────────── */
main {
  max-width: 800px;
  margin: 36px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Card (Glass) ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s, box-shadow 0.3s;
  animation: fadeInUp 0.5s ease both;
}

.card:hover {
  border-color: rgba(99,102,241,0.25);
  box-shadow: 0 0 0 1px rgba(99,102,241,0.10), var(--shadow-md);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.24s; }

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: rgba(99,102,241,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.7;
}

/* ── Tombol utama ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}

.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--grad-button);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.55);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--grad-success);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16,185,129,0.5);
}

.btn-danger-outline {
  background: transparent;
  color: var(--rose);
  border: 1px solid rgba(244,63,94,0.4);
}
.btn-danger-outline:hover {
  background: rgba(244,63,94,0.1);
  border-color: var(--rose);
}

.btn-capture {
  background: rgba(255,255,255,0.95);
  color: #1e1b4b;
  border: 3px solid rgba(255,255,255,0.8);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 0 0 6px rgba(255,255,255,0.1);
}
.btn-capture:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 32px rgba(0,0,0,0.4), 0 0 0 8px rgba(255,255,255,0.15);
}

.btn-capture::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 8px var(--rose);
  display: block;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

.btn-lg { padding: 13px 28px; font-size: 15px; }

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
  border-radius: 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  padding: 11px;
}

/* ── Source buttons (Langkah 1) ──────────────────────────── */
.source-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

.source-btn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  border-radius: var(--r-md);
  border: 2px dashed var(--border);
  background: transparent;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.25s;
  color: var(--text-secondary);
  text-decoration: none;
}

.source-btn-card:hover {
  border-color: var(--indigo);
  background: rgba(99,102,241,0.08);
  color: var(--indigo-light);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.15);
}

.source-btn-card:hover .sbc-icon { transform: scale(1.1); }

.sbc-icon {
  font-size: 36px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sbc-label {
  font-size: 14px;
  font-weight: 600;
}

.sbc-sub {
  font-size: 11px;
  opacity: 0.7;
}

/* Drop-zone feel saat drag over */
.source-btn-card.dragover {
  border-color: var(--cyan);
  background: rgba(6,182,212,0.08);
  color: var(--cyan);
}

/* ── Area kamera ─────────────────────────────────────────── */
#camera-area {
  margin-top: 8px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

#video-preview {
  width: 100%;
  max-height: 420px;
  background: #000;
  display: block;
  object-fit: cover;
}

/* Overlay scanning garis animasi */
#camera-area::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--indigo), var(--cyan), transparent);
  animation: scan-line 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scan-line {
  0%   { top: 0%;   opacity: 1; }
  90%  { top: 100%; opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Sudut pemandu kamera */
.camera-guide {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  z-index: 5;
}

.camera-guide::before,
.camera-guide::after,
.guide-br::before,
.guide-br::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: rgba(99,102,241,0.8);
  border-style: solid;
}

.camera-guide::before { top:0; left:0; border-width:3px 0 0 3px; border-radius: 4px 0 0 0; }
.camera-guide::after  { top:0; right:0; border-width:3px 3px 0 0; border-radius: 0 4px 0 0; }
.guide-br::before     { bottom:0; left:0; border-width:0 0 3px 3px; border-radius: 0 0 0 4px; }
.guide-br::after      { bottom:0; right:0; border-width:0 3px 3px 0; border-radius: 0 0 4px 0; }

.camera-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}

/* ── Preview Grid (thumbnail foto) ──────────────────────── */
#preview-grid, #final-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.preview-thumb {
  position: relative;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  aspect-ratio: 3/4;
  background: var(--bg2);
  transition: all 0.25s;
  cursor: pointer;
}

.preview-thumb:hover {
  border-color: var(--indigo);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.2);
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-thumb .thumb-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 16px 4px 6px;
}

.preview-thumb .btn-remove {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(244,63,94,0.85);
  backdrop-filter: blur(4px);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s;
}

.preview-thumb:hover .btn-remove {
  opacity: 1;
  transform: scale(1);
}

/* ── Action Row ─────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 28px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

footer span {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* ============================================================
   HALAMAN CROP & EDIT (Layout Dua Kolom)
   ============================================================ */

#layout-crop {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  max-width: 1140px;
  margin: 28px auto;
  padding: 0 20px;
}

/* Panel kiri: daftar halaman */
#page-list-panel {
  width: 170px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  overflow: hidden;
  position: sticky;
  top: 80px;
  animation: fadeInLeft 0.5s ease both;
}

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#page-count-label {
  background: rgba(99,102,241,0.2);
  color: var(--indigo-light);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
}

#page-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#page-list::-webkit-scrollbar { width: 4px; }
#page-list::-webkit-scrollbar-track { background: transparent; }
#page-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.page-item {
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255,255,255,0.04);
}

.page-item:hover { border-color: var(--indigo); transform: scale(1.02); }
.page-item.active {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2), var(--shadow-glow);
}
.page-item.saved { border-color: var(--emerald); }

.page-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.page-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.badge-saved {
  font-size: 10px;
  color: var(--emerald);
  font-weight: 700;
}

/* Panel kanan: editor */
#editor-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: fadeInRight 0.5s ease both;
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  align-items: center;
}

.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.toolbar-group + .toolbar-group {
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.tool-btn {
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.2s;
  white-space: nowrap;
}

.tool-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
}

.tool-btn.active {
  background: var(--grad-button);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(99,102,241,0.4);
}

.tool-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tool-select {
  padding: 5px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  background: var(--bg2);
  color: var(--text-primary);
  cursor: pointer;
}

/* Area crop gambar */
#crop-container {
  max-height: 480px;
  background: #060810;
  overflow: hidden;
  position: relative;
}

#crop-image {
  display: block;
  max-width: 100%;
}

/* Aksi crop */
.crop-actions {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  background: rgba(255,255,255,0.02);
}

/* Status bar */
#status-bar {
  padding: 9px 16px;
  background: rgba(0,0,0,0.2);
  border-top: 1px solid var(--border);
}

#status-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tombol lanjut di bawah editor */
#layout-crop-footer {
  max-width: 1140px;
  margin: 0 auto 32px;
  padding: 0 20px;
}

#section-next {
  background: linear-gradient(135deg, rgba(99,102,241,0.10) 0%, rgba(139,92,246,0.08) 100%);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

#saved-count-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================================
   HALAMAN PDF — Setting Group
   ============================================================ */

.setting-group { margin-bottom: 28px; }

.setting-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

/* Pilihan ukuran file */
.size-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.size-btn {
  flex: 1;
  min-width: 110px;
  padding: 14px 12px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'Inter', sans-serif;
}

.size-btn:hover {
  border-color: var(--indigo);
  background: rgba(99,102,241,0.08);
  transform: translateY(-2px);
}

.size-btn.active {
  border-color: var(--indigo);
  background: rgba(99,102,241,0.12);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15), var(--shadow-glow);
}

.size-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.size-btn.active .size-value { color: var(--indigo-light); }

.size-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Input manual */
.manual-input-row,
.filename-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-input-row input[type="number"],
.filename-row input[type="text"] {
  padding: 9px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  background: rgba(0,0,0,0.3);
  width: 150px;
  transition: all 0.2s;
}

.manual-input-row input[type="number"]:focus,
.filename-row input[type="text"]:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.filename-row input[type="text"] { width: 240px; }

.input-unit {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.hint-small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Radio ukuran halaman */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: all 0.2s;
}

.radio-option:hover {
  border-color: var(--indigo);
  background: rgba(99,102,241,0.08);
  color: var(--text-primary);
}

.radio-option input[type="radio"] {
  accent-color: var(--indigo);
}

.radio-option-highlight {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.05);
}
.radio-option-highlight:hover {
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.1);
}

.radio-auto-badge {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Info target */
.target-info {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--r-sm);
  padding: 11px 16px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.target-info::before {
  content: 'ℹ️';
  font-size: 14px;
}

/* Progress bar */
.progress-bar-wrap {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--grad-main);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(99,102,241,0.5);
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Estimasi ukuran */
.estimate-info {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: #6ee7b7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.estimate-info::before { content: '✅'; font-size: 14px; }

/* ============================================================
   MODE PERSPEKTIF — Overlay 4 titik
   ============================================================ */

#persp-overlay {
  position: absolute;
  top: 0; left: 0;
  cursor: crosshair;
  z-index: 10;
  touch-action: none;
}

/* Tombol perspektif: warna oranye */
.tool-btn#btn-persp-toggle.active {
  background: var(--grad-orange);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(249,115,22,0.4);
}

.tool-btn#btn-persp-toggle:not(.active):hover {
  color: var(--orange);
  border-color: rgba(249,115,22,0.4);
  background: rgba(249,115,22,0.08);
}

/* ============================================================
   RESPONSIVE — Mobile-First Overhaul
   Breakpoints:
     ≤ 768px  — Tablet / Phablet
     ≤ 600px  — Smartphone lanskap
     ≤ 480px  — Smartphone portrait (utama)
     ≤ 360px  — Smartphone kecil
   ============================================================ */

/* ── Tablet (≤ 768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  /* Header: lebih kompak */
  header {
    padding: 0 16px;
    height: 56px;
  }

  .logo { font-size: 17px; }
  .logo-icon { width: 30px; height: 30px; font-size: 15px; }

  /* Stepper: sembunyikan teks, hanya tampilkan nomor */
  .step span { display: none; }
  .step { padding: 4px 8px; }
  .step-sep { width: 12px; }

  /* Layout crop: switch ke kolom */
  #layout-crop {
    flex-direction: column;
    padding: 0 14px;
    margin: 14px auto;
    gap: 12px;
  }

  /* Panel halaman: horizontal strip di atas editor */
  #page-list-panel {
    width: 100%;
    position: static;    /* lepas sticky agar tidak memblokir layar */
    flex-shrink: 0;
  }

  #page-list {
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    gap: 10px;
    /* Scroll snap agar geser halaman terasa natural */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .page-item {
    width: 72px;
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  /* Crop container: lebih tinggi di tablet */
  #crop-container { max-height: 400px; }

  /* Toolbar: wrap & beri lebih banyak ruang */
  .toolbar { gap: 8px; padding: 10px 12px; }
  .tool-btn { padding: 9px 13px; font-size: 12px; min-height: 36px; }

  /* Footer layout */
  #layout-crop-footer {
    padding: 0 14px;
    margin-bottom: 24px;
  }

  #section-next {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    text-align: center;
  }

  #section-next .btn { width: 100%; justify-content: center; }

  /* PDF page: action row */
  .action-row { flex-direction: column; }
  .action-row .btn { width: 100%; justify-content: center; }

  /* Card padding */
  .card { padding: 20px 16px; }
  main { padding: 0 14px; margin: 20px auto; }
}

/* ── Smartphone Portrait (≤ 480px) ───────────────────────── */
@media (max-width: 480px) {

  /* Sembunyikan stepper sepenuhnya */
  .stepper { display: none; }

  /* Header hanya logo */
  header { height: 52px; padding: 0 14px; }
  header > div:last-child { display: none; } /* hapus spacer */

  /* Tombol sumber gambar: 2 kolom */
  .source-buttons {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .source-btn-card { padding: 18px 10px; }
  .sbc-icon { font-size: 26px; }
  .sbc-label { font-size: 13px; }
  .sbc-sub { font-size: 11px; }

  /* Kamera: kontrol lebih besar untuk sentuh */
  .camera-controls { gap: 12px; padding: 12px 16px; }
  .btn-capture {
    width: 64px !important;
    height: 64px !important;
    font-size: 24px !important;
  }

  /* Card */
  .card { padding: 16px 14px; border-radius: var(--r-md); }
  main { margin: 14px auto; gap: 14px; }

  /* Toolbar: tombol lebih kecil tapi tetap touchable */
  .toolbar { padding: 8px 10px; gap: 6px; }
  .toolbar-group + .toolbar-group {
    padding-left: 6px;
    border-left-width: 1px;
  }

  .tool-btn {
    padding: 8px 10px;
    font-size: 11px;
    min-height: 38px;   /* min 38px = mudah disentuh */
    min-width: 44px;
  }

  /* Auto Detect: teks lebih pendek di mobile */
  #btn-auto-detect::before { content: '🔍'; }

  /* Crop container: sesuaikan tinggi layar */
  #crop-container { max-height: calc(50vh - 60px); min-height: 200px; }

  /* Aksi crop: tombol full-width */
  .crop-actions {
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
  }
  .crop-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;   /* touch target */
    font-size: 14px;
  }

  /* Panel halaman: thumbnail lebih kecil */
  .page-item { width: 62px; }

  /* PDF settings */
  .size-options { flex-direction: column; }
  .size-btn {
    flex-direction: row;
    justify-content: space-between;
    min-width: unset;
    padding: 12px 14px;
    min-height: 48px;
  }
  .radio-group { flex-direction: column; gap: 8px; }
  .radio-option {
    min-height: 44px;   /* touch target */
    font-size: 14px;
  }

  /* Input fields */
  .filename-row { flex-wrap: wrap; }
  .filename-row input[type="text"] { width: 100%; }
  .manual-input-row input[type="number"] { width: 130px; }

  /* Tombol Buat PDF */
  #btn-generate { width: 100%; min-height: 52px; font-size: 16px; }

  /* Pratinjau dokumen grid */
  #final-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .preview-thumb { height: 120px; }

  /* Tombol remove pada thumbnail: selalu visible di mobile */
  .preview-thumb .btn-remove {
    opacity: 1 !important;
    transform: scale(1) !important;
    width: 28px;
    height: 28px;
  }

  /* Footer */
  footer { padding: 18px 14px; }
  footer span { font-size: 11px; }
}

/* ── Smartphone Kecil (≤ 360px) ─────────────────────────── */
@media (max-width: 360px) {
  .source-buttons { grid-template-columns: 1fr; }

  .tool-btn { padding: 7px 8px; font-size: 10px; }

  #btn-auto-detect { font-size: 10px; }

  .crop-actions .btn { font-size: 13px; padding: 10px; }

  .page-item { width: 56px; }

  #final-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ── Landscape Smartphone (≤ 680px height) ───────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  header { height: 46px; }

  #layout-crop {
    flex-direction: row;  /* Kembali ke 2 kolom di landscape */
    padding: 0 10px;
    margin: 8px auto;
  }

  #page-list-panel {
    width: 100px;
    position: sticky;
    top: 54px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  #page-list { flex-direction: column; max-height: none; }
  .page-item { width: 100%; }

  #crop-container { max-height: calc(100vh - 180px); }

  .toolbar { padding: 6px 10px; }
  .crop-actions { padding: 8px 12px; }
}

/* ── Safe area untuk notch / Dynamic Island ──────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  footer {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .crop-actions {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}


/* =============================================
   Tombol Auto Detect (cyan/teal)
   ============================================= */

.tool-btn-detect {
  background: linear-gradient(135deg, rgba(6,182,212,0.15) 0%, rgba(8,145,178,0.1) 100%);
  color: #22d3ee;
  border-color: rgba(6,182,212,0.35);
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: all 0.25s;
}

.tool-btn-detect:hover {
  background: linear-gradient(135deg, rgba(6,182,212,0.28) 0%, rgba(8,145,178,0.2) 100%);
  border-color: #06b6d4;
  box-shadow: 0 0 12px rgba(6,182,212,0.35);
  color: #fff;
}

.tool-btn-detect:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  animation: detect-pulse 1s ease-in-out infinite;
}

@keyframes detect-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6,182,212,0); }
  50%       { box-shadow: 0 0 0 6px rgba(6,182,212,0.2); }
}

/* =============================================
   Overlay scanning saat Auto Detect berjalan
   ============================================= */

#ad-scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 16, 0.55);
  backdrop-filter: blur(4px);
  pointer-events: none;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ad-scan-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Garis scanner yang bergerak naik-turun */
.ad-scan-line {
  width: 220px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, #06b6d4 40%, #22d3ee 60%, transparent 100%);
  border-radius: 99px;
  box-shadow: 0 0 12px rgba(6,182,212,0.8), 0 0 24px rgba(6,182,212,0.4);
  animation: scan-sweep 1.4s ease-in-out infinite alternate;
}

@keyframes scan-sweep {
  from { transform: translateY(-70px) scaleX(0.7); opacity: 0.7; }
  to   { transform: translateY(70px)  scaleX(1.0); opacity: 1.0; }
}

.ad-scan-text {
  font-size: 13px;
  font-weight: 600;
  color: #e0f2fe;
  letter-spacing: 0.3px;
  text-shadow: 0 0 8px rgba(6,182,212,0.6);
}