@import url("https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap");
/* ID Card Scanner & A4 PDF Maker – uses the portal's shared style.css for header, sidebar, footer.
   Everything here is scoped to .idscan-page / tool-specific class names. */

.idscan-page {
  --ink: #0f172a;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --line: #000000;
  --muted: #475569;
  --ok: #16a34a;
  --warn: #b45309;
  --bad: #dc2626;
  --comic: 'Comic Neue', 'Comic Sans', 'Comic Neue', 'Chalkboard SE', 'Marker Felt', cursive;
}

.hidden { display: none !important; }

.idscan-main { max-width: 1280px; }
.idscan-main, .idscan-main button, .idscan-main select, .idscan-main label, .modal, .toasts, .busy {
  font-family: var(--comic);
}
.idscan-main h3 { font-family: 'Fredoka', var(--comic); }

/* Banner + steps */
.idscan-banner {
  display: flex; align-items: center; gap: 10px;
  background: #ffffff; border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 16px; font-size: 14px; color: var(--ink);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.12); margin-bottom: 18px;
}
.idscan-banner i { color: var(--ok); }

.idscan-steps {
  list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 26px 0; padding: 0;
  font-size: 13px; color: var(--muted);
}
.idscan-steps li { display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid #cbd5e1; border-radius: 999px; padding: 6px 14px 6px 8px; }
.idscan-steps b { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; align-items: center; justify-content: center; font-size: 12px; }

/* Panels (card boxes) */
.panel, .card-box {
  background: #ffffff; border: 2px solid var(--line); border-radius: 12px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.15); padding: 20px; margin-bottom: 24px;
}
.panel-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h3, .card-head h3 { font-size: 20px; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.panel-head h3 i, .card-head h3 i { color: var(--blue); }
.card-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Side panels (front / back) */
.side-panel {
  border: 2px solid #cbd5e1; border-radius: 12px; padding: 16px; margin-bottom: 18px; background: #f8fafc;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.side-panel:last-child { margin-bottom: 0; }
.side-panel.is-active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.side-panel.drag-over { border-color: var(--blue); background: var(--blue-soft); }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.side-head h4 { font-family: 'Fredoka', var(--comic); font-size: 17px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.side-head h4 i { color: var(--blue); }
.side-status { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #e2e8f0; color: var(--muted); }
.side-status.ok { background: rgba(22,163,74,0.14); color: #166534; }

/* Empty state / dropzone */
.dropzone {
  border: 2.5px dashed #94a3b8; border-radius: 12px; background: #ffffff;
  padding: 28px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.dropzone > i { font-size: 34px; color: var(--blue); }
.dropzone p { font-size: 14px; color: var(--muted); }
.dropzone .hint { font-size: 12px; }
.drop-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.paste-box { font-size: 12px; color: var(--muted); }
kbd { background: #e2e8f0; border: 1px solid #94a3b8; border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: inherit; }

/* Working state */
.side-work { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview-stage {
  position: relative; border: 2px solid var(--line); border-radius: 10px; overflow: hidden;
  background-color: #e2e8f0;
  background-image: linear-gradient(45deg, #cbd5e1 25%, transparent 25%), linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #cbd5e1 75%), linear-gradient(-45deg, transparent 75%, #cbd5e1 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  padding: 14px; display: flex; align-items: center; justify-content: center; min-height: 200px;
}
.preview-canvas { display: block; max-width: 100%; max-height: 420px; height: auto; box-shadow: 0 2px 10px rgba(0,0,0,0.25); background: #fff; }
.compare-badge { position: absolute; top: 8px; left: 8px; background: #000; color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.preview-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.warnings { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.warn-item { font-size: 13px; padding: 8px 10px; border-radius: 8px; display: flex; gap: 8px; align-items: flex-start; line-height: 1.35; }
.warn-item.warn { background: #fffbeb; border: 1.5px solid #f59e0b; color: #92400e; }
.warn-item.bad { background: #fef2f2; border: 1.5px solid #ef4444; color: #991b1b; }

.side-tools { display: flex; flex-direction: column; gap: 16px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-group > label, .field > label, .field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 2px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .12s ease, background .12s ease;
}
.chip:hover { transform: translateY(-1px); background: #f1f5f9; }
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 2px 2px 0 rgba(0,0,0,0.25); }

.slider-row { display: grid; grid-template-columns: 90px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.slider-row output { text-align: right; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--blue); height: 28px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--line); border-radius: 10px; padding: 9px 16px;
  font-size: 14px; font-weight: 700; cursor: pointer; background: #fff; color: var(--ink);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2); transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  min-height: 40px;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(0,0,0,0.25); }
.btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 1px 1px 0 rgba(0,0,0,0.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(37,99,235,.55); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-dark { background: #151b29; color: #fff; }
.btn-ghost { background: #fff; }
.btn-danger-text { color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 36px; }
.btn-lg { padding: 13px 22px; font-size: 16px; width: 100%; }
.icon-btn { width: 40px; height: 40px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.add-card-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }

/* Output section */
.out-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 28px; align-items: start; }
.out-settings .field { margin-bottom: 14px; }
.out-settings .field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
select {
  width: 100%; height: 40px; border: 2px solid var(--line); border-radius: 10px; padding: 0 10px; font-size: 14px; background: #fff; color: var(--ink);
}
.notice { font-size: 13px; line-height: 1.45; background: #fffbeb; border: 1.5px solid #f59e0b; color: #78350f; border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.notice.info { background: var(--blue-soft); border-color: #93c5fd; color: #1e3a8a; }
.notice p + p { margin-top: 6px; }
.out-actions { display: flex; flex-direction: column; gap: 10px; }
.out-actions .btn:not(.btn-lg) { width: 100%; }

.out-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.pager { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.a4-wrap { width: 100%; max-width: 520px; background: #cbd5e1; border: 2px solid var(--line); border-radius: 10px; padding: 16px; }
.a4-sheet {
  position: relative; width: 100%; background: #ffffff; box-shadow: 0 4px 16px rgba(0,0,0,0.3); overflow: hidden;
  aspect-ratio: 210 / 297;
}
.a4-sheet canvas { position: absolute; display: block; }
.a4-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; color: #94a3b8; font-size: 14px; }
.preview-caption { font-size: 12px; color: var(--muted); text-align: center; }

/* Crop modal */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(2, 6, 23, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: #fff; border: 2px solid var(--line); border-radius: 14px; width: 100%; max-width: 1000px; max-height: 100%; display: flex; flex-direction: column; padding: 16px; gap: 10px; box-shadow: 6px 6px 0 rgba(0,0,0,0.35); overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 20px; }
.modal-hint { font-size: 13px; color: var(--muted); }
.crop-stage { position: relative; width: 100%; height: min(60vh, 560px); min-height: 260px; background: #0f172a; border-radius: 10px; overflow: hidden; border: 2px solid var(--line); }
#cropCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crop-toolbar select { width: auto; min-width: 200px; height: 36px; font-size: 13px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.modal-actions { display: flex; gap: 10px; }
.crop-info { font-size: 13px; color: var(--muted); }
.crop-info.bad { color: var(--bad); font-weight: 700; }
body.modal-open { overflow: hidden; }

/* Busy + toasts */
.busy { position: fixed; inset: 0; z-index: 3000; background: rgba(255,255,255,0.55); display: flex; align-items: center; justify-content: center; }
.busy-box { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 16px 22px; display: flex; align-items: center; gap: 14px; box-shadow: 4px 4px 0 rgba(0,0,0,0.25); font-size: 15px; }
.spinner { width: 22px; height: 22px; border: 3px solid #cbd5e1; border-top-color: var(--blue); border-radius: 50%; animation: idspin .8s linear infinite; }
@keyframes idspin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3500; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px); }
.toast { background: #151b29; color: #fff; border-radius: 10px; padding: 11px 14px; font-size: 14px; border-left: 5px solid #38bdf8; box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.toast.warn { border-left-color: #f59e0b; }
.toast.bad { border-left-color: #ef4444; }
.toast.ok { border-left-color: #22c55e; }

/* Print root is never visible on screen */
#print-root { display: none; }

/* Responsive */
@media (max-width: 1100px) {
  .side-work { grid-template-columns: 1fr; }
  .out-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .panel, .card-box { padding: 14px; }
  .crop-stage { height: 52vh; }
  .modal { padding: 8px; }
  .modal-card { padding: 12px; }
  .crop-toolbar .btn-sm { flex: 1 1 calc(50% - 8px); }
  .crop-toolbar select { flex: 1 1 100%; }
  .modal-actions { width: 100%; }
  .modal-actions .btn { flex: 1; }
  .chip, .btn { min-height: 44px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ===== PRINT: only the final A4 card layout is printed ===== */
@page { size: A4 portrait; margin: 0; }

@media print {
  html, body {
    background: #ffffff !important;
    background-image: none !important;
    margin: 0 !important; padding: 0 !important;
    height: auto !important; min-height: 0 !important;
    display: block !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  /* Hide the whole website (header, sidebar, tool UI, footer, dialogs) */
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; margin: 0; padding: 0; background: #fff; }

  .print-page {
    position: relative; overflow: hidden; background: #fff;
    break-after: page; page-break-after: always; break-inside: avoid; page-break-inside: avoid;
  }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page img { position: absolute; display: block; max-width: none; border: 0; margin: 0; padding: 0; }
}
