/**
 * ExtraToolkit PDF Scanner — Stylesheet
 * Responsive, touch-friendly, dark glassmorphic design system
 */

.scanner-app-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  font-family: var(--font-family, 'Outfit', 'Poppins', 'Inter', sans-serif);
  color: var(--text-primary, #ffffff);
}

/* ── Top Step / Mode Bar ── */
.scanner-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card, rgba(3, 6, 12, 0.45));
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: var(--border-radius-md, 16px);
  padding: 12px 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.scanner-nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scanner-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary, #9fb3c8);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.scanner-tab-btn i,
.scanner-tab-btn svg {
  width: 16px;
  height: 16px;
}

.scanner-tab-btn:hover {
  color: var(--cyan, #00e5ff);
  background: rgba(0, 229, 255, 0.05);
}

.scanner-tab-btn.active {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--cyan, #00e5ff);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.scanner-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-page-count {
  background: var(--accent-gradient, linear-gradient(135deg, #00bfff, #00e5ff));
  color: #050816;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Screen Containers ── */
.scanner-view-panel {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.scanner-view-panel.active {
  display: block;
}

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

/* ── 1. CAMERA VIEWPORT ── */
.camera-viewport-card {
  position: relative;
  background: #000000;
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: var(--border-radius-md, 16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  max-height: 70vh;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000000;
}

/* Guide Framing Overlay */
.camera-overlay-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-guide-box {
  width: 82%;
  height: 82%;
  border: 2px dashed rgba(0, 229, 255, 0.6);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  transition: all 0.3s ease;
}

.camera-guide-box.id-card-mode {
  width: 80%;
  height: 52%;
}

.guide-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--cyan, #00e5ff);
  border-style: solid;
}
.guide-corner.tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 8px; }
.guide-corner.tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 8px; }
.guide-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 8px; }
.guide-corner.br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 8px; }

.guide-label-pill {
  position: absolute;
  top: 14px;
  background: rgba(3, 6, 12, 0.85);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.3));
  color: var(--cyan, #00e5ff);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Floating Camera Top Controls */
.camera-top-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.icon-circle-btn {
  background: rgba(3, 6, 12, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.icon-circle-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--cyan, #00e5ff);
  color: var(--cyan, #00e5ff);
  transform: scale(1.05);
}

.icon-circle-btn.active {
  background: var(--cyan, #00e5ff);
  color: #050816;
  border-color: var(--cyan, #00e5ff);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

/* Floating Camera Bottom Controls */
.camera-bottom-toolbar {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 24px;
  z-index: 10;
}

.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid rgba(0, 229, 255, 0.8);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4), inset 0 0 0 3px #050816;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.shutter-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.6);
}

.shutter-btn:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-gradient, linear-gradient(135deg, #00bfff, #00e5ff));
}

/* Flash feedback effect on capture */
.camera-flash-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
  z-index: 20;
}

/* Camera fallback upload dropzone */
.camera-fallback-card {
  padding: 48px 24px;
  text-align: center;
}

/* ── 2. CROP & PERSPECTIVE WORKSPACE ── */
.crop-workspace-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.crop-canvas-wrapper {
  position: relative;
  background: #03060c;
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: var(--border-radius-md, 16px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
  max-height: 65vh;
  touch-action: none;
  user-select: none;
}

#crop-interactive-canvas {
  max-width: 100%;
  max-height: 65vh;
  display: block;
}

.crop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-card, rgba(3, 6, 12, 0.45));
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: 12px;
  padding: 12px 18px;
}

.crop-toolbar-left,
.crop-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── 3. FILTERS & ADJUSTMENTS ── */
.filter-workspace-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.filter-preview-box {
  background: #03060c;
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: var(--border-radius-md, 16px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
  max-height: 70vh;
  position: relative;
}

#filter-preview-canvas {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.filter-controls-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Preset Cards Grid */
.filter-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.filter-preset-card {
  background: rgba(13, 27, 42, 0.5);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.filter-preset-card:hover {
  border-color: var(--cyan, #00e5ff);
  background: rgba(0, 229, 255, 0.05);
  transform: translateY(-2px);
}

.filter-preset-card.active {
  border-color: var(--cyan, #00e5ff);
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.filter-preset-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
}

.filter-preset-desc {
  font-size: 0.7rem;
  color: var(--text-secondary, #9fb3c8);
}

/* Slider Groups */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary, #9fb3c8);
}

.scanner-range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.scanner-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan, #00e5ff);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

/* ── 4. MULTI-PAGE REVIEW STRIP ── */
.multi-page-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.page-card {
  background: rgba(13, 27, 42, 0.6);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: all 0.25s ease;
}

.page-card:hover {
  border-color: rgba(0, 229, 255, 0.4);
  transform: translateY(-2px);
}

.page-card-thumb-wrap {
  width: 100%;
  height: 200px;
  background: #03060c;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.page-card-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.page-card-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(3, 6, 12, 0.85);
  color: var(--cyan, #00e5ff);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.3));
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
}

.page-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-icon-tiny {
  background: transparent;
  border: none;
  color: var(--text-secondary, #9fb3c8);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-icon-tiny:hover {
  color: var(--cyan, #00e5ff);
  background: rgba(0, 229, 255, 0.1);
}

.btn-icon-tiny.delete:hover {
  color: #ff1744;
  background: rgba(255, 23, 68, 0.1);
}

.add-page-card {
  border: 2px dashed rgba(0, 229, 255, 0.3);
  border-radius: 12px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  color: var(--text-secondary, #9fb3c8);
}

.add-page-card:hover {
  border-color: var(--cyan, #00e5ff);
  color: var(--cyan, #00e5ff);
  background: rgba(0, 229, 255, 0.04);
}

/* ── 5. PDF SETTINGS & TARGET SIZE ── */
.pdf-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.target-size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.size-chip {
  background: rgba(13, 27, 42, 0.5);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary, #9fb3c8);
}

.size-chip:hover {
  border-color: var(--cyan, #00e5ff);
  color: #ffffff;
}

.size-chip.active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--cyan, #00e5ff);
  color: var(--cyan, #00e5ff);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}

/* Target Size Output Stats Card */
.compression-stats-card {
  background: linear-gradient(135deg, rgba(0, 191, 255, 0.08), rgba(0, 229, 255, 0.03));
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 16px;
  text-align: center;
}

.stat-item-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

.stat-item-val.highlight {
  color: var(--cyan, #00e5ff);
}

.stat-item-val.savings {
  color: #00e676;
}

.stat-item-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary, #9fb3c8);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── 6. RESULT & DOWNLOAD ── */
.result-success-box {
  text-align: center;
  padding: 36px 20px;
}

.result-icon-glow {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.3);
  color: #00e676;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.25);
}

.result-icon-glow i,
.result-icon-glow svg {
  width: 32px;
  height: 32px;
}

/* Cross Tool Growth Cards */
.cross-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.cross-tool-card {
  background: rgba(13, 27, 42, 0.45);
  border: 1px solid var(--border-glass, rgba(0, 229, 255, 0.15));
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.25s ease;
}

.cross-tool-card:hover {
  border-color: var(--cyan, #00e5ff);
  transform: translateY(-3px);
  background: rgba(0, 229, 255, 0.04);
}

/* ── Responsive Mobile Rules ── */
@media (max-width: 800px) {
  .filter-workspace-container {
    grid-template-columns: 1fr;
  }
  .pdf-settings-grid {
    grid-template-columns: 1fr;
  }
  .camera-viewport-card {
    min-height: 400px;
    max-height: 65vh;
  }
}
