/* BeforeAfter — Design System */
:root {
  /* Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --bg-input: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border: #334155;
  --border-light: #475569;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  position: relative;
}

/* Header */
.app-header {
  padding: var(--space-lg) var(--space-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.logo {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.tagline {
  color: rgba(255,255,255,0.8);
  font-size: var(--text-sm);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: calc(80px + var(--space-md));
  overflow-y: auto;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Screen Header */
.screen-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.screen-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

.btn-back {
  background: none;
  border: none;
  color: var(--primary-light);
  font-size: var(--text-base);
  cursor: pointer;
  padding: var(--space-sm);
  margin-left: calc(-1 * var(--space-sm));
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

.btn-large {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-icon {
  font-size: var(--text-lg);
}

/* Action Buttons */
.action-buttons {
  margin-bottom: var(--space-lg);
}

/* Sections */
.section {
  margin-bottom: var(--space-xl);
}

.section-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Project Cards */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.project-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.project-card:hover {
  background: var(--bg-elevated);
  transform: translateX(4px);
}

.project-icon {
  font-size: var(--text-2xl);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.project-info {
  flex: 1;
}

.project-info h3 {
  font-size: var(--text-base);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.project-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.project-preview {
  display: flex;
  gap: var(--space-xs);
}

.preview-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.preview-thumb.before {
  background: linear-gradient(135deg, #475569, #334155);
}

.preview-thumb.after {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* Category Chips */
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.category-chip {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-chip:hover,
.category-chip.active {
  background: var(--primary);
  color: white;
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.textarea {
  min-height: 80px;
  resize: vertical;
}

/* Category Selector */
.category-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.cat-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-btn:hover {
  border-color: var(--primary);
}

.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Camera Preview */
.camera-preview {
  margin-bottom: var(--space-lg);
}

.camera-viewfinder {
  position: relative;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewfinder-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}

.viewfinder-grid::before,
.viewfinder-grid::after {
  content: '';
  position: absolute;
}

.viewfinder-center {
  text-align: center;
  color: var(--text-secondary);
}

.camera-icon {
  font-size: 48px;
  display: block;
  margin-bottom: var(--space-sm);
}

.camera-controls {
  padding: var(--space-md);
}

.camera-info {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.info-badge {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--success);
}

/* Ghost Overlay Mode */
.ghost-mode .camera-viewfinder {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.ghost-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.4;
}

.ghost-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.alignment-indicators {
  position: absolute;
  bottom: var(--space-md);
  left: var(--space-md);
  right: var(--space-md);
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.indicator {
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0,0,0,0.7);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
}

.indicator.aligned {
  color: var(--success);
}

.indicator.warning {
  color: var(--warning);
}

.opacity-control {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.opacity-control input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

/* Comparison Modes */
.comparison-modes {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  background: var(--bg-card);
  padding: var(--space-xs);
  border-radius: var(--radius-md);
}

.mode-btn {
  flex: 1;
  padding: var(--space-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

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

.mode-btn.active {
  background: var(--primary);
  color: white;
}

/* Comparison Views */
.comparison-view {
  display: none;
  margin-bottom: var(--space-lg);
}

.comparison-view.active {
  display: block;
}

/* Side by Side */
.side-by-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.comparison-panel {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.comparison-panel img {
  width: 100%;
  display: block;
}

.panel-label {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0,0,0,0.7);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.panel-label.after {
  background: var(--primary);
}

.panel-date {
  position: absolute;
  bottom: var(--space-sm);
  left: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0,0,0,0.7);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Slider Comparison */
.slider-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.slider-before,
.slider-after {
  position: absolute;
  inset: 0;
}

.slider-before img,
.slider-after img {
  width: 100%;
  display: block;
}

.slider-after {
  clip-path: inset(0 0 0 50%);
}

.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.handle-line {
  flex: 1;
  width: 2px;
  background: white;
}

.handle-circle {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--bg-dark);
  box-shadow: var(--shadow-md);
}

.slider-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
}

/* Fade Comparison */
.fade-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.fade-before,
.fade-after {
  width: 100%;
  display: block;
}

.fade-after {
  position: absolute;
  inset: 0;
  opacity: 0.5;
}

.fade-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.fade-controls input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: var(--radius-full);
}

.fade-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

/* Comparison Stats */
.comparison-stats {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat {
  flex: 1;
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: var(--text-base);
  font-weight: 600;
}

/* Action Row */
.action-row {
  display: flex;
  gap: var(--space-sm);
}

.action-row .btn {
  flex: 1;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: var(--text-xl);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--success);
  color: white;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
}

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

.toast-icon {
  font-size: var(--text-lg);
}

/* Responsive */
@media (max-width: 430px) {
  .app-container {
    max-width: 100%;
  }
  
  .bottom-nav {
    max-width: 100%;
  }
}
