/* ========== CSS Variables & Reset ========== */
/* Light theme (default) */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(241, 245, 249, 0.9);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #7c3aed;
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-cool: linear-gradient(135deg, #06b6d4, #3b82f6);
  --border-color: rgba(148, 163, 184, 0.25);
  --border-glow: rgba(99, 102, 241, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --particle-color: rgba(99, 102, 241, 0.15);
  --bg-gradient-1: rgba(99, 102, 241, 0.04);
  --bg-gradient-2: rgba(139, 92, 246, 0.03);
  --bg-gradient-3: rgba(6, 182, 212, 0.03);
  --preview-bg: rgba(241, 245, 249, 0.8);
  --scrollbar-thumb: rgba(148, 163, 184, 0.3);
  --scrollbar-thumb-hover: rgba(148, 163, 184, 0.5);

  /* Format card colors */
  --color-image: #0891b2;
  --color-word: #2563eb;
  --color-text: #7c3aed;
  --color-excel: #16a34a;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-3: #a78bfa;
  --border-color: rgba(148, 163, 184, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  --particle-color: rgba(167, 139, 250, 0.4);
  --bg-gradient-1: rgba(99, 102, 241, 0.08);
  --bg-gradient-2: rgba(139, 92, 246, 0.06);
  --bg-gradient-3: rgba(6, 182, 212, 0.05);
  --preview-bg: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb: rgba(148, 163, 184, 0.2);
  --scrollbar-thumb-hover: rgba(148, 163, 184, 0.3);
  --color-image: #06b6d4;
  --color-word: #3b82f6;
  --color-text: #8b5cf6;
  --color-excel: #22c55e;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ========== Animated Background ========== */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, var(--bg-gradient-1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, var(--bg-gradient-2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, var(--bg-gradient-3) 0%, transparent 50%);
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
  }
}

.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--particle-color);
  border-radius: 50%;
  animation: float linear infinite;
}

@keyframes float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* ========== Container ========== */
.container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== Header ========== */
.header {
  text-align: center;
  margin-bottom: 48px;
  animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  from {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
  }

  to {
    box-shadow: 0 4px 30px rgba(139, 92, 246, 0.5);
  }
}

.logo-icon svg {
  width: 32px;
  height: 32px;
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========== Navigation ========== */
.top-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 40px;
  animation: fadeInDown 0.8s ease-out 0.1s both;
}

.nav-item {
  padding: 10px 24px;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.nav-item:hover {
  color: var(--accent-1);
  border-color: var(--accent-1);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.15);
}

.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* ========== Upload Zone ========== */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.upload-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 0;
}

.upload-zone:hover {
  border-color: var(--accent-1);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.upload-zone:hover::before {
  opacity: 0.03;
}

.upload-zone.dragover {
  border-color: var(--accent-2);
  background: rgba(99, 102, 241, 0.08);
  transform: scale(1.02);
  box-shadow: 0 0 60px rgba(99, 102, 241, 0.2);
}

.upload-zone.dragover::before {
  opacity: 0.06;
}

.upload-content {
  position: relative;
  z-index: 1;
}

.upload-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  color: var(--accent-3);
  animation: uploadBounce 3s ease-in-out infinite;
}

@keyframes uploadBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.upload-icon svg {
  width: 100%;
  height: 100%;
}

.upload-zone h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.upload-hint {
  margin-top: 12px;
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
}

/* ========== File Info ========== */
.file-info {
  animation: fadeInUp 0.5s ease-out;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.file-icon {
  width: 48px;
  height: 48px;
  color: #ef4444;
  flex-shrink: 0;
}

.file-icon svg {
  width: 100%;
  height: 100%;
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-remove {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 50%;
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-remove:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.1);
}

.btn-remove svg {
  width: 18px;
  height: 18px;
}

/* ========== Format Section & File List ========== */
.format-section,
.file-list-section {
  margin-top: 32px;
  animation: fadeInUp 0.5s ease-out;
}

.format-section h3,
.file-list-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-align: center;
}

.file-list-section .hint,
.format-section .hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: -10px;
}

.file-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 8px;
}

.file-list-container::-webkit-scrollbar {
  width: 6px;
}

.file-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.file-list-container::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 10px;
}

.page-input {
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
  outline: none;
}

.page-input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.format-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-family: inherit;
}

.format-card:hover {
  border-color: var(--accent-1);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
}

.format-card.selected {
  border-color: var(--accent-1);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.15);
}

.format-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.format-icon svg {
  width: 28px;
  height: 28px;
}

.format-icon-image {
  background: rgba(6, 182, 212, 0.12);
  color: var(--color-image);
}

.format-icon-word {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-word);
}

.format-icon-text {
  background: rgba(139, 92, 246, 0.12);
  color: var(--color-text);
}

.format-icon-excel {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-excel);
}

.format-card.selected .format-icon-image {
  background: rgba(6, 182, 212, 0.25);
}

.format-card.selected .format-icon-word {
  background: rgba(59, 130, 246, 0.25);
}

.format-card.selected .format-icon-text {
  background: rgba(139, 92, 246, 0.25);
}

.format-card.selected .format-icon-excel {
  background: rgba(34, 197, 94, 0.25);
}

.format-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.format-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========== Convert Button ========== */
.action-section {
  margin-top: 32px;
  text-align: center;
  animation: fadeInUp 0.5s ease-out;
}

.btn-convert {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 48px;
  background: var(--gradient-primary);
  border: none;
  border-radius: 50px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  position: relative;
  overflow: hidden;
}

.btn-convert::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

.btn-convert:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.btn-convert:hover::before {
  left: 100%;
}

.btn-convert:active {
  transform: translateY(-1px) scale(0.98);
}

.btn-convert:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
}

/* ========== Progress ========== */
.progress-section {
  margin-top: 32px;
  animation: fadeInUp 0.5s ease-out;
}

.progress-card {
  text-align: center;
  padding: 40px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
}

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

.progress-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========== Result ========== */
.result-section,
.error-section {
  margin-top: 32px;
  animation: fadeInUp 0.5s ease-out;
}

.result-card,
.error-card {
  text-align: center;
  padding: 40px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
}

.result-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.result-icon.success {
  color: #22c55e;
  animation: successPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.result-icon.error {
  color: #ef4444;
}

@keyframes successPop {
  0% {
    transform: scale(0);
  }

  80% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

.result-icon svg {
  width: 100%;
  height: 100%;
}

.result-card h3,
.error-card h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.result-card p,
.error-card p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--gradient-primary);
  border: none;
  border-radius: 50px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.btn-download svg {
  width: 20px;
  height: 20px;
}

.btn-again {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.btn-again:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.btn-again svg {
  width: 20px;
  height: 20px;
}

/* ========== FAQ Section ========== */
.faq-section {
  margin-top: 64px;
  animation: fadeInUp 0.5s ease-out;
}

.faq-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.faq-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

.faq-question {
  width: 100%;
  text-align: left;
  padding: 18px 24px;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
}

.faq-question:hover {
  color: var(--accent-1);
}

.faq-question svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.faq-item.active .faq-question svg {
  transform: rotate(180deg);
  color: var(--accent-1);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, padding 0.3s ease;
  padding: 0 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  max-height: 400px;
  padding: 0 24px 18px 24px;
}

/* ========== Image Preview ========== */
.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--preview-bg);
}

.image-preview img {
  max-width: 200px;
  max-height: 260px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========== Footer ========== */
.footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== Theme Toggle ========== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  border-color: var(--accent-1);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.2);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: var(--transition);
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .container {
    padding: 24px 16px;
  }

  .logo {
    flex-direction: column;
    gap: 12px;
  }

  .logo h1 {
    font-size: 1.4rem;
  }

  .upload-zone {
    padding: 40px 20px;
  }

  .format-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .btn-convert {
    padding: 14px 36px;
    font-size: 1rem;
  }

  .result-actions {
    flex-direction: column;
    align-items: center;
  }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}