/* ==========================================================================
   ImageOptima SaaS — Custom Styles & Interactive Components
   100% Client-Side HTML5 Canvas Bulk Image Optimizer
   ========================================================================== */

:root {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.78);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-emerald: #10b981;
}

html.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-subtle: rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}

/* Transparency Checkerboard Pattern for Thumbnails & Split Comparator */
.checkerboard {
  background-color: #18181b;
  background-image:
    linear-gradient(45deg, #27272a 25%, transparent 25%),
    linear-gradient(-45deg, #27272a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #27272a 75%),
    linear-gradient(-45deg, transparent 75%, #27272a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.checkerboard-light {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* Drag & Drop Zone Active States */
.dropzone-transition {
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropzone-active {
  border-color: #6366f1 !important;
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.18) 0%, rgba(17, 24, 39, 0.6) 100%) !important;
  transform: scale(1.008);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

/* Custom Range Input (Quality Slider & Split Handle) */
input[type="range"].optima-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1 0%, #10b981 var(--slider-pct, 82%), #1e293b var(--slider-pct, 82%));
  outline: none;
  cursor: pointer;
}

input[type="range"].optima-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #6366f1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"].optima-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.25);
}

input[type="range"].optima-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.08);
}

input[type="range"].optima-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #6366f1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Split-Screen Before / After Interactive Viewport */
.split-viewport {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  touch-action: none;
}

.split-after-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-before-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: inset(0 calc(100% - var(--split-pos, 50%)) 0 0);
}

.split-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split-pos, 50%);
  width: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), #6366f1, rgba(255,255,255,0.95));
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

.split-divider-handle {
  position: absolute;
  top: 50%;
  left: var(--split-pos, 50%);
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: #0f172a;
  border: 2px solid #ffffff;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 0 4px rgba(99, 102, 241, 0.35);
  cursor: ew-resize;
  z-index: 25;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.split-divider-handle:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background: #4f46e5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #090d16;
}

::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 9999px;
  border: 2px solid #090d16;
}

::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Pulse animation for active parallel workers */
@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.worker-busy-dot {
  animation: pulse-ring 1.5s infinite;
}

/* Light mode overrides for key surfaces */
html.light body {
  background-color: #f1f5f9;
  color: #0f172a;
}

html.light .glass-panel {
  background-color: rgba(255, 255, 255, 0.92) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
  color: #0f172a;
}

html.light .text-slate-100,
html.light .text-white {
  color: #0f172a !important;
}

html.light .text-slate-300,
html.light .text-slate-400 {
  color: #475569 !important;
}

html.light .bg-slate-900\/80,
html.light .bg-slate-900\/60,
html.light .bg-slate-950\/80,
html.light .bg-slate-900 {
  background-color: #ffffff !important;
}

html.light .bg-slate-800\/70,
html.light .bg-slate-800\/60,
html.light .bg-slate-800 {
  background-color: #f1f5f9 !important;
}

html.light .border-slate-800,
html.light .border-slate-800\/80,
html.light .border-slate-700\/60 {
  border-color: #cbd5e1 !important;
}
