:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-card: #1e2538;
  --bg-input: #252d3f;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #5f6368;
  --accent: #c9a96e;
  --accent-light: rgba(201,169,110,0.1);
  --accent-dark: #a88a4e;
  --border: #2d3548;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font-sans); background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Inputs */
input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  width: 100%;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--bg-card); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { color: #ff4757; border-color: #ff4757; }
.btn-danger:hover { background: rgba(255,71,87,0.1); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }

/* Navigation */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(15,20,25,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.nav-brand-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  overflow: hidden;
}
.nav-brand-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.hamburger {
  display: none;
  background: none; border: none; color: var(--text-primary);
  font-size: 1.4rem; cursor: pointer; padding: 8px;
}
.nav-brand h1 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 1px;
}
.nav-brand span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: block;
  margin-top: -2px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  font-family: var(--font-sans);
}
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--accent-light); }

/* Hero */
.hero {
  margin-top: 64px;
  padding: 80px 24px 60px;
  text-align: center;
  background: linear-gradient(180deg, rgba(201,169,110,0.05) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}
.hero h2 {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}
.hero h2 .gold { color: var(--accent); }
.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto 32px;
}
.hero-intro {
  max-width: 800px;
  margin: 0 auto 36px;
  text-align: left;
  background: rgba(201,169,110,0.05);
  border-left: 3px solid var(--accent);
  padding: 24px 28px;
  border-radius: 0 8px 8px 0;
}
.hero-intro p {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.8;
  margin: 0 0 14px;
  max-width: none;
}
.hero-intro p:last-child { margin-bottom: 0; }
.hero-intro em { color: var(--accent); font-style: italic; }
.hero-intro strong { color: var(--accent); }
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
}
.hero-stat .num {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.hero-stat .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Search Bar */
.search-container {
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}
.search-bar {
  display: flex;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.3s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 16px 20px;
  font-size: 1rem;
}
.search-bar input:focus { outline: none; }
.search-bar button {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 16px 28px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.search-bar button:hover { background: var(--accent-dark); }

/* Main Content */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page-section { padding: 40px 0; }

/* Categories Grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.cat-card .count { font-size: 0.8rem; color: var(--accent); }

/* Document List */
.doc-list { display: flex; flex-direction: column; gap: 12px; }
.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 16px;
  transition: border-color 0.2s;
  cursor: pointer;
}
.doc-card:hover { border-color: var(--accent); }
.doc-icon {
  width: 48px; height: 60px;
  background: var(--accent-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  font-size: 1.2rem;
}
.doc-info { flex: 1; min-width: 0; }
.doc-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.doc-meta span { display: flex; align-items: center; gap: 4px; }
.doc-desc { font-size: 0.85rem; color: var(--text-secondary); margin-top: 8px; }

/* Document Detail */
.doc-detail {
  max-width: 800px;
  margin: 80px auto 40px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.doc-detail h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 16px;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.meta-item {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--radius);
}
.meta-item .meta-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 2px; }
.meta-item .meta-value { font-size: 0.9rem; color: var(--text-primary); }

/* Snippet highlight */
mark { background: var(--accent-light); color: var(--accent); padding: 1px 3px; border-radius: 3px; }

/* Upload Form */
.upload-form {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
.drop-zone i { font-size: 2rem; color: var(--accent); margin-bottom: 12px; display: block; }

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 1px; }
.admin-table tr:hover td { background: var(--bg-card); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-pending { background: rgba(255,176,32,0.1); color: #ffb020; }
.badge-approved { background: rgba(0,230,138,0.1); color: #00e68a; }
.badge-book { background: rgba(0,180,255,0.1); color: #00b4ff; }
.badge-article { background: rgba(124,58,237,0.1); color: #7c3aed; }

/* Chatbot */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201,169,110,0.3);
  z-index: 200;
  border: none;
  color: #000;
  font-size: 1.3rem;
  transition: transform 0.2s;
}
.chatbot-fab:hover { transform: scale(1.08); }
.chatbot-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 400px;
  max-height: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 200;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  overflow: hidden;
}
.chatbot-panel.open { display: flex; }
.chatbot-panel.fullscreen {
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; max-height: 100%;
  border-radius: 0;
  z-index: 9999;
}
.chatbot-panel.fullscreen .chat-messages { flex: 1; max-height: none; }
.chatbot-panel.fullscreen .chat-header { padding: 20px 24px; }
.chatbot-panel.fullscreen .chat-input-row { padding: 16px 24px; }
.chatbot-panel.fullscreen .chat-input-row input { font-size: 1rem; padding: 14px 16px; }
.chat-fullscreen-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; margin-right: 8px; }
.chat-fullscreen-btn:hover { color: var(--accent); }
.chat-header {
  padding: 16px;
  background: linear-gradient(135deg, rgba(201,169,110,0.1), rgba(201,169,110,0.02));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.chat-msg.bot { background: rgba(201,169,110,0.08); border-radius: 12px 12px 12px 4px; align-self: flex-start; }
.chat-msg.user { background: var(--accent); color: #000; border-radius: 12px 12px 4px 12px; align-self: flex-end; }
.chat-input-row {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.chat-input-row input { border-radius: 10px; }
.chat-input-row button {
  background: var(--accent);
  border: none;
  color: #000;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { font-family: var(--font-serif); margin-bottom: 16px; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 60px;
}

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  z-index: 400;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}
.toast.success { border-color: #10b981; }
.toast.error { border-color: #ff4757; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links {
    display: none;
    position: fixed;
    top: 64px; left: 0; right: 0;
    background: rgba(15,20,25,0.98);
    backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: 12px 16px; width: 100%; text-align: left; font-size: 1rem; }
  .hero h2 { font-size: 1.6rem; }
  .hero { padding: 60px 16px 40px; }
  .hero-intro { padding: 16px 18px; font-size: 0.9rem; }
  .hero-intro p { font-size: 0.9rem; line-height: 1.7; }
  .form-row { flex-direction: column; }
  .hero-stats { gap: 16px; flex-wrap: wrap; }
  .hero-stat .num { font-size: 1.4rem; }
  .hero-stat .label { font-size: 0.65rem; }
  .meta-grid { grid-template-columns: 1fr; }
  .chatbot-panel { width: calc(100% - 32px); right: 16px; bottom: 80px; }
  .doc-card { flex-direction: column; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .container { padding: 0 16px; }
  .section-title { font-size: 1.4rem; }
  .upload-form { padding: 20px; }
  .search-bar { flex-direction: column; gap: 8px; }
  .search-bar input { width: 100%; }
  .search-bar button { width: 100%; justify-content: center; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar { flex-direction: row; overflow-x: auto; white-space: nowrap; padding: 8px; gap: 4px; }
  .admin-sidebar button { padding: 8px 14px; font-size: 0.8rem; }
  .navbar { padding: 0 12px; }
  .nav-brand h1 { font-size: 1rem; }
  .nav-brand span { font-size: 0.6rem; letter-spacing: 1px; }
}
@media (max-width: 400px) {
  .cat-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 12px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Loading spinner */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.pagination button.active { background: var(--accent); color: #000; border-color: var(--accent); }
.pagination button:hover { border-color: var(--accent); }

/* Section headings */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Admin sidebar */
.admin-layout {
  display: flex;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}
.admin-sidebar {
  width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}
.admin-sidebar button {
  display: block;
  width: 100%;
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s;
}
.admin-sidebar button:hover, .admin-sidebar button.active {
  color: var(--accent);
  background: var(--accent-light);
}
.admin-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}
.stat-card .stat-num {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* Tutorial Layout */
.tutorial-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 500px;
}
.tutorial-sidebar {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
  position: sticky;
  top: 80px;
}
.tutorial-section-header {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 0;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}
.tutorial-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.9rem;
}
.tutorial-item:hover { background: var(--bg-secondary); }
.tutorial-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.tutorial-item .tutorial-thumb {
  width: 40px;
  height: 30px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.tutorial-item .tutorial-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.tutorial-content {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 30px;
}
.tutorial-content h2 { font-family: var(--font-serif); margin-bottom: 12px; }
.tutorial-content img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 16px 0;
}
.tutorial-content .tutorial-step-text {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}
.tutorial-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .tutorial-layout {
    grid-template-columns: 1fr;
  }
  .tutorial-sidebar {
    position: static;
    max-height: none;
  }
}

/* Hidden */
.hidden { display: none !important; }
