/* ═══════════════════════════════════════════════════════════════
   Emily Library — Design System
   Dark premium UI | Lila-Cyan akcentek | Inter font
═══════════════════════════════════════════════════════════════ */

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

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Háttér rétegek */
  --bg-base:       #080810;
  --bg-surface:    #0f0f1a;
  --bg-card:       #13131f;
  --bg-card-hover: #1a1a2e;
  --bg-elevated:   #1e1e32;

  /* Akcent színek */
  --accent-purple:      #7c3aed;
  --accent-purple-light:#9d5ffd;
  --accent-purple-dim:  rgba(124, 58, 237, 0.15);
  --accent-cyan:        #06b6d4;
  --accent-cyan-light:  #22d3ee;
  --accent-cyan-dim:    rgba(6, 182, 212, 0.15);
  --accent-gradient:    linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);

  /* Szöveg */
  --text-primary:   #f0f0ff;
  --text-secondary: #9090b0;
  --text-muted:     #5050708;
  --text-accent:    #a78bfa;

  /* Szegélyek */
  --border:         rgba(255, 255, 255, 0.07);
  --border-accent:  rgba(124, 58, 237, 0.4);

  /* Állapot színek */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error:   #ef4444;
  --color-info:    #06b6d4;

  /* Árnyék */
  --shadow-card:   0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow:   0 0 30px rgba(124, 58, 237, 0.2);
  --shadow-cyan:   0 0 20px rgba(6, 182, 212, 0.15);

  /* Border radius */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  /* Sidebar */
  --sidebar-width: 240px;
  --topbar-height: 60px;
}

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

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-purple-light); text-decoration: none; }
a:hover { color: var(--accent-cyan); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-purple-dim); }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.sidebar-logo .logo-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-purple-dim);
  color: var(--accent-purple-light);
  border: 1px solid var(--border-accent);
}

.nav-item .nav-icon { font-size: 1rem; flex-shrink: 0; }

.sidebar-stats {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.75rem;
}

.sidebar-stat-item .stat-label { color: var(--text-secondary); }
.sidebar-stat-item .stat-value {
  font-weight: 600;
  color: var(--accent-purple-light);
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all 0.25s ease;
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  transform: translateY(-1px);
}

.card-glass {
  background: rgba(19, 19, 31, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
}

/* ── Stat Cards (dashboard) ────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-gradient);
}

.stat-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}

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

/* ── Book Cards ────────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
}

.book-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.book-cover {
  height: 140px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  overflow: hidden;
}

.book-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0.08;
}

.book-cover-law    { background: linear-gradient(135deg, #1e1832, #0d0d1a); }
.book-cover-marketing { background: linear-gradient(135deg, #1a1a10, #0d0d08); }
.book-cover-medical { background: linear-gradient(135deg, #0f1a1a, #080d0d); }
.book-cover-vet    { background: linear-gradient(135deg, #101a10, #080d08); }

.book-info {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.book-category-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-law       { background: rgba(124, 58, 237, 0.2); color: #a78bfa; }
.badge-marketing { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-medical   { background: rgba(6, 182, 212, 0.2);  color: #22d3ee; }
.badge-vet       { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-default   { background: rgba(144, 144, 176, 0.2); color: #9090b0; }

.book-size {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
  color: #fff;
}

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

.btn-secondary:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

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

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); color: #f87171; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
  font-size: 1.4rem;
  position: fixed;
  bottom: 32px; right: 32px;
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.5);
  z-index: 200;
  background: var(--accent-gradient);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-fab:hover {
  transform: scale(1.1) rotate(45deg);
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.6);
}

/* ── Inputs ────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  outline: none;
}

.input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-purple-dim);
}

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

.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 1rem;
  pointer-events: none;
}

.search-input-wrap input {
  padding-left: 40px;
}

select.input {
  cursor: pointer;
  appearance: none;
  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='%239090b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  padding: 28px 28px;
  max-width: 1400px;
  flex: 1;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

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

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent-purple-dim);
  border-color: var(--border-accent);
  color: var(--accent-purple-light);
}

/* ── Search Page ───────────────────────────────────────────── */
.search-hero {
  text-align: center;
  padding: 40px 0 32px;
}

.search-hero-title {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.search-hero-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.search-box-large {
  max-width: 700px;
  margin: 0 auto;
}

.search-box-large input {
  font-size: 1rem;
  padding: 14px 18px 14px 46px;
  border-radius: var(--radius-md);
}

/* ── Answer Card ───────────────────────────────────────────── */
.answer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 24px 0;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.answer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-gradient);
}

.answer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.answer-emily-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-purple-light);
}

.emily-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.answer-text {
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ── Source Cards ──────────────────────────────────────────── */
.sources-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 24px 0 12px;
}

.source-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.source-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card);
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.source-filename {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.source-score {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  font-weight: 600;
}

.source-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Chat Page ─────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.chat-sessions-panel {
  width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sessions-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-session-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-session-item .session-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-session-item .session-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.chat-session-item:hover .session-delete-btn { opacity: 0.7; }
.chat-session-item .session-delete-btn:hover { opacity: 1; background: rgba(255,60,60,0.15); }

.chat-session-item:hover { background: var(--bg-card); color: var(--text-primary); }
.chat-session-item.active { background: var(--accent-purple-dim); color: var(--accent-purple-light); }


.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: msgIn 0.3s ease;
}

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

.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-message-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.chat-message.user .chat-message-avatar {
  background: var(--accent-purple-dim);
  border: 1px solid var(--border-accent);
}

.chat-message.emily .chat-message-avatar {
  background: var(--accent-gradient);
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 100%;
}

.chat-message.user .chat-bubble {
  background: var(--accent-purple-dim);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}

.chat-message.emily .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
}

/* ── Markdown content inside Emily's chat bubble ───────────── */
.chat-bubble p            { margin: 0 0 8px; line-height: 1.65; }
.chat-bubble p:last-child { margin-bottom: 0; }

.chat-bubble strong { color: var(--text-primary); font-weight: 700; }
.chat-bubble em     { font-style: italic; color: var(--text-secondary); }
.chat-bubble del    { text-decoration: line-through; color: var(--text-secondary); }

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
  font-weight: 700;
  color: var(--text-primary);
  margin: 12px 0 6px;
  line-height: 1.3;
}
.chat-bubble h1 { font-size: 1.1rem; }
.chat-bubble h2 { font-size: 1rem; }
.chat-bubble h3 { font-size: 0.95rem; }

.chat-bubble ul, .chat-bubble ol {
  margin: 6px 0 8px 16px;
  padding: 0;
}
.chat-bubble li { margin-bottom: 3px; line-height: 1.55; }

.chat-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.chat-bubble blockquote {
  border-left: 3px solid var(--accent-purple);
  margin: 8px 0;
  padding: 6px 12px;
  background: var(--accent-purple-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Inline code */
.chat-bubble code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82em;
  color: var(--accent-cyan);
}

/* Code blocks */
.chat-bubble pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.chat-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* Tables */
.chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chat-bubble th {
  background: var(--bg-elevated);
  color: var(--accent-purple-light);
  font-weight: 700;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-accent);
  white-space: nowrap;
}
.chat-bubble td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.chat-bubble tr:last-child td { border-bottom: none; }
.chat-bubble tr:hover td { background: var(--bg-elevated); }


.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.chat-input-row textarea:focus {
  border-color: var(--accent-purple);
}

/* ── Book View Page ────────────────────────────────────────── */
.book-view-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.book-view-icon {
  width: 64px; height: 80px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.book-view-meta { flex: 1; }
.book-view-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.book-view-details {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.book-view-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chunk-list { display: flex; flex-direction: column; gap: 12px; }

.chunk-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color 0.2s ease;
}

.chunk-item:hover { border-color: var(--border-accent); }

.chunk-number {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.chunk-text {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0 16px;
}

/* ── Upload Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-glow);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-purple);
  background: var(--accent-purple-dim);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.dropzone-text { font-size: 0.9rem; color: var(--text-secondary); }
.dropzone-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.category-suggestion {
  background: var(--bg-elevated);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
  display: none;
}

.category-suggestion.visible { display: block; }
.category-label { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 6px; }
.category-value {
  font-weight: 600;
  color: var(--accent-purple-light);
  font-size: 0.95rem;
}

/* ── Progress / Loading ────────────────────────────────────── */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.loading-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-purple-light);
  animation: dot-bounce 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

.progress-bar-wrap {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}

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

/* ── Notification Toast ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.875rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  pointer-events: all;
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error   { border-color: rgba(239, 68, 68, 0.4); }
.toast.info    { border-color: var(--border-accent); }

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

/* ── Status Indicator ──────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online  { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.status-dot.offline { background: var(--color-error);   box-shadow: 0 0 6px var(--color-error); }
.status-dot.warning { background: var(--color-warning); box-shadow: 0 0 6px var(--color-warning); }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-state-text { font-size: 0.875rem; }

/* ── Utility ───────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-16        { margin-bottom: 16px; }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.text-muted   { color: var(--text-secondary); }
.text-accent  { color: var(--accent-purple-light); }
.font-bold    { font-weight: 700; }
.w-full       { width: 100%; }
.hidden       { display: none !important; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .page-content { padding: 16px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
