/* Design System & Core Tokens */
:root {
  --bg-color: #080b11;
  --card-bg: rgba(17, 24, 39, 0.55);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-glow-active: rgba(99, 102, 241, 0.15);
  
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --secondary-gradient: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-color: #818cf8;
  --accent-hover: #a78bfa;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background Glow Effects */
.background-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 40%);
  z-index: -1;
  pointer-events: none;
}

/* Header & Intro */
header {
  text-align: center;
  margin-top: 3rem;
  margin-bottom: 2rem;
  max-width: 600px;
  width: 90%;
  animation: fadeIn 0.8s ease-out;
}

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

.logo-emoji {
  font-size: 2.5rem;
  animation: wave 2.5s infinite ease-in-out;
}

h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.gradient-text {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Main Container Layout */
.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 1050px;
  width: 92%;
  margin-bottom: 4rem;
  z-index: 10;
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* LIVE Indicator */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: #ef4444;
  border-radius: 50%;
  animation: pulse 1.5s infinite ease-in-out;
}

/* Canvas Area (Interactive Preview) */
.canvas-wrapper {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background-color: #0d1220;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

#editor-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: grab;
}

#editor-canvas:active {
  cursor: grabbing;
}

.canvas-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: rgba(13, 18, 32, 0.9);
  color: var(--text-secondary);
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.placeholder-icon {
  font-size: 3rem;
  opacity: 0.8;
  animation: pulse 2s infinite ease-in-out;
}

.canvas-placeholder p {
  font-size: 0.95rem;
  max-width: 250px;
  line-height: 1.4;
}

/* Actions in Canvas card */
.action-block {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.action-block #download-link {
  flex: 1.6;
}

.action-block #reset-btn {
  flex: 0.7;
}

/* Info badge footer below preview */
.info-footer {
  display: flex;
  justify-content: space-around;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.info-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.badge-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Upload Card Styles */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
  background-color: rgba(255, 255, 255, 0.01);
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-color);
  background-color: var(--card-glow-active);
}

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

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-icon {
  font-size: 1.8rem;
  transition: var(--transition-smooth);
}

.drop-zone:hover .upload-icon {
  transform: translateY(-3px);
}

.upload-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.upload-text .highlight {
  color: var(--accent-color);
  text-decoration: underline;
}

/* Upload status */
.upload-status {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: fadeIn 0.4s ease-out;
}

.status-icon {
  font-size: 1rem;
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 50%;
  flex-shrink: 0;
}

.status-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.status-filename {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-action {
  font-size: 0.78rem;
  color: var(--accent-color);
  cursor: pointer;
  text-decoration: underline;
  transition: var(--transition-fast);
}

.status-action:hover {
  color: var(--accent-hover);
}

/* Config disabled wrapper */
.disabled-controls {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.5);
  transition: var(--transition-smooth);
}

/* Collapsible advanced section */
.advanced-details {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.advanced-details summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-color);
  cursor: pointer;
  outline: none;
  user-select: none;
  margin-bottom: 1.25rem;
  transition: var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.advanced-details summary:hover {
  color: var(--accent-hover);
}

/* Control Elements */
.control-group {
  margin-bottom: 1.25rem;
}

.control-row {
  display: flex;
  gap: 1rem;
}

.half-width {
  flex: 1;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.label-row label {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
  transition: var(--transition-fast);
}

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

.value-display {
  font-size: 0.88rem;
  font-weight: 600;
  width: 50px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent-color);
}

/* Toggle Custom Switch */
.toggle-group {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: normal;
}

.toggle-label input {
  display: none;
}

.custom-toggle {
  width: 38px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  transition: var(--transition-smooth);
}

.custom-toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: var(--transition-smooth);
}

.toggle-label input:checked + .custom-toggle {
  background: var(--accent-color);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.toggle-label input:checked + .custom-toggle::after {
  transform: translateX(18px);
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
  text-decoration: none;
}

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

.btn-secondary:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-success {
  background: var(--success-gradient);
  color: var(--text-primary);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(.disabled-btn) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.45);
}

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

.btn.disabled-btn {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.5);
}

/* Loading Spinners */
.spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none !important;
}

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

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

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

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(15deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  body {
    padding: 0 1rem;
  }
  
  header {
    margin-top: 2rem;
    margin-bottom: 1.5rem;
  }
  
  h1 {
    font-size: 2.2rem;
  }
  
  .card {
    padding: 1.5rem;
  }
}
