/* ===========================
   Design System & Variables
   =========================== */
:root {
  --bg-primary: #0a0b0f;
  --bg-secondary: #12141c;
  --bg-tertiary: #1a1d2a;
  --bg-card: rgba(26, 29, 42, 0.7);
  --bg-glass: rgba(26, 29, 42, 0.4);
  
  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b4;
  --text-muted: #636b80;
  
  --accent-primary: #6c5ce7;
  --accent-secondary: #a29bfe;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe, #74b9ff);
  --accent-glow: rgba(108, 92, 231, 0.3);
  
  --success: #00cec9;
  --success-bg: rgba(0, 206, 201, 0.1);
  --warning: #fdcb6e;
  --error: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.1);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(116, 185, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 50% 60% at 50% 80%, rgba(162, 155, 254, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===========================
   App Layout
   =========================== */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===========================
   Header
   =========================== */
.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  background: var(--bg-glass);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-glow);
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.engine-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-normal);
}

.status-dot.loading {
  background: var(--warning);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.ready {
  background: var(--success);
  box-shadow: 0 0 8px rgba(0, 206, 201, 0.5);
}

.status-dot.error {
  background: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===========================
   Main Content
   =========================== */
.main {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
  flex: 1;
}

/* ===========================
   Upload Zone
   =========================== */
.upload-section {
  margin-bottom: 24px;
}

.upload-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-xl);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-slow);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-slow);
  border-radius: inherit;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.upload-zone:hover::before,
.upload-zone.drag-over::before {
  opacity: 0.04;
}

.upload-zone > * {
  position: relative;
  z-index: 1;
}

.upload-icon {
  color: var(--accent-secondary);
  margin-bottom: 16px;
  transition: transform var(--transition-slow);
}

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

.upload-zone h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.upload-formats {
  margin-top: 16px;
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
}

/* Options Bar */
.options-bar {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.option-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.option-group select,
.option-group input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  transition: border-color var(--transition-fast);
  outline: none;
}

.option-group select:hover,
.option-group input:hover {
  border-color: var(--border-hover);
}

.option-group select:focus,
.option-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===========================
   File Info Bar
   =========================== */
.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  animation: slideUp 0.3s var(--transition-slow);
}

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

.file-icon {
  font-size: 1.5rem;
}

.file-name {
  font-weight: 500;
  font-size: 0.95rem;
  display: block;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-extract {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-glow);
}

.btn-extract:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 48px var(--accent-glow);
}

.btn-extract:active {
  transform: translateY(0);
}

.btn-extract:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===========================
   Progress
   =========================== */
.progress-section {
  margin-bottom: 24px;
  animation: slideUp 0.3s ease;
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 100px;
  width: 0%;
  transition: width 0.5s ease;
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ===========================
   Results Section
   =========================== */
.results-section {
  animation: slideUp 0.4s ease;
}

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

.results-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.results-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--bg-tertiary);
}

.meta-item .label {
  color: var(--text-secondary);
  font-weight: 500;
}

.meta-item.engine {
  color: var(--accent-secondary);
  background: rgba(108, 92, 231, 0.12);
}

/* Results Actions */
.results-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-action.copied {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-bg);
}

.btn-new {
  margin-left: auto;
  border-color: var(--accent-primary);
  color: var(--accent-secondary);
}

.btn-new:hover {
  background: rgba(108, 92, 231, 0.15);
}

/* Results Content */
.results-content {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  max-height: 600px;
  overflow-y: auto;
}

.results-content pre {
  padding: 24px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-primary);
}

/* Custom scrollbar */
.results-content::-webkit-scrollbar {
  width: 6px;
}

.results-content::-webkit-scrollbar-track {
  background: transparent;
}

.results-content::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.results-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===========================
   Error Section
   =========================== */
.error-section {
  animation: slideUp 0.3s ease;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: var(--radius-md);
  background: var(--error-bg);
  text-align: center;
}

.error-icon {
  font-size: 2rem;
}

.error-content p {
  color: var(--error);
  font-size: 0.9rem;
  max-width: 500px;
}

/* ===========================
   Footer
   =========================== */
.footer {
  text-align: center;
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ===========================
   Animations
   =========================== */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 640px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .upload-zone {
    padding: 40px 24px;
  }

  .options-bar {
    flex-direction: column;
  }

  .file-info {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .btn-extract {
    justify-content: center;
  }

  .results-actions {
    flex-wrap: wrap;
  }

  .btn-new {
    margin-left: 0;
    flex: 1;
    justify-content: center;
  }

  .results-meta {
    width: 100%;
  }
}
