/* AI Image Sanitizer — Design System & Stylesheet */

:root {
  /* Color Palette: Professional Dark Studio */
  --bg-base: hsl(220, 18%, 10%);
  --bg-surface: hsl(220, 16%, 14%);
  --bg-surface-elevated: hsl(220, 15%, 18%);
  --bg-surface-hover: hsl(220, 14%, 22%);
  --bg-input: hsl(220, 18%, 12%);
  
  --border-subtle: hsl(220, 12%, 22%);
  --border-strong: hsl(220, 12%, 30%);
  --border-focus: hsl(210, 80%, 55%);
  
  --text-primary: hsl(220, 20%, 96%);
  --text-secondary: hsl(220, 12%, 70%);
  --text-muted: hsl(220, 10%, 48%);
  
  --accent-primary: hsl(210, 85%, 52%);
  --accent-primary-hover: hsl(210, 85%, 46%);
  --accent-primary-active: hsl(210, 85%, 40%);
  --accent-text: hsl(0, 0%, 100%);
  
  --success: hsl(142, 70%, 45%);
  --success-bg: hsla(142, 70%, 45%, 0.12);
  --danger: hsl(0, 72%, 51%);
  --danger-bg: hsla(0, 72%, 51%, 0.12);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px hsla(0, 0%, 0%, 0.25);
  --shadow-md: 0 4px 12px hsla(0, 0%, 0%, 0.35);
  --shadow-lg: 0 12px 32px hsla(0, 0%, 0%, 0.45);
  
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --header-height: 56px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background-color: var(--accent-primary);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--success);
  background: var(--success-bg);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid hsla(142, 70%, 45%, 0.25);
}

/* Main Layout */
.app-main {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  min-height: calc(100vh - var(--header-height));
  background-color: var(--bg-base);
}

@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
}

/* Viewer Section */
.viewer-section {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  padding: 20px;
}

/* Dropzone */
.dropzone {
  display: none;
  flex: 1;
  min-height: 480px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.dropzone.active {
  display: flex;
}

.dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: var(--bg-surface-elevated);
  transform: scale(0.995);
}

.dropzone-content {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.dropzone-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.dropzone-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.file-input-hidden {
  display: none;
}

/* Preview Workspace */
.preview-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 14px;
  height: 100%;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.view-modes {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.mode-tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s ease;
}

.mode-tab-btn:hover {
  color: var(--text-primary);
}

.mode-tab-btn.active {
  background: var(--accent-primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.tool-btn.active {
  color: #fff;
  background: var(--accent-primary);
}

.tool-btn.text-danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* Comparison Stage */
.comparison-stage {
  flex: 1;
  min-height: 440px;
  background-color: hsl(220, 20%, 7%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.stage-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

.render-canvas {
  max-width: 100%;
  max-height: calc(100vh - 280px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-sm);
}

/* Original Overlay for Split Comparison */
.original-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.original-overlay .render-canvas {
  width: 100%;
  height: 100%;
}

/* Comparison Slider Divider */
.comparison-slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

.slider-handle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 2;
  transition: transform 0.1s ease;
}

.comparison-slider:hover .slider-handle {
  transform: scale(1.08);
}

/* Label Badges */
.label-badge {
  position: absolute;
  bottom: 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: hsla(220, 20%, 10%, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  z-index: 5;
}

.label-left {
  left: 14px;
  color: #f87171;
}

.label-right {
  right: 14px;
  color: #4ade80;
}

/* Batch Bar */
.batch-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.batch-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.batch-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.batch-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.batch-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.batch-thumb.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px hsla(210, 85%, 52%, 0.3);
}

.batch-thumb .thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: none;
}

.batch-thumb:hover .thumb-remove {
  display: flex;
}

/* Control Panel */
.control-panel {
  background: var(--bg-surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

.audit-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.audit-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.audit-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--success);
  background: var(--success-bg);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.audit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.audit-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-top: 4px;
  flex-shrink: 0;
}

.audit-item.inactive .audit-dot {
  background: var(--text-muted);
}

.audit-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audit-info strong {
  font-size: 0.75rem;
  color: var(--text-primary);
  line-height: 1.2;
}

.audit-info span {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Panel Section */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* Presets */
.preset-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.preset-btn.active {
  background: hsla(210, 85%, 52%, 0.1);
  border-color: var(--accent-primary);
}

.preset-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.preset-btn.active .preset-name {
  color: var(--accent-primary);
}

.preset-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-label label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.val-display {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-primary);
  background: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.control-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.select-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.select-input:focus {
  border-color: var(--border-focus);
}

.select-input option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Range Inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

/* Toggles */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-control input {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.2s ease;
}

.toggle-control input:checked + .toggle-switch {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle-control input:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: #ffffff;
}

.toggle-text {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

.btn-primary:active {
  background: var(--accent-primary-active);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--text-secondary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 4px 8px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.btn-sm {
  font-size: 0.75rem;
  padding: 4px 10px;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.95rem;
}

/* Export Box */
.export-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Metadata Modal */
.meta-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: hsla(220, 20%, 6%, 0.85);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 780px;
  max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.modal-title h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.meta-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .meta-comparison {
    grid-template-columns: 1fr;
  }
}

.meta-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-col h4 {
  font-size: 0.85rem;
  font-weight: 700;
}

.text-danger { color: #f87171; }
.text-success { color: #4ade80; }

.meta-content-box {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  min-height: 220px;
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

.meta-tag-highlight {
  color: #f87171;
  font-weight: 600;
}

.meta-clean-badge {
  color: #4ade80;
  font-weight: 600;
}
