/* ═══════════════════════════════════════════════════════════════════════════
   WordRunner — main.css  (landing page + global styles)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

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

:root {
  --navy:   #0a0a1a;
  --violet: #2d1b69;
  --teal:   #0891b2;
  --teal-light: #22d3ee;
  --white:  #ffffff;
  --text:   #e2e8f0;
  --text-muted: #94a3b8;
  --glass-bg: rgba(10, 10, 30, 0.55);
  --glass-border: rgba(255, 255, 255, 0.1);
  --card-bg: rgba(255, 255, 255, 0.05);
  --error:  #ef4444;
  --success: #10b981;
  --radius: 16px;
  --radius-sm: 8px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: var(--text);
  overflow-x: hidden;
  position: relative;
}

/* ── Animated Gradient Background ────────────────────────────────────────── */
.bg-gradient {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0a3e 25%, #2d1b69 50%, #0a2d4a 75%, #0a0a1a 100%);
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
  z-index: -1;
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(10, 10, 26, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  user-select: none;
}
.logo-word   { color: var(--white); }
.logo-runner { color: var(--teal-light); }

.settings-btn {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 200ms ease;
}
.settings-btn:hover {
  color: var(--teal-light);
  border-color: var(--teal);
  box-shadow: 0 0 12px rgba(8, 145, 178, 0.3);
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 48px;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}
.hero-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* ── Cards / Glass panels ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 200ms ease;
}
.card:hover { border-color: rgba(8, 145, 178, 0.25); }

/* ── API Key Card ────────────────────────────────────────────────────────── */
.api-key-card { margin-bottom: 28px; }
.api-key-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* ── Input Grid (URL + PDF side by side) ─────────────────────────────────── */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 640px) { .input-grid { grid-template-columns: 1fr; } }

.input-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.input-card h2 svg { color: var(--teal-light); }

/* ── Form Controls ───────────────────────────────────────────────────────── */
input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}
input::placeholder { color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--teal) 0%, #0369a1 100%);
  color: var(--white);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 220ms ease;
}
.btn-primary:hover {
  box-shadow: 0 0 24px rgba(8, 145, 178, 0.5);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  background: transparent;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-secondary:hover {
  border-color: var(--teal);
  color: var(--teal-light);
  box-shadow: 0 0 12px rgba(8, 145, 178, 0.2);
}

.btn-icon {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 200ms ease;
  flex-shrink: 0;
}
.btn-icon:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  background: transparent;
  color: var(--error);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* ── File Drop Zone ──────────────────────────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms ease;
}
.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color: var(--teal);
  background: rgba(8, 145, 178, 0.05);
}
.file-drop-zone p {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.file-drop-zone .file-name {
  margin-top: 10px;
  color: var(--teal-light);
  font-size: 0.9rem;
  word-break: break-all;
}
.file-drop-zone .page-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* ── PDF Modals ──────────────────────────────────────────────────────────── */
.pdf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.pdf-modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.pdf-modal-panel {
  background: rgba(15,15,35,0.97);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: min(540px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pdf-modal-panel--wide {
  width: min(800px, 100%);
}
.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pdf-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  margin: 0;
}
.pdf-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.page-range-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.page-range-row input {
  flex: 1;
  min-width: 160px;
}
.page-range-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}
.page-range-error {
  font-size: 0.85rem;
  color: var(--error);
  display: none;
  margin: 0;
}
.page-range-error.visible { display: block; }

.pdf-pages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}
.pdf-pages-grid::-webkit-scrollbar { width: 6px; }
.pdf-pages-grid::-webkit-scrollbar-track { background: transparent; }
.pdf-pages-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.pdf-page-thumb {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.pdf-page-thumb canvas {
  display: block;
  width: 100%;
  height: auto;
}
.pdf-page-label {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── History Section ─────────────────────────────────────────────────────── */
.history-section { margin-top: 12px; }
.history-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
}
.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px 0;
}
.history-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 200ms ease;
}
.history-card:hover { border-color: rgba(8, 145, 178, 0.3); }
.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 20px;
}
.badge-url  { background: rgba(8,145,178,0.2); color: var(--teal-light); border: 1px solid rgba(8,145,178,0.3); }
.badge-pdf  { background: rgba(124,58,237,0.2); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
.history-progress-bar {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.history-progress-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  transition: width 300ms ease;
}
.history-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-resume {
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--teal), #0369a1);
  color: var(--white);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-resume:hover { box-shadow: 0 0 12px rgba(8,145,178,0.4); }
.btn-delete {
  padding: 7px 10px;
  font-size: 0.8rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
}
.btn-delete:hover { color: var(--error); border-color: rgba(239,68,68,0.4); }

/* ── Settings Drawer ─────────────────────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}
.settings-overlay.open { opacity: 1; pointer-events: all; }

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100vw);
  background: rgba(10, 10, 30, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--glass-border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.settings-drawer.open { transform: translateX(0); }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  background: rgba(10,10,30,0.95);
  backdrop-filter: blur(24px);
  z-index: 1;
}
.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
}
.settings-close {
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 200ms ease;
}
.settings-close:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }

.settings-body { padding: 24px; flex: 1; }

.setting-group {
  margin-bottom: 28px;
}
.setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.setting-label-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.setting-label-value {
  font-size: 0.85rem;
  color: var(--teal-light);
  font-family: 'IBM Plex Mono', monospace;
}
.setting-description {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle input   { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 24px;
  cursor: pointer;
  transition: background 200ms ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 200ms ease;
}
.toggle input:checked + .toggle-slider { background: var(--teal); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--white);
}

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(8,145,178,0.5);
  transition: all 200ms ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 14px rgba(8,145,178,0.7);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--teal);
  border: none;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(8,145,178,0.5);
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 24px 0;
}

.settings-footer { padding: 0 24px 24px; }

/* ── Password-style input with show/hide toggle ───────────────────────────── */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  flex: 1;
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0;
  transition: color 150ms ease;
}
.pw-toggle:hover { color: var(--white); }

/* Progress mode toggle */
.seg-control {
  display: flex;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg-btn {
  flex: 1;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms ease;
}
.seg-btn.active {
  background: var(--teal);
  color: var(--white);
}

/* ── Loading Overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.loading-overlay.hidden { display: none !important; }

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(8,145,178,0.2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: min(480px, 90vw);
}
.toast {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: all;
  animation: toastIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.toast-exit { animation: toastOut 300ms ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

.toast-error   { background: rgba(127,29,29,0.85); border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; }
.toast-success { background: rgba(6,78,59,0.85); border: 1px solid rgba(16,185,129,0.4); color: #6ee7b7; }
.toast-info    { background: rgba(7,44,68,0.85); border: 1px solid rgba(8,145,178,0.4); color: var(--teal-light); }

/* ── Confirmation Dialog ─────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.hidden { display: none !important; }
.dialog-box {
  background: rgba(15, 15, 35, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 32px;
  width: min(420px, 90vw);
  text-align: center;
}
.dialog-box h3 { font-size: 1.1rem; color: var(--white); margin-bottom: 12px; }
.dialog-box p  { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; line-height: 1.6; }
.dialog-actions { display: flex; gap: 12px; justify-content: center; }

.btn-dialog-confirm {
  padding: 10px 28px;
  background: linear-gradient(135deg, var(--teal), #0369a1);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-dialog-confirm:hover { box-shadow: 0 0 16px rgba(8,145,178,0.45); }
.btn-dialog-cancel {
  padding: 10px 28px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-dialog-cancel:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }

/* ── Scrollbar Global ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
