/* Modern CSS Reset & Variables */
:root {
  --font-family: 'Outfit', sans-serif;
  --bg-color: #0b0f19;
  --card-bg: rgba(17, 24, 39, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #5856d6;
  --primary-glow: rgba(88, 86, 214, 0.4);
  --primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f97316;
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Atmospheric Glowing Background */
.glass-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(88, 86, 214, 0.15) 0%, rgba(6, 182, 212, 0.08) 50%, rgba(11, 15, 25, 0) 100%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1200px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Header */
.app-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

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

.magic-icon {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.logo h1 span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  background: rgba(88, 86, 214, 0.15);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(88, 86, 214, 0.3);
  margin-left: 10px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 300;
  max-width: 600px;
}

/* Grid Layout */
.app-main {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr;
  gap: 30px;
  width: 100%;
}

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

/* Custom Glass Card UI */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.card-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h3 i {
  color: var(--accent-cyan);
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius-md);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 260px;
  position: relative;
  overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(88, 86, 214, 0.05);
  box-shadow: 0 0 15px rgba(88, 86, 214, 0.15);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.6rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.upload-zone:hover .upload-icon-wrapper {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  transform: translateY(-4px);
}

.upload-content h4 {
  font-size: 1.1rem;
  font-weight: 500;
}

.upload-content p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Preview Image Canvas */
.preview-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#editorCanvas {
  max-width: 100%;
  max-height: 380px;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  cursor: crosshair;
}

.canvas-overlay-tip {
  position: absolute;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-cyan);
  pointer-events: none;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 0.8; }
  50% { opacity: 0.4; }
  100% { opacity: 0.8; }
}

/* Section Labels */
.section-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.section-label .help-text {
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  font-size: 0.8rem;
}

/* Mode Selector Switch */
.mode-selector-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255,255,255,0.05);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.mode-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.mode-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* Target Chips */
.target-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 30px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.chip.active {
  background: rgba(88, 86, 214, 0.15);
  border-color: var(--primary);
  color: #c7d2fe;
}

/* Specific styling for active chip types matching screenshots */
.chip[data-target="watermark"].active {
  background: rgba(88, 86, 214, 0.12);
  border-color: var(--primary);
  color: #a5b4fc;
}

.chip[data-target="logo"].active {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--accent-red);
  color: #fca5a5;
}

.chip[data-target="text"].active {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--accent-orange);
  color: #fed7aa;
}

.chip[data-target="stamp"].active {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--accent-green);
  color: #a7f3d0;
}

.chip[data-target="signature"].active {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--accent-cyan);
  color: #cffafe;
}

/* Brush Controls */
.brush-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

#brushVal {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.slider-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

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

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
  transition: transform 0.1s;
}

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

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  border: none;
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(88, 86, 214, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--border-radius-sm);
}

/* Results Displays States */
.result-display {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--border-radius-md);
  border: 1px dashed rgba(255,255,255,0.05);
  padding: 20px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.empty-icon-wrapper {
  font-size: 3rem;
  color: rgba(255,255,255,0.08);
}

.empty-state h4 {
  font-size: 1.1rem;
  font-weight: 500;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 250px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(88, 86, 214, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state h4 {
  font-size: 1.1rem;
  font-weight: 500;
}

.loading-state p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Output Layout (Before/After) */
.output-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.comparison-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

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

.image-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.01);
  border-radius: var(--border-radius-md);
  padding: 10px;
  overflow: hidden;
}

.image-box img {
  max-width: 100%;
  max-height: 350px;
  border-radius: var(--border-radius-sm);
  object-fit: contain;
}

.image-label {
  position: absolute;
  top: 18px;
  left: 18px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.1);
}

.image-label.processed {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.2);
}

/* Footer */
.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Tool Tabs Selection Styles */
.tool-tabs-container {
  display: flex;
  justify-content: center;
  width: 100%;
}

.tool-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px;
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  box-shadow: 0 4px 15px var(--primary-glow);
}

/* Before/After Comparison Slider Styles */
.slider-comparison-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.comparison-slider {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
  cursor: col-resize;
  background: #090d16;
}

.slider-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.slider-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  clip-path: inset(0 0 0 50%);
  pointer-events: none;
}

.slider-overlay .slider-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slider-label {
  position: absolute;
  top: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.5px;
  z-index: 5;
  pointer-events: none;
}

.label-before {
  left: 16px;
  color: var(--text-main);
}

.label-after {
  right: 16px;
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.2);
}

.slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 40px;
  height: 100%;
  margin-left: -20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: col-resize;
}

.slider-handle-line {
  width: 2px;
  flex: 1;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.slider-handle-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  border: 2.5px solid #fff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  box-shadow: 0 0 12px var(--primary-glow);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slider-handle:hover .slider-handle-button {
  transform: scale(1.15);
  box-shadow: 0 0 16px var(--primary-glow);
}

