/* styles.css – 0xPDF Tool */

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

:root {
  --bg: #030305;
  --bg-elevated: #0a0a0f;
  --accent: #FFDE21;
  --accent-glow: rgba(255, 222, 33, 0.35);
  --accent-dim: rgba(255, 222, 33, 0.12);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.3);
  --cyan: #22d3ee;
  --cyan-glow: rgba(34, 211, 238, 0.3);
  --red: #ef4444;
  --green: #22c55e;
  --text: #e8e8ec;
  --text-dim: #7a7a8a;
  --card-bg: rgba(255, 255, 255, 0.035);
  --card-border: rgba(255, 255, 255, 0.07);
  --font-heading: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* ─── Dot Grid ─── */
.dot-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 222, 33, 0.09) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ─── Navigation ─── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0.7rem 1.5rem;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  background: rgba(3, 3, 5, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.nav-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.nav-brand {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.nav-logo span {
  color: var(--accent);
}

.nav-byline {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.5px;
  line-height: 1;
  transition: color 0.2s ease;
}

.nav-byline:hover {
  color: var(--accent);
}

/* ─── Main ─── */
main {
  position: relative;
  z-index: 1;
  padding-top: 4rem;
}

/* ─── Section ─── */
.section {
  padding: 2.5rem 0 3rem;
}

.section-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.2rem;
}

.section-header {
  margin-bottom: 1.8rem;
}

.section-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 3.5px;
  color: var(--accent);
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.accent {
  color: var(--accent);
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 520px;
}

/* ─── Divider ─── */
.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 2rem;
}

.divider-line {
  height: 1px;
  flex: 1;
  max-width: 200px;
  background: linear-gradient(to right, transparent, rgba(255, 222, 33, 0.15), transparent);
}

.divider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
}

/* ─── Drop Zone ─── */
.drop-zone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 222, 33, 0.03);
  box-shadow: 0 0 40px rgba(255, 222, 33, 0.06);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  text-align: center;
  gap: 0.4rem;
}

.drop-icon {
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 0.4rem;
  transition: all 0.3s ease;
}

.drop-zone:hover .drop-icon {
  opacity: 1;
  transform: translateY(-3px);
}

.drop-text {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.drop-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.drop-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.8rem;
}

.format-tag {
  padding: 0.15rem 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
}

/* ─── Convert Preview ─── */
.convert-preview-area {
  margin-top: 1.5rem;
  animation: fadeIn 0.4s ease;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.preview-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.file-item:hover {
  border-color: rgba(255, 222, 33, 0.15);
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.file-icon img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

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

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

.file-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.file-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.file-remove:hover {
  background: rgba(239, 68, 68, 0.25);
  transform: scale(1.1);
}

/* ─── Options ─── */
.convert-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.option-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.option-label span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.select-input {
  padding: 0.6rem 0.8rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%237a7a8a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.8rem;
}

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

.select-input option {
  background: #1a1a2e;
  color: var(--text);
}

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 100px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 25px rgba(255, 222, 33, 0.2);
  width: 100%;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 35px rgba(255, 222, 33, 0.35);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost-sm {
  padding: 0.35rem 0.8rem;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--card-border);
  border-radius: 100px;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-ghost-sm:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.btn-icon {
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

/* ─── Merge Upload Grid ─── */
.merge-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.merge-upload-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.3s ease;
}

.merge-upload-card.has-pdf {
  border-color: rgba(255, 222, 33, 0.15);
}

.merge-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.merge-card-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.merge-drop {
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 1.5rem 0.8rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
}

.merge-drop:hover,
.merge-drop.drag-over {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 222, 33, 0.02);
}

.merge-drop p {
  font-size: 0.8rem;
  font-weight: 500;
}

/* ─── Merge Pages Grid ─── */
.merge-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.5rem;
  margin-top: 0.6rem;
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  -webkit-overflow-scrolling: touch;
}

.merge-pages::-webkit-scrollbar {
  width: 3px;
}

.merge-pages::-webkit-scrollbar-track {
  background: transparent;
}

.merge-pages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.page-thumb {
  position: relative;
  aspect-ratio: 0.707;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.03);
  -webkit-tap-highlight-color: transparent;
}

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

.page-thumb.selected {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255, 222, 33, 0.2);
}

.page-thumb:hover {
  border-color: rgba(255, 222, 33, 0.3);
}

.page-thumb .page-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--text);
  font-size: 0.55rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
}

.page-thumb .page-check {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: transparent;
  transition: all 0.2s ease;
}

.page-thumb.selected .page-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.merge-page-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.page-count {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-left: auto;
}

/* ─── Merge Options ─── */
.merge-options-panel {
  animation: fadeIn 0.4s ease;
}

.options-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.merge-order-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.order-btn {
  padding: 1rem 0.6rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  -webkit-tap-highlight-color: transparent;
}

.order-btn:hover {
  border-color: rgba(255, 222, 33, 0.2);
  background: rgba(255, 222, 33, 0.03);
}

.order-btn.active {
  border-color: var(--accent);
  background: rgba(255, 222, 33, 0.06);
  box-shadow: 0 0 16px rgba(255, 222, 33, 0.08);
}

.order-icon {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.order-btn span {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
}

.order-btn small {
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  pointer-events: auto;
}

.toast.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.toast.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.toast.info {
  background: rgba(255, 222, 33, 0.1);
  border: 1px solid rgba(255, 222, 33, 0.25);
  color: var(--accent);
}

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

.toast.out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(12px); }
}

/* ─── Loading ─── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(3, 3, 5, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 222, 33, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
}

/* ─── Footer ─── */
.footer {
  position: relative;
  z-index: 1;
  padding: 2rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

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

.footer-logo {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dim);
}

.footer-logo span {
  color: var(--accent);
  opacity: 0.6;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0.5;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.footer-link:hover {
  opacity: 1;
}

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive — Mobile First ─── */
@media (max-width: 600px) {
  .nav {
    padding: 0.6rem 1rem;
  }

  .nav-icon {
    width: 30px;
    height: 30px;
  }

  .nav-logo {
    font-size: 1.05rem;
  }

  main {
    padding-top: 3.5rem;
  }

  .section {
    padding: 2rem 0 2.5rem;
  }

  .section-inner {
    padding: 0 1rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .section-desc {
    font-size: 0.82rem;
  }

  .merge-upload-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .merge-order-btns {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .order-btn {
    flex-direction: row;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    text-align: left;
  }

  .convert-options {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .drop-zone-inner {
    padding: 2rem 1rem;
  }

  .drop-text {
    font-size: 0.9rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.3rem;
    text-align: center;
  }

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

/* Ensure PWA safe areas */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .toast-container {
    bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}
