/* ===== CSS Variables & Reset ===== */
:root {
  --bg: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-elevated: #F4F4F5;
  --text: #18181B;
  --text-secondary: #71717A;
  --text-tertiary: #A1A1AA;
  --border: #E4E4E7;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-light: #EEF2FF;
  --accent-subtle: #C7D2FE;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --bg: #09090B;
  --bg-card: #18181B;
  --bg-elevated: #27272A;
  --text: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-tertiary: #71717A;
  --border: #3F3F46;
  --accent: #818CF8;
  --accent-hover: #6366F1;
  --accent-light: #1e1b4b;
  --accent-subtle: #312e81;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.2);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,250,0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

[data-theme="dark"] .header {
  background: rgba(9,9,11,0.8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

.nav a:hover {
  color: var(--text);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-tertiary);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 80px 0 64px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 100px;
  margin-bottom: 24px;
  border: 1px solid var(--accent-subtle);
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, #9333EA 50%, #EC4899 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.7;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius);
}

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: var(--accent-light);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Tools Grid ===== */
.tools-section {
  padding: 48px 0 80px;
}

.section-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-sub {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 48px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.tool-card:hover {
  border-color: var(--accent-subtle);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--icon-bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

[data-theme="dark"] .tool-icon {
  background: var(--icon-bg-dark);
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.tool-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Features ===== */
.features-section {
  padding: 64px 0 80px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  margin-top: 48px;
}

.feature-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--border);
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
  padding: 48px 0 24px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 8px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footer-bottom p {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  text-align: center;
}

/* ===== Workspace ===== */
.workspace {
  display: none;
  padding: 32px 0 80px;
  min-height: calc(100vh - 64px);
}

.workspace.active {
  display: block;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 24px;
  transition: color var(--transition);
}

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

.workspace-header {
  margin-bottom: 32px;
}

.workspace-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.workspace-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  background: var(--bg-card);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone-content svg {
  margin-bottom: 16px;
  opacity: 0.6;
}

.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.drop-hint {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-top: 12px;
}

/* ===== File List ===== */
.file-list {
  margin-top: 20px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all var(--transition);
}

.file-item:hover {
  border-color: var(--accent-subtle);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.file-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.file-remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.file-remove:hover {
  background: #FEE2E2;
  color: #DC2626;
}

[data-theme="dark"] .file-remove:hover {
  background: #7f1d1d;
  color: #FCA5A5;
}

/* ===== Tool Options ===== */
.tool-options {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.option-group {
  margin-bottom: 16px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.option-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.option-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.option-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.option-hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.option-select {
  appearance: none;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg) url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2371717A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 14px center no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
}

.option-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== Action Bar ===== */
.action-bar {
  margin-top: 24px;
  text-align: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Progress ===== */
.progress-container {
  margin-top: 24px;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ===== Result Area ===== */
.result-area {
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.result-success {
  margin-bottom: 16px;
}

.result-success svg {
  color: #16A34A;
}

.result-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Page Preview Grid ===== */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.page-thumb {
  position: relative;
  aspect-ratio: 210 / 297;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  background: #fff;
}

.page-thumb:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.page-thumb.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.2);
}

.page-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-number {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
}

/* ===== Sortable (Reorder) ===== */
.page-thumb.dragging {
  opacity: 0.4;
}

.page-thumb.drag-over {
  border-color: var(--accent);
  transform: scale(1.05);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero {
    padding: 48px 0 40px;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-sub {
    font-size: 1rem;
  }

  .tools-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .tool-card {
    padding: 16px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .drop-zone {
    padding: 32px 16px;
  }

  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

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

.tool-card,
.feature-card {
  animation: fadeInUp 0.4s ease both;
}

.tools-grid .tool-card:nth-child(1) { animation-delay: 0.05s; }
.tools-grid .tool-card:nth-child(2) { animation-delay: 0.1s; }
.tools-grid .tool-card:nth-child(3) { animation-delay: 0.15s; }
.tools-grid .tool-card:nth-child(4) { animation-delay: 0.2s; }
.tools-grid .tool-card:nth-child(5) { animation-delay: 0.25s; }
.tools-grid .tool-card:nth-child(6) { animation-delay: 0.3s; }
.tools-grid .tool-card:nth-child(7) { animation-delay: 0.35s; }
.tools-grid .tool-card:nth-child(8) { animation-delay: 0.4s; }
.tools-grid .tool-card:nth-child(9) { animation-delay: 0.45s; }
.tools-grid .tool-card:nth-child(10) { animation-delay: 0.5s; }

/* ===== Ad Banners ===== */
.ad-banner {
  padding: 16px 0;
}

.ad-banner-workspace {
  margin-top: 32px;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot-horizontal {
  min-height: 90px;
}

.ad-placeholder {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* When real ads are loaded, hide the placeholder text */
.ad-placeholder:has(.adsbygoogle[data-ad-status="filled"]) span {
  display: none;
}

/* ===== Powered By ===== */
.powered-by {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 8px;
}

.powered-by strong {
  color: var(--text-secondary);
  font-weight: 600;
}

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