/* ===== Variables ===== */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --accent: #a855f7;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.4);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.4);
  --bg-dark: #050508;
  --bg-card: rgba(255, 255, 255, 0.02);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --text-muted: #64748b;
  --radius: 20px;
  --radius-sm: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== Background ===== */
.bg-animation { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg-gradient { 
  position: absolute; 
  inset: 0; 
  background: 
    radial-gradient(ellipse at 50% -20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
}
.floating-orbs { position: absolute; inset: 0; }
.orb { 
  position: absolute; 
  border-radius: 50%; 
  filter: blur(100px); 
  opacity: 0.2; 
  animation: orbFloat 30s ease-in-out infinite; 
}
.orb-1 { width: 500px; height: 500px; background: var(--primary); top: -150px; right: -150px; }
.orb-2 { width: 350px; height: 350px; background: var(--accent); bottom: -100px; left: -100px; animation-delay: -12s; }
.orb-3 { width: 200px; height: 200px; background: var(--success); top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: -20s; opacity: 0.1; }
@keyframes orbFloat { 
  0%, 100% { transform: translate(0, 0) scale(1); } 
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* ===== Layout ===== */
.app-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition-slow);
}

/* Processing state - center content */
body.processing .app-container {
  justify-content: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2.5rem;
  opacity: 1;
  transform: translateY(0);
  transition: var(--transition-slow);
  max-height: 100px;
  overflow: hidden;
}

body.processing .header {
  opacity: 0;
  transform: translateY(-20px);
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: var(--radius-sm);
  color: white;
}
.logo-icon svg { width: 24px; height: 24px; }

.logo-text { text-align: left; }
.logo-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===== Steps Bar ===== */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  transition: var(--transition-slow);
}

body.processing .steps-bar {
  transform: scale(0.85);
  margin-bottom: 1.5rem;
}

body.completed .steps-bar {
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}

.step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
  cursor: default;
}
.step-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
}
.step-check-icon {
  width: 16px;
  height: 16px;
  position: absolute;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition);
  color: #fff;
}
.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  transition: var(--transition);
}

/* Step States */
.step-dot.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.15);
  animation: stepPulse 2s ease-in-out infinite;
  box-shadow: 0 0 20px var(--primary-glow);
}
.step-dot.active .step-num { color: var(--primary-light); }
@keyframes stepPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); } 50% { box-shadow: 0 0 0 10px transparent; } }

.step-dot.completed {
  border-color: var(--success);
  background: var(--success);
  box-shadow: 0 0 15px var(--success-glow);
}
.step-dot.completed .step-num { opacity: 0; }
.step-dot.completed .step-check-icon { opacity: 1; transform: scale(1); }
.step-line.completed { background: var(--success); }

.step-dot.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 15px var(--error-glow);
}
.step-dot.error .step-num { color: var(--error); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  animation: cardIn 0.5s ease-out;
  transition: var(--transition);
}
.card:hover {
  border-color: var(--border-hover);
}

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

.main-content { flex: 1; display: flex; flex-direction: column; gap: 1rem; }

/* Hide upload card during processing */
body.processing .upload-card {
  display: none;
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  position: relative;
  overflow: hidden;
}
.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, var(--primary-glow), transparent 70%);
  opacity: 0;
  transition: var(--transition);
}
.dropzone:hover::before, .dropzone.dragover::before {
  opacity: 0.15;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  transform: scale(1.01);
}
.dropzone.has-file { display: none; }
.dropzone-content { position: relative; z-index: 1; }
.dropzone-icon { margin: 0 auto 1.25rem; }
.dropzone-icon svg { 
  width: 52px; 
  height: 52px; 
  color: var(--text-muted); 
  transition: var(--transition); 
}
.dropzone:hover .dropzone-icon svg { 
  color: var(--primary-light); 
  transform: translateY(-6px); 
}
.dropzone-text { 
  font-size: 1rem; 
  font-weight: 500;
  color: var(--text); 
  margin-bottom: 0.5rem; 
}
.dropzone-or { 
  font-size: 0.8rem; 
  color: var(--text-muted); 
  display: block; 
  margin: 0.75rem 0; 
}
.dropzone-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.dropzone-btn:hover { 
  background: rgba(255, 255, 255, 0.1); 
  border-color: var(--border-hover);
}

/* ===== File Selected ===== */
.file-selected {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
.file-icon svg { width: 32px; height: 32px; color: var(--primary-light); }
.file-info-text { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.file-name { font-size: 0.95rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.file-remove {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  border-radius: 8px;
}
.file-remove:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }
.file-remove svg { width: 18px; height: 18px; }

/* ===== Page Options ===== */
.page-options {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}
.page-options-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  list-style: none;
  padding: 0.25rem 0;
  transition: var(--transition);
}
.page-options-toggle:hover { color: var(--text); }
.page-options-toggle::-webkit-details-marker { display: none; }
.page-options-toggle .chevron { width: 16px; height: 16px; transition: var(--transition); }
.page-options[open] .chevron { transform: rotate(180deg); }
.page-options-content { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.radio-pill {
  display: inline-flex;
  cursor: pointer;
}
.radio-pill input { display: none; }
.radio-pill span {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  border-radius: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: var(--transition);
  font-weight: 500;
}
.radio-pill:hover span { border-color: var(--border-hover); }
.radio-pill input:checked + span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.page-input-wrap { width: 100%; margin-top: 0.75rem; }
.page-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.875rem;
  transition: var(--transition);
}
.page-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.page-input::placeholder { color: var(--text-muted); }

/* ===== Process Button ===== */
.btn-process {
  width: 100%;
  margin-top: 1.75rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-process::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  opacity: 0;
  transition: var(--transition);
}
.btn-process:hover:not(:disabled)::before { opacity: 1; }
.btn-process:hover:not(:disabled) { 
  transform: translateY(-3px); 
  box-shadow: 0 8px 30px var(--primary-glow); 
}
.btn-process:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-process .btn-text { position: relative; z-index: 1; }
.btn-process.loading .btn-text { opacity: 0; }
.btn-process.loading .btn-loader { opacity: 1; }
.btn-loader {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Progress Card ===== */
.progress-card { 
  text-align: center; 
  padding: 3rem 2rem; 
}
.progress-visual { margin-bottom: 2rem; }
.progress-ring { 
  position: relative; 
  width: 120px; 
  height: 120px; 
  margin: 0 auto; 
}
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: var(--border); stroke-width: 5; }
.progress-ring-fill {
  fill: none;
  stroke: url(#progressGradient);
  stroke: var(--primary);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}
.progress-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.progress-status { 
  font-size: 1rem; 
  font-weight: 500;
  color: var(--text); 
  margin-bottom: 0.5rem; 
}
.progress-detail { 
  font-size: 0.8rem; 
  color: var(--text-muted);
  line-height: 1.6;
}
.progress-detail-row {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}
.progress-eta {
  margin-top: 0.25rem;
  color: var(--primary-light);
  font-weight: 500;
}

/* ===== Result Card ===== */
.result-card { 
  text-align: center; 
  padding: 2.5rem 2rem; 
}
.result-icon { margin-bottom: 1.5rem; }
.result-icon svg { width: 72px; height: 72px; margin: 0 auto; }
.result-circle { 
  fill: none; 
  stroke: var(--success); 
  stroke-width: 2; 
  animation: circleIn 0.6s ease-out; 
  filter: drop-shadow(0 0 10px var(--success-glow));
}
@keyframes circleIn { from { stroke-dasharray: 0 200; } to { stroke-dasharray: 200 0; } }
.result-icon polyline { stroke: var(--success); animation: checkIn 0.4s ease-out 0.3s both; }
@keyframes checkIn { from { stroke-dasharray: 0 50; } to { stroke-dasharray: 50 0; } }

.result-stats { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 2.5rem; 
  margin-bottom: 2rem; 
}
.stat { text-align: center; }
.stat-value { 
  display: block; 
  font-size: 2.5rem; 
  font-weight: 700; 
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.stat-divider { width: 1px; height: 50px; background: var(--border); }

.btn-download {
  width: 100%;
  padding: 1rem;
  background: var(--success);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px var(--success-glow);
}
.btn-download:hover { 
  transform: translateY(-3px); 
  box-shadow: 0 8px 30px var(--success-glow); 
}
.btn-download svg { width: 22px; height: 22px; }

.btn-new {
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-new:hover { 
  background: rgba(255, 255, 255, 0.04); 
  color: var(--text); 
  border-color: var(--border-hover);
}

/* ===== Error Card ===== */
.error-card { text-align: center; padding: 2.5rem 2rem; }
.error-icon svg { 
  width: 56px; 
  height: 56px; 
  color: var(--error); 
  margin-bottom: 1.25rem;
  filter: drop-shadow(0 0 10px var(--error-glow));
}
.error-text { color: var(--text); font-size: 0.95rem; margin-bottom: 1.75rem; }
.btn-retry {
  padding: 0.75rem 2.5rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--error);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-retry:hover { 
  background: rgba(239, 68, 68, 0.2); 
  transform: translateY(-2px);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.875rem 1.5rem;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-success { border-color: rgba(16, 185, 129, 0.3); }
.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-icon { font-size: 1rem; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .app-container { padding: 2rem 1rem; }
  .logo-title { font-size: 1.25rem; }
  .logo-icon { width: 36px; height: 36px; }
  .logo-icon svg { width: 20px; height: 20px; }
  .step-dot { width: 32px; height: 32px; }
  .step-line { width: 30px; }
  .card { padding: 1.5rem; }
  .dropzone { padding: 2rem 1rem; }
  .dropzone-icon svg { width: 44px; height: 44px; }
  .progress-ring { width: 100px; height: 100px; }
  .progress-percent { font-size: 1.5rem; }
  .stat-value { font-size: 2rem; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.12); }
::selection { background: var(--primary); color: #fff; }
