/* ═══════════════════════════════════════════════════════════════
   PDF READER — Design System
   Vercel-style Black & White Professional Theme
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Tokens ── */
:root {
  --bg: #000000;
  --bg-1: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #1a1a1a;
  --bg-4: #222222;
  --border: #2a2a2a;
  --border-hover: #444444;
  --text: #ededed;
  --text-2: #a1a1a1;
  --text-3: #666666;
  --accent: #ffffff;
  --accent-dim: rgba(255, 255, 255, 0.08);
  --danger: #ff4444;
  --success: #22cc66;
  --radius: 6px;
  --radius-lg: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 150ms ease;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: var(--font);
}

input,
textarea,
select {
  font-family: var(--font);
}

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-wrapper {
  padding: 40px 0 80px;
}

/* ── Navbar ── */
.navbar {
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 16px;
}

.navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.navbar-brand span {
  color: var(--text-2);
  font-weight: 400;
}

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

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-2);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-link.active {
  color: var(--text);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #e0e0e0;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover {
  background: rgba(255, 68, 68, 0.08);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 0.95rem;
}

/* ── Cards ── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Book Grid ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.book-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-3);
  transform: translateY(-1px);
}

.book-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.book-card-meta {
  font-size: 0.78rem;
  color: var(--text-3);
  display: flex;
  gap: 12px;
}

.book-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.book-card-actions {
  display: flex;
  gap: 6px;
}

/* ── Progress Bar ── */
.progress-bar-wrap {
  background: var(--bg-4);
  border-radius: 100px;
  height: 4px;
  overflow: hidden;
}

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

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 4px;
}

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-3);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ── Heatmap ── */
.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 8px;
}

.heatmap-grid {
  display: flex;
  gap: 3px;
  align-items: flex-start;
}

.heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--bg-4);
  transition: background var(--transition);
}

.heatmap-cell:hover {
  outline: 1px solid var(--accent);
}

.heatmap-cell[data-level="1"] {
  background: #333;
}

.heatmap-cell[data-level="2"] {
  background: #555;
}

.heatmap-cell[data-level="3"] {
  background: #888;
}

.heatmap-cell[data-level="4"] {
  background: #bbb;
}

.heatmap-cell[data-level="5"] {
  background: #fff;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Activity Feed ── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-main {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

.activity-meta {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 2px;
}

.activity-note {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--bg-3);
  border-radius: var(--radius);
  border-left: 2px solid var(--border-hover);
}

.activity-actions {
  flex-shrink: 0;
}

/* ── Forms ── */
.form-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.88rem;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--bg-4);
}

.form-input::placeholder {
  color: var(--text-3);
}

.form-input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text-2);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg-4);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.badge-white {
  background: var(--accent);
  color: #000;
  border-color: transparent;
}



/* ── Charts ── */
.chart-wrap {
  position: relative;
  height: 200px;
}

.chart-wrap-lg {
  position: relative;
  height: 260px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* ── Book Detail Layout ── */
.book-detail-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.book-detail-main {
  min-width: 0;
}

.book-detail-side {
  min-width: 0;
}

/* ── Donut Chart ── */
.donut-wrap {
  position: relative;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.2s ease;
  max-width: 300px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Auth Pages ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 0.83rem;
  color: var(--text-3);
  margin-bottom: 28px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-3);
}

.auth-footer a {
  color: var(--text);
  text-decoration: underline;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.83rem;
  margin-bottom: 20px;
}

/* ── Messages ── */
.messages-list {
  margin-bottom: 20px;
}

.message {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.message.success {
  border-color: var(--success);
  color: var(--success);
  background: rgba(34, 204, 102, 0.05);
}

.message.error {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(255, 68, 68, 0.05);
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Inline Collapse ── */
.collapsible {
  display: none;
}

.collapsible.open {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .book-detail-layout {
    grid-template-columns: 1fr;
  }

  .book-detail-side {
    order: -1;
  }
}

@media (max-width: 640px) {
  .navbar-inner {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .navbar-nav {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

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

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .container {
    padding: 0 16px;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-2);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-4);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ── Skeleton Loader ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ── PDF Viewer specific ── */
.pdf-viewer-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.pdf-main {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.pdf-canvas-wrap {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 8px;
}

.pdf-page-canvas {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  max-width: 100%;
}

.pdf-sidebar {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pdf-sidebar-tab {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.pdf-sidebar-tab-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}

.pdf-sidebar-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.pdf-sidebar-content {
  padding: 16px;
  flex: 1;
}

.highlight-item {
  padding: 8px 10px;
  background: var(--bg-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  margin-bottom: 6px;
  line-height: 1.4;
}

.highlight-item-page {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
}

.highlight-text {
  color: var(--text-2);
}

.highlight-yellow {
  border-left: 3px solid #c0a000;
}

.highlight-green {
  border-left: 3px solid #22aa55;
}

.session-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}

.session-date {
  color: var(--text-2);
}

.session-page {
  color: var(--text-3);
}

#pdf-page-input {
  width: 48px;
  text-align: center;
  padding: 4px 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
}

#pdf-page-input:focus {
  border-color: var(--accent);
}

.page-count-label {
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ── Tooltip ── */
[data-tip] {
  position: relative;
}

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-4);
  color: var(--text);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
  border: 1px solid var(--border);
  pointer-events: none;
  z-index: 999;
}