/* ============================================================
   Bankfoto Photo ID - Apple-Inspired White & Blue Theme
   Typography: Google Prompt
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Apple Signature White & Blue Palette */
  --apple-bg: #f5f5f7;
  --apple-surface: #ffffff;
  --apple-surface-secondary: #fbfbfd;
  --apple-blue: #0071e3;
  --apple-blue-hover: #0077ed;
  --apple-blue-active: #0062c4;
  --apple-blue-light: #e8f2fe;
  --apple-blue-tint: rgba(0, 113, 227, 0.08);
  --apple-border: rgba(0, 0, 0, 0.08);
  --apple-border-subtle: rgba(0, 0, 0, 0.04);
  --apple-text: #1d1d1f;
  --apple-text-secondary: #6e6e73;
  --apple-text-tertiary: #86868b;
  --apple-card-shadow: 0 4px 24px -2px rgba(0, 0, 0, 0.04), 0 2px 8px -1px rgba(0, 0, 0, 0.02);
  --apple-card-shadow-hover: 0 12px 32px -4px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  background-color: var(--apple-bg);
  color: var(--apple-text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure Prompt font applies everywhere */
input, button, select, textarea, span, p, h1, h2, h3, h4, h5, h6, label {
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Subtle Apple Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}

/* Cropper styling tweaks - Clean solid background */
.cropper-view-box,
.cropper-face {
  border-radius: 6px;
}
.cropper-line, .cropper-point {
  background-color: var(--apple-blue) !important;
}
.cropper-point {
  width: 9px !important;
  height: 9px !important;
  border-radius: 9999px !important;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.4) !important;
}
.cropper-bg {
  background: #111827 !important; /* Elegant Obsidian slate */
  background-image: none !important;
}
.cropper-modal {
  background-color: #030712 !important;
  opacity: 0.78 !important;
}

/* Center Alignment Guide Lines (Toggleable) */
.show-center-guide .cropper-crop-box::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  transform: translateX(-50%);
  background: var(--apple-blue);
  box-shadow: 0 0 0 0.75px rgba(255, 255, 255, 0.95), 0 0 6px rgba(0, 113, 227, 0.6);
  z-index: 200;
  pointer-events: none;
}

.show-center-guide .cropper-crop-box::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  border-top: 1px dashed var(--apple-blue);
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.9);
  z-index: 200;
  pointer-events: none;
}

.show-center-guide .cropper-view-box::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--apple-blue);
  border-radius: 9999px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), inset 0 0 0 1px rgba(255, 255, 255, 0.9);
  z-index: 201;
  pointer-events: none;
}

/* ============================================================
   Authentic Apple iOS Toggle Switch
   ============================================================ */
.ios-switch-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  pointer-events: none;
}

.ios-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e5e5ea; /* iOS inactive light gray */
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ios-switch-slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 1px 1px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.ios-switch input:checked + .ios-switch-slider {
  background-color: #34c759; /* Apple iOS Iconic Green */
}

.ios-switch input:checked + .ios-switch-slider::before {
  transform: translateX(20px);
}

/* Live Photo Filter Preview (Left Cropper Images) */
#cropperContainerWrapper .cropper-container img,
#imageToCrop {
  transition: filter 0.12s ease-out;
}

/* Scaler Wrapper that keeps layout dimensions strictly in sync with scaled preview */
#paperScaleWrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  transition: width 0.2s cubic-bezier(0.16, 1, 0.3, 1), height 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Apple-style A4 Sheet Viewport - Clean, Light & Floating (No Black Background) */
.sheet-viewport {
  background: transparent;
  overflow: auto;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 12px;
  min-height: 420px;
  border-radius: 24px;
  /* Luminous, crystal-clear Apple ambient backdrop (0% dark background) */
  background: radial-gradient(circle at 50% 25%, rgba(0, 113, 227, 0.05) 0%, rgba(255, 255, 255, 0.5) 60%, transparent 100%);
  border: 1px solid rgba(0, 113, 227, 0.08);
}

@media (min-width: 640px) {
  .sheet-viewport {
    padding: 28px 16px;
    min-height: 520px;
  }
}

@media (min-width: 1024px) {
  .sheet-viewport {
    padding: 36px 20px;
    min-height: 580px;
  }
}

@media (min-width: 1536px) {
  .sheet-viewport {
    min-height: 680px;
  }
}

/* The simulated A4 paper - Floating card with rounded corners & glowing edge */
.a4-paper {
  background: #ffffff;
  width: 420px;
  height: 594px;
  position: relative;
  transform-origin: top center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease, border-color 0.35s ease;
  overflow: hidden;
  border-radius: 12px; /* กรอบมนเล็กๆ สวยหรู */
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* Smooth corner clipping */
  border: 1.5px solid rgba(0, 113, 227, 0.35); /* เส้นขอบเรืองแสง Apple Blue คมชัด */
  
  /* รูปลอยขึ้นมา (Floating Card) พร้อมขอบเรืองแสงสีฟ้านุ่มนวล */
  box-shadow: 
    0 16px 36px -8px rgba(0, 0, 0, 0.07),
    0 6px 16px -4px rgba(0, 0, 0, 0.03),
    0 0 0 1px rgba(0, 113, 227, 0.15),
    0 0 20px rgba(0, 113, 227, 0.22),
    0 0 42px rgba(0, 113, 227, 0.12);
  animation: paperGlowPulse 5s ease-in-out infinite alternate;
}

.a4-paper:hover {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 
    0 22px 45px -8px rgba(0, 0, 0, 0.09),
    0 8px 20px -4px rgba(0, 0, 0, 0.04),
    0 0 0 1.5px rgba(0, 113, 227, 0.3),
    0 0 28px rgba(0, 113, 227, 0.32),
    0 0 54px rgba(0, 113, 227, 0.18);
}

@keyframes paperGlowPulse {
  0% {
    box-shadow: 
      0 16px 36px -8px rgba(0, 0, 0, 0.07),
      0 6px 16px -4px rgba(0, 0, 0, 0.03),
      0 0 0 1px rgba(0, 113, 227, 0.15),
      0 0 18px rgba(0, 113, 227, 0.20),
      0 0 38px rgba(0, 113, 227, 0.10);
  }
  100% {
    box-shadow: 
      0 18px 40px -8px rgba(0, 0, 0, 0.08),
      0 7px 18px -4px rgba(0, 0, 0, 0.04),
      0 0 0 1.5px rgba(0, 113, 227, 0.26),
      0 0 24px rgba(0, 113, 227, 0.28),
      0 0 46px rgba(0, 113, 227, 0.15);
  }
}

/* Canvas inside paper with smooth fade transition */
.a4-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  transition: opacity 0.25s ease-out;
}

/* Smooth Apple-style loading animation */
.smooth-fade-in {
  animation: appleSmoothFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes appleSmoothFade {
  0% {
    opacity: 0;
    transform: scale(0.99);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Fantasy Logo Animation: Subtle Magical Pulse */
@keyframes magicFloat {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-2px) rotate(0.8deg);
  }
}

.logo-magic-float {
  animation: magicFloat 4s ease-in-out infinite;
}

@keyframes starShimmer {
  0%, 100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.magic-sparkle {
  transform-origin: center;
  animation: starShimmer 2.4s ease-in-out infinite;
}

/* Apple Range sliders */
input[type=range] {
  accent-color: var(--apple-blue);
}

/* Apple Dropzone styling */
.dropzone {
  border: 2px dashed rgba(0, 113, 227, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--apple-surface-secondary);
  border-radius: 18px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--apple-blue);
  background-color: var(--apple-blue-light);
  transform: translateY(-1px);
}

/* Apple Badge styling */
.badge-rec {
  background: linear-gradient(135deg, #0071e3, #38bdf8);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
  letter-spacing: 0.01em;
}

/* Apple Card hover elevation */
.apple-card {
  background: var(--apple-surface);
  border: 1px solid var(--apple-border);
  box-shadow: var(--apple-card-shadow);
  border-radius: 18px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.apple-card-interactive {
  cursor: pointer;
}
.apple-card-interactive:hover {
  border-color: rgba(0, 113, 227, 0.3);
  box-shadow: var(--apple-card-shadow-hover);
  transform: translateY(-1.5px);
}

/* Print specific rules */
@media print {
  body * {
    visibility: hidden;
  }
  .print-area, .print-area * {
    visibility: visible;
  }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
  }
}
