/* ==========================================================================
   Design System & Core Styles: Epson A3 Book Splitter & Repagination
   Theme: Sleek Dark / Glassmorphism / Modern Engineering Utility
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Sarabun:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Color Palette */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-elevated: rgba(26, 34, 52, 0.7);
  --bg-card: rgba(17, 24, 39, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --border-glow: rgba(56, 189, 248, 0.3);

  --accent-primary: #6366f1;       /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;          /* Cyan */
  --accent-emerald: #10b981;       /* Green */
  --accent-amber: #f59e0b;         /* Amber */
  --accent-rose: #f43f5e;          /* Rose */
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --gradient-accent: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --gradient-card: linear-gradient(180deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.7) 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 70%);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', 'Sarabun', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.3);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
}

/* App Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: var(--gradient-accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  color: #fff;
  font-size: 1.3rem;
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-titles p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.badge-portable {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Step Wizard Navigation */
.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 0.75rem 1rem;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.wizard-step .step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.wizard-step:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.wizard-step.active {
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.15);
}

.wizard-step.active .step-number {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.wizard-step.completed .step-number {
  background: var(--accent-emerald);
  color: #fff;
}

.wizard-divider {
  width: 20px;
  height: 1px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* Main Layout Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Control Panel (Sidebar) */
.control-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-demo {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: #38bdf8;
}

.btn-demo:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25) 0%, rgba(99, 102, 241, 0.25) 100%);
  border-color: #38bdf8;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Radio Cards & Options */
.option-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.option-card {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.option-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.option-card.selected {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.option-card .card-icon {
  font-size: 1.1rem;
  color: var(--accent-cyan);
}

.option-card .card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.option-card .card-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}

/* Interactive Split Slider */
.slider-control-group {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

.fine-tune-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.8);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Input text & tags */
.input-text {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.input-text:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Main Display Area */
.display-stage {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Upload Dropzone */
.dropzone-container {
  background: var(--gradient-card);
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: 20px;
  padding: 3.5rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.dropzone-container:hover,
.dropzone-container.dragover {
  border-color: var(--accent-cyan);
  background: rgba(15, 23, 42, 0.85);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.dropzone-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--accent-cyan);
}

.dropzone-text h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.dropzone-text p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Preview Canvas Container */
.preview-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-md);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-navigator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.dual-preview-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .dual-preview-view {
    grid-template-columns: 1fr;
  }
}

.preview-viewport {
  background: #060911;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  position: relative;
  overflow: hidden;
}

.viewport-label {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  z-index: 10;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
  border-radius: 4px;
  overflow: hidden;
  max-width: 100%;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Interactive Split Cut Guideline */
.split-guideline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #f43f5e;
  cursor: ew-resize;
  z-index: 20;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.9);
}

.split-guideline.horizontal {
  left: 0;
  right: 0;
  height: 2px;
  width: auto;
  cursor: ns-resize;
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f43f5e;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.8);
}

/* Repagination Diagram Box */
.repagination-info-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.diagram-sheet-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.diagram-page-pill {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.diagram-arrow {
  color: var(--accent-cyan);
}

/* Thumbnail Grid for Page Management */
.thumbnails-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  max-height: 440px;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
}

.thumb-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
  transition: var(--transition-fast);
}

.thumb-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.thumb-canvas-box {
  width: 100%;
  aspect-ratio: 1 / 1.414;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-canvas-box canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.thumb-actions {
  display: flex;
  gap: 0.25rem;
}

.thumb-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  font-size: 0.75rem;
}

.thumb-btn:hover {
  color: var(--text-main);
}

/* Modal / Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--accent-emerald);
}

.toast.info {
  border-color: var(--accent-cyan);
}

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

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
  display: none;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  transition: width 0.2s ease;
}
