:root {
  --bg-color: #0b0d13;
  --card-bg: rgba(22, 26, 38, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.25);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Background glows */
.glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

.glow-1 {
  background: var(--primary);
  top: -10%;
  left: -10%;
}

.glow-2 {
  background: var(--accent);
  bottom: 10%;
  right: -10%;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 5%;
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
  z-index: 10;
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo h1 span {
  color: var(--primary);
}

.header-tagline {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 20px;
}

/* Main Container Grid */
.app-container {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  max-width: 1400px;
  width: 90%;
  margin: 40px auto;
  flex: 1;
}

/* Panels */
.panel-left, .panel-right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: var(--transition-smooth);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* Upload Card */
.upload-card {
  position: relative;
  border: 2px dashed var(--card-border);
  cursor: pointer;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.upload-card.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 20px var(--primary-glow);
}

.upload-card.dragover .upload-icon {
  transform: translateY(-5px);
  color: var(--primary);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  width: 100%;
}

.upload-content button {
  pointer-events: auto; /* Allow click on browse button */
}

.upload-icon-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.upload-icon {
  width: 36px;
  height: 36px;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.upload-content h3 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
}

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

/* File Info Box */
.file-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.file-details {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.file-icon {
  background: rgba(255, 255, 255, 0.05);
  padding: 12px;
  border-radius: var(--border-radius-md);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon svg {
  width: 24px;
  height: 24px;
}

.text-info h4 {
  font-size: 15px;
  font-weight: 600;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--danger);
}

.btn-close svg {
  width: 18px;
  height: 18px;
}

/* Settings Card styling */
.settings-card h2, .result-card h2, .api-card h2 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  position: relative;
}

.settings-card.disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5);
}

.setting-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.setting-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.badge {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
}

/* Slider Customization */
.slider-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform 0.1s;
}

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

/* Select inputs */
.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "▾";
  font-size: 12px;
  color: var(--text-muted);
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  transition: var(--transition-smooth);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

/* Dimension inputs style */
.dimension-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
}

.input-wrapper input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 12px 36px 12px 14px;
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

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

.input-wrapper span {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.aspect-link-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 10px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.aspect-link-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.aspect-link-btn.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: rgba(16, 185, 129, 0.2);
}

.aspect-link-btn svg {
  width: 18px;
  height: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px var(--primary-glow);
  transform: translateY(-1px);
}

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

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.w-full {
  width: 100%;
}

.mt-4 {
  margin-top: 16px;
}

.flex-1 {
  flex: 1;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s ease-in-out infinite;
}

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

/* Result Card */
.result-card {
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

.empty-state {
  justify-content: center;
  align-items: center;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
}

.result-placeholder h3 {
  font-family: var(--font-title);
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 600;
}

.result-placeholder p {
  max-width: 280px;
  font-size: 14px;
}

/* Comparison Viewer (Split Slider) */
.comparison-container {
  position: relative;
  width: 100%;
  height: 380px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--card-border);
  margin-bottom: 24px;
}

.comparison-image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.comparison-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #11141e; /* background color behind image */
  background-image: linear-gradient(45deg, #181d28 25%, transparent 25%), 
                    linear-gradient(-45deg, #181d28 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #181d28 75%), 
                    linear-gradient(-45deg, transparent 75%, #181d28 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px; /* transparent pattern grid */
}

/* After layer is clip path'ed */
.comparison-image-wrapper.processed {
  width: 100%;
}

/* Compare badges */
.compare-badge {
  position: absolute;
  top: 16px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  z-index: 5;
}

.compare-badge.original {
  left: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.compare-badge.processed {
  right: 16px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Handle line */
.slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 100%;
  cursor: ew-resize;
  z-index: 10;
  pointer-events: auto;
}

.handle-line {
  position: absolute;
  left: -1px;
  top: 0;
  width: 2px;
  height: 100%;
  background: white;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.handle-circle {
  position: absolute;
  top: 50%;
  left: -20px;
  margin-top: -20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-color);
  transition: transform 0.1s;
}

.slider-handle:hover .handle-circle {
  transform: scale(1.1);
}

.handle-circle svg {
  width: 20px;
  height: 20px;
}

/* Metrics Dashboard */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring-fill {
  transition: stroke-dashoffset 0.5s ease-out;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.savings-percent {
  position: absolute;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
}

.metric-details h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.metric-details p {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-card-details {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.detail-label {
  color: var(--text-muted);
}

.detail-val {
  font-weight: 600;
}

.detail-val.highlighted {
  color: var(--accent);
}

.action-row {
  display: flex;
  gap: 12px;
}

/* API Integration Card */
.api-card {
  margin-top: 0;
}

.api-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.api-header h2 {
  margin-bottom: 0;
}

.api-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 4px 10px;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  border-radius: 6px;
}

.api-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 16px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  position: relative;
  transition: var(--transition-smooth);
}

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

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

.tab-contents {
  background: #07090d;
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  max-height: 280px;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

pre {
  margin: 0;
}

code {
  font-family: 'Fira Code', 'Courier New', Courier, monospace;
  font-size: 12.5px;
  color: #e5e7eb;
  line-height: 1.6;
}

/* Footer styling */
.app-footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 12px;
  margin-top: auto;
}

/* Utility helpers */
.hidden {
  display: none !important;
}

/* Responsiveness */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    width: 95%;
    margin: 20px auto;
  }
  
  .panel-left, .panel-right {
    gap: 20px;
  }
}

@media (max-width: 480px) {
  .app-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .setting-grid {
    grid-template-columns: 1fr;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .comparison-container {
    height: 260px;
  }
}

/* Background Removal Preview & Checkerboard */
.checkerboard {
  background-color: #11141e;
  background-image: linear-gradient(45deg, #161a25 25%, transparent 25%), 
                    linear-gradient(-45deg, #161a25 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #161a25 75%), 
                    linear-gradient(-45deg, transparent 75%, #161a25 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.bg-removed-preview-container {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--card-border);
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.bg-removed-preview-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Tool Navigation Tabs */
.tool-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: rgba(20, 24, 35, 0.5);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  border-radius: 40px;
  padding: 6px;
  max-width: 500px;
  width: 90%;
  margin: 40px auto -10px auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.tool-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-smooth);
}

.tool-nav-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tool-nav-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.tool-icon {
  width: 18px;
  height: 18px;
  color: inherit;
}

/* Specific button styles */
#btn-tool-bg.active {
  background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}

#btn-tool-crop.active {
  background: #f59e0b;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

/* Manual Crop Workspace and Overrides */
.crop-workspace {
  width: 100%;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #07090d;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--card-border);
}

.crop-workspace img {
  display: block;
  max-width: 100%;
  max-height: 400px;
}

.crop-result-preview-container {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--card-border);
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.crop-result-preview-container img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
  animation: fadeIn 0.4s ease-out;
}

/* Cropper Theme Overwrites */
.cropper-view-box {
  outline: 2px solid #f59e0b !important;
  outline-color: #f59e0b !important;
}

.cropper-line, .cropper-point {
  background-color: #f59e0b !important;
}

.cropper-point.point-se {
  width: 10px !important;
  height: 10px !important;
  opacity: 1 !important;
}

.cropper-bg {
  background-image: none !important;
  background-color: rgba(0, 0, 0, 0.6) !important;
}

.cropper-modal {
  background-color: rgba(0, 0, 0, 0.6) !important;
  opacity: 0.8 !important;
}
