/* Import modern Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS variables for consistent design tokens */
:root {
  --bg-primary: #080710;
  --bg-secondary: #0f0e1c;
  --card-bg: rgba(17, 16, 32, 0.65);
  --card-border: rgba(139, 92, 246, 0.15);
  --card-border-hover: rgba(139, 92, 246, 0.35);
  
  --primary-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
  --primary-color: #8b5cf6;
  --primary-hover: #a78bfa;
  --secondary-color: #06b6d4;
  --secondary-hover: #22d3ee;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --shadow-neon: 0 0 20px rgba(139, 92, 246, 0.15);
  --shadow-neon-hover: 0 0 30px rgba(139, 92, 246, 0.3);
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  
  --slider-percent: 50%;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
}

/* Container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.8s ease;
}

.logo-container {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.nexus-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background-color: #ffffff;
  border-radius: 12px;
  padding: 3px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.logo-container:hover .nexus-logo {
  transform: scale(1.08) rotate(3deg);
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.5);
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 0.5rem;
  font-weight: 300;
}

/* Main Grid Layout */
.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  flex: 1;
  align-items: start;
}

@media (min-width: 992px) {
  .app-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

/* Glassmorphism Card Base */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--card-border-hover);
}

/* Drag & Drop Area */
.upload-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dropzone {
  border: 2px dashed var(--card-border);
  border-radius: 18px;
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
  z-index: 0;
}

.dropzone:hover {
  border-color: var(--primary-color);
  background: rgba(139, 92, 246, 0.03);
  transform: translateY(-2px);
  box-shadow: var(--shadow-neon);
}

.dropzone.dragover {
  border-color: var(--secondary-color);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.2);
  transform: scale(1.02);
}

.dropzone-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.upload-icon-wrapper {
  width: 70px;
  height: 70px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  transition: transform var(--transition-normal), background var(--transition-normal);
}

.dropzone:hover .upload-icon-wrapper {
  transform: scale(1.1) rotate(5deg);
  background: rgba(139, 92, 246, 0.2);
}

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

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

.file-limit-text {
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
  margin-top: 0.25rem;
}

.hidden-input {
  display: none;
}

/* Example Gallery */
.gallery-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.gallery-section h4 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.example-thumb {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.05);
  position: relative;
  transition: all var(--transition-fast);
  background-color: #1a1a2e;
}

.example-thumbimg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

.example-thumb:hover {
  border-color: var(--primary-color);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.example-thumb:hover img {
  transform: scale(1.1);
}

.example-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.65rem;
  padding: 2px 4px;
  text-align: center;
  backdrop-filter: blur(4px);
}

/* Right Side: Preview Card */
.preview-card {
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

.preview-card.has-content {
  justify-content: space-between;
  align-items: stretch;
}

/* Placeholder state */
.preview-placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
}

.preview-placeholder-icon {
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.05);
  margin-bottom: 0.5rem;
  animation: pulse 3s infinite ease-in-out;
}

/* Loading state */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 320px;
}

.spinner-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
}

.spinner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid rgba(139, 92, 246, 0.1);
  border-top-color: var(--primary-color);
  animation: spin 1s infinite linear;
}

.spinner-inner {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border-radius: 50%;
  border: 3px solid rgba(6, 182, 212, 0.1);
  border-bottom-color: var(--secondary-color);
  animation: spin 1.5s infinite linear reverse;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  border-radius: 3px;
  transition: width 0.2s ease;
  position: absolute;
  top: 0;
  left: 0;
}

.loading-status {
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  color: var(--text-primary);
}

.loading-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Compare View Component */
.compare-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 16px;
  overflow: hidden;
  background-color: #0c0b16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  user-select: none;
}

/* Checkerboard transparency background */
.checkerboard {
  background-color: #12111d;
  background-image: 
    linear-gradient(45deg, #1b1a2a 25%, transparent 25%, transparent 75%, #1b1a2a 75%, #1b1a2a),
    linear-gradient(45deg, #1b1a2a 25%, transparent 25%, transparent 75%, #1b1a2a 75%, #1b1a2a);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}

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

/* The 'Before' image sits on top and is clipped */
.image-before {
  z-index: 2;
  clip-path: polygon(0 0, var(--slider-percent) 0, var(--slider-percent) 100%, 0 100%);
}

/* The 'After' image sits behind and is not clipped (but is on checkerboard) */
.image-after {
  z-index: 1;
}

/* Vertical slider control line */
.compare-slider-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--slider-percent);
  width: 2px;
  background: white;
  z-index: 3;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), 0 0 4px rgba(139, 92, 246, 0.8);
}

.compare-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 0 0 10px rgba(139, 92, 246, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  pointer-events: auto;
  transition: transform 0.1s ease, background-color 0.2s ease;
}

.compare-slider-handle:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background-color: #f3e8ff;
}

.compare-slider-handle svg {
  width: 20px;
  height: 20px;
  fill: var(--primary-color);
}

/* Slider labels 'Before' / 'After' */
.compare-label {
  position: absolute;
  bottom: 12px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: white;
  z-index: 4;
  pointer-events: none;
}

.label-before {
  left: 12px;
}

.label-after {
  right: 12px;
}

/* Control Panel (Buttons) */
.controls-wrapper {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.action-buttons-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: 'Outfit', sans-serif;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
  flex: 1;
  min-width: 150px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, #9b6cff, #fd5ba8);
}

.btn-primary:active {
  transform: translateY(1px);
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Quality setting styling */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.select-wrapper {
  position: relative;
  display: inline-block;
  flex: 1;
}

.select-control {
  width: 100%;
  appearance: none;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select-control:hover, .select-control:focus {
  border-color: var(--primary-color);
}

.select-wrapper::after {
  content: '▼';
  font-size: 0.65rem;
  color: var(--text-muted);
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(17, 16, 32, 0.9);
  border: 1px solid var(--primary-color);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), var(--shadow-neon);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: auto;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Keyframe Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.5; }
}

/* Utility classes for animations */
.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
