/* =============================================
   ASTROPDF — Main Stylesheet
   ============================================= */

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

:root {
  --bg: #0d0e14;
  --surface: #151621;
  --surface2: #1c1e2e;
  --surface3: #242638;
  --border: rgba(255,255,255,0.07);
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --accent3: #a78bfa;
  --text: #e8e9f3;
  --text2: #9a9bc0;
  --text3: #6b6c8c;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ===== SCREENS ===== */
.screen { position: fixed; inset: 0; transition: opacity 0.4s ease, transform 0.4s ease; }
.screen:not(.active) { opacity: 0; pointer-events: none; transform: scale(0.98); }
.screen.active { opacity: 1; transform: scale(1); }

/* ===== LANDING ===== */
#landing {
  overflow-y: auto;
  background: var(--bg);
}

.landing-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
}
.orb1 { width: 600px; height: 600px; top: -200px; left: -100px; background: radial-gradient(circle, #6366f1, transparent); animation: float1 12s ease-in-out infinite; }
.orb2 { width: 400px; height: 400px; top: 200px; right: -100px; background: radial-gradient(circle, #8b5cf6, transparent); animation: float2 15s ease-in-out infinite; }
.orb3 { width: 300px; height: 300px; bottom: 100px; left: 50%; background: radial-gradient(circle, #a78bfa, transparent); animation: float1 18s ease-in-out infinite reverse; }

@keyframes float1 { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-30px) scale(1.05); } }
@keyframes float2 { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(20px) rotate(5deg); } }

/* Nav */
.top-nav {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 48px;
}

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

.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: var(--transition); }
.nav-links a:hover { color: var(--text); }
.btn-ghost {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text) !important;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.15) !important; }

/* Hero */
.hero {
  position: relative;
  z-index: 5;
  max-width: 860px;
  margin: 0 auto;
  padding: 60px 24px 100px;
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 100px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent3);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: clamp(3rem, 7vw, 5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

.gradient-text {
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--text2);
  max-width: 520px;
  margin: 0 auto 48px;
  line-height: 1.7;
}

/* Upload Zone */
.upload-zone {
  position: relative;
  border: 2px dashed rgba(99,102,241,0.35);
  border-radius: 20px;
  padding: 60px 40px;
  background: rgba(99,102,241,0.04);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 72px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: rgba(99,102,241,0.7);
  background: rgba(99,102,241,0.09);
  transform: scale(1.01);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-inner { pointer-events: none; }
.upload-icon { margin-bottom: 16px; }
.upload-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 8px; }
.upload-sub { color: var(--text2); font-size: 0.95rem; margin-bottom: 8px; }
.upload-browse {
  background: none;
  border: none;
  color: var(--accent3);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
  pointer-events: all;
}
.upload-note { color: var(--text3); font-size: 0.82rem; margin-top: 12px; }

/* Features Row */
.features-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 700px) { .features-row { grid-template-columns: repeat(2, 1fr); } }

.feat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  transition: var(--transition);
}
.feat-card:hover { background: var(--surface2); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(99,102,241,0.12); }
.feat-icon { font-size: 1.8rem; margin-bottom: 12px; }
.feat-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.feat-card p { font-size: 0.82rem; color: var(--text2); line-height: 1.5; }

/* ===== EDITOR ===== */
#editor { display: flex; flex-direction: column; background: var(--bg); }

/* App Bar */
.app-bar {
  height: 56px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 50;
}
.app-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.app-bar-center { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.app-bar-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

.file-name {
  font-size: 0.88rem;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.page-info { font-size: 0.88rem; color: var(--text2); min-width: 60px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-label { font-size: 0.82rem; color: var(--text2); min-width: 44px; text-align: center; }
.divider { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

.icon-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: var(--transition);
  white-space: nowrap;
}
.icon-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.2); }

.btn-download {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99,102,241,0.45); }
.btn-download:active { transform: translateY(0); }

/* Editor Body */
.editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px 2px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-size: 0.84rem;
  font-family: inherit;
  transition: var(--transition);
  text-align: left;
}
.tool-btn:hover { background: var(--surface2); color: var(--text); }
.tool-btn.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.3);
  color: var(--accent3);
}

/* Style Rows */
.style-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--text2);
}
.style-row label { min-width: 52px; flex-shrink: 0; }
.style-row input[type="color"] {
  width: 28px; height: 28px;
  border: none; border-radius: 6px;
  padding: 2px; cursor: pointer;
  background: var(--surface3);
}
.style-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.style-row input[type="number"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface3);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 4px 8px;
  width: 54px;
}
.style-row input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }

.history-btns { display: flex; flex-direction: column; gap: 4px; }

/* Canvas Area */
.canvas-area {
  flex: 1;
  overflow: auto;
  background: #1a1b26;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  box-shadow: 0 20px 80px rgba(0,0,0,0.5);
  border-radius: 4px;
  line-height: 0;
  transform-origin: top center;
}

#pdfCanvas, #annotationCanvas {
  position: absolute;
  top: 0; left: 0;
  border-radius: 4px;
}
#pdfCanvas { z-index: 1; }
#annotationCanvas { z-index: 2; }

#textInputContainer {
  position: absolute;
  top: 0; left: 0;
  z-index: 3;
  pointer-events: none;
}

/* Text input overlay */
.text-input-box {
  position: absolute;
  pointer-events: all;
  background: transparent;
  border: 2px dashed var(--accent);
  border-radius: 4px;
  outline: none;
  resize: none;
  font-family: inherit;
  color: #000;
  padding: 4px;
  min-width: 80px;
  min-height: 28px;
  overflow: hidden;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,14,20,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.loading-overlay.visible { opacity: 1; pointer-events: all; }
.loading-overlay p { color: var(--text2); font-size: 0.9rem; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(99,102,241,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 24px;
  border-radius: 100px;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface3); }
