:root {
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --secondary-color: #10b981;
  --accent-color: #f59e0b;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --success-color: #10b981;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --border-color: #334155;
  --border-light: #475569;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.3s ease;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--gradient-primary);
  color: white;
  padding: var(--space-lg) 0;
  box-shadow: var(--shadow-lg);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.logo-animation {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-icon {
  font-size: 3rem;
  animation: bounce 2s infinite;
}

.logo-text h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.logo-text p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.header-stats {
  display: flex;
  gap: var(--space-xl);
}

.stat-item {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: 0.8rem;
  opacity: 0.9;
}

.dashboard {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

@media (min-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
      "upload output"
      "processing output";
  }
  
  .upload-section { grid-area: upload; }
  .processing-section { grid-area: processing; }
  .output-section { grid-area: output; }
}

.dashboard-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.card-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.3rem;
  font-weight: 600;
}

.drop-zone {
  border: 3px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: all 0.3s ease;
  background: var(--bg-secondary);
  margin-bottom: var(--space-lg);
  position: relative;
}

.drop-zone.active {
  border-color: var(--primary-color);
  background: var(--bg-tertiary);
  transform: scale(1.02);
}

.drop-content {
  pointer-events: none;
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.7;
}

.drop-zone h3 {
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.drop-zone p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.image-preview-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.preview-header {
  padding: var(--space-md);
  background: var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.preview-content {
  position: relative;
  padding: var(--space-md);
  text-align: center;
}

#imagePreview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  padding: var(--space-md);
}

.preview-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.btn-primary, .btn-extract, .btn-action {
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.btn-extract {
  background: var(--gradient-primary);
  color: white;
  font-size: 1.1rem;
  justify-content: center;
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: var(--space-lg);
}

.btn-extract:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-extract:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-loading {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.btn-action {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-action:hover {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

.btn-clear {
  background: var(--error-color);
  color: white;
}

.btn-clear:hover {
  background: #dc2626;
}

.btn-small {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.8rem;
}

.btn-small:hover {
  background: var(--bg-secondary);
}

.btn-danger {
  background: var(--error-color);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-theme {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: var(--space-md);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.btn-theme:hover {
  background: var(--bg-tertiary);
  transform: rotate(15deg);
}

.processing-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.option-group label {
  font-weight: 600;
  color: var(--text-primary);
}

.styled-select {
  padding: var(--space-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.styled-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.adjustment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.adjustment-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.adjustment-item label {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

.adjustment-item input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-color);
  outline: none;
  -webkit-appearance: none;
}

.adjustment-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}

.progress-container {
  margin-top: var(--space-md);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  text-align: center;
}

.output-stats {
  display: flex;
  gap: var(--space-md);
}

.stat-badge {
  background: var(--gradient-secondary);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.7rem;
  opacity: 0.9;
}

.stat-value {
  font-weight: 700;
  font-size: 1rem;
}

.output-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.action-tools {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.text-output-container {
  position: relative;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 400px;
}

#textOutput {
  width: 100%;
  height: 400px;
  padding: var(--space-lg);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  z-index: 2;
  position: relative;
}

.text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--space-lg) 0;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .header-stats {
    justify-content: center;
  }
  
  .adjustment-grid {
    grid-template-columns: 1fr;
  }
  
  .output-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-tools {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}