/* ============================================
   PDF to PNG Converter – Premium Dark Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables / Design Tokens --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.5);

  --text-primary: #f1f1f4;
  --text-secondary: #8b8b9e;
  --text-muted: #55556a;

  --accent-primary: #8b5cf6;
  --accent-secondary: #6366f1;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #6366f1, #3b82f6);
  --accent-gradient-hover: linear-gradient(135deg, #a78bfa, #818cf8, #60a5fa);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Animated Background --- */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb--1 {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -200px;
  right: -200px;
  animation-delay: 0s;
}

.bg-orb--2 {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: -100px;
  left: -100px;
  animation-delay: -7s;
  animation-duration: 25s;
}

.bg-orb--3 {
  width: 300px;
  height: 300px;
  background: #3b82f6;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -13s;
  animation-duration: 30s;
  opacity: 0.15;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 30px) scale(1.02); }
}

/* --- Grid Overlay --- */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* --- Header --- */
.app-header {
  text-align: center;
  margin-bottom: 48px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.app-logo__icon {
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-glow);
}

.app-logo__text {
  font-size: 28px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.app-header__subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
}

/* --- Drop Zone --- */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}

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

.drop-zone:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.drop-zone:hover::before {
  opacity: 0.03;
}

.drop-zone--active {
  border-color: var(--accent-primary) !important;
  background: rgba(139, 92, 246, 0.08) !important;
  transform: scale(1.01) !important;
  box-shadow: 0 0 60px rgba(139, 92, 246, 0.2) !important;
}

.drop-zone--active::before {
  opacity: 0.06 !important;
}

.drop-zone__content {
  position: relative;
  z-index: 1;
}

.drop-zone__icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(139, 92, 246, 0.3));
  animation: iconBounce 3s ease-in-out infinite;
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.drop-zone__title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.drop-zone__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.drop-zone__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.drop-zone__btn:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.drop-zone__formats {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

#file-input {
  display: none;
}

/* --- Settings Panel --- */
.settings-panel {
  display: none;
  margin-top: 24px;
  padding: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
}

.settings-panel.visible {
  display: block;
  animation: slideUp 0.3s ease-out;
}

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

.settings-panel__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.setting-group {
  flex: 1;
  min-width: 200px;
}

.setting-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.setting-group select,
.setting-group input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.setting-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b8b9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.setting-group select:focus,
.setting-group input[type="number"]:focus {
  border-color: var(--accent-primary);
}

/* --- File Info Bar --- */
.file-info {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin-top: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  animation: slideUp 0.3s ease-out;
}

.file-info.visible {
  display: flex;
}

.file-info__icon {
  width: 44px;
  height: 44px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.file-info__details {
  flex: 1;
  min-width: 0;
}

.file-info__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.file-info__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

/* --- Progress Bar --- */
.progress-container {
  display: none;
  margin-top: 24px;
  animation: slideUp 0.3s ease-out;
}

.progress-container.visible {
  display: block;
}

.progress-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  width: 0%;
  transition: width var(--transition-base);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Action Buttons --- */
.action-bar {
  display: none;
  gap: 12px;
  margin-top: 24px;
  animation: slideUp 0.3s ease-out;
}

.action-bar.visible {
  display: flex;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn--primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm);
  flex: 1;
  justify-content: center;
}

.btn--primary:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

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

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

.btn--secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn--success {
  background: var(--success);
  color: white;
  flex: 1;
  justify-content: center;
}

.btn--success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* --- Pages Preview Grid --- */
.pages-section {
  display: none;
  margin-top: 32px;
}

.pages-section.visible {
  display: block;
  animation: slideUp 0.4s ease-out;
}

.pages-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.pages-section__title {
  font-size: 18px;
  font-weight: 700;
}

.pages-section__count {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

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

.page-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
  position: relative;
}

.page-card:hover {
  border-color: var(--border-active);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.page-card__preview {
  aspect-ratio: 3/4;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

.page-card__preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.page-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.page-card:hover .page-card__overlay {
  opacity: 1;
}

.page-card__download {
  padding: 10px 20px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.page-card__download:hover {
  transform: scale(1.05);
}

.page-card__footer {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-card__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-card__size {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  min-width: 280px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--error); }
.toast--info { border-left: 3px solid var(--accent-primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-exit {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-container {
    padding: 24px 16px 60px;
  }

  .app-logo__text {
    font-size: 22px;
  }

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

  .drop-zone__icon {
    font-size: 42px;
  }

  .pages-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .settings-row {
    flex-direction: column;
    gap: 16px;
  }

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

  .file-info {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .pages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
