/* ===== FONTS ===== */
@font-face {
  font-family: 'BebasNeue';
  src: url('../../../cdn/fonts/BebasNeue-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'BebasNeue';
  src: url('../../../cdn/fonts/BebasNeue-Bold.ttf') format('truetype');
  font-weight: 700;
}
@font-face {
  font-family: 'BebasNeue';
  src: url('../../../cdn/fonts/BebasNeue-Light.ttf') format('truetype');
  font-weight: 300;
}

/* ===== CSS VARIABLES ===== */
:root {
  --bg-primary: #181818;
  --bg-secondary: #222222;
  --bg-card: #2a2a2a;
  --bg-card-hover: #333333;
  --bg-input: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #777777;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --border: #3a3a3a;
  --border-light: #444444;
  --glow: rgba(255,255,255,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }

/* ===== UTILITIES ===== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ===== NAVBAR ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(24,24,24,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.navbar .container {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand img { width: 40px; height: 40px; border-radius: 50%; }
.nav-brand-text { font-family: 'BebasNeue', sans-serif; font-size: 1.3rem; letter-spacing: 1px; }
.nav-links { display: flex; gap: 8px; }
.nav-links a {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary); background: var(--glow);
}
.nav-search {
  position: relative; flex: 0 1 320px;
}
.nav-search input {
  width: 100%; padding: 10px 16px 10px 40px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-xl); outline: none;
  font-size: 0.875rem; color: var(--text-primary);
  transition: var(--transition);
}
.nav-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.nav-search input::placeholder { color: var(--text-muted); }
.nav-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1.1rem; pointer-events: none;
}
.mobile-menu-btn { display: none; padding: 8px; color: var(--text-secondary); }

/* ===== HERO ===== */
.hero {
  position: relative; padding: 80px 0 60px; overflow: hidden;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url('../../../cdn/images/wallpaper.png') center/cover no-repeat;
  opacity: 0.04;
}
.hero .container { position: relative; z-index: 1; text-align: center; }
.hero-logo { width: 100px; height: 100px; border-radius: 50%; margin: 0 auto 24px; box-shadow: 0 0 40px rgba(255,255,255,0.1); }
.hero h1 { font-family: 'BebasNeue', sans-serif; font-size: 3rem; letter-spacing: 3px; margin-bottom: 8px; }
.hero-tagline { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.hero-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 36px; }
.hero-search {
  max-width: 560px; margin: 0 auto; position: relative;
}
.hero-search input {
  width: 100%; padding: 16px 24px 16px 52px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-xl); font-size: 1rem; color: var(--text-primary);
  outline: none; transition: var(--transition);
}
.hero-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(245,158,11,0.15); }
.hero-search input::placeholder { color: var(--text-muted); }
.hero-search-icon {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1.25rem;
}
.hero-stats {
  display: flex; justify-content: center; gap: 48px; margin-top: 40px;
}
.hero-stat { text-align: center; }
.hero-stat-num { font-family: 'BebasNeue', sans-serif; font-size: 2rem; color: var(--accent); }
.hero-stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ===== SECTIONS ===== */
.section { padding: 48px 0; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-title {
  font-family: 'BebasNeue', sans-serif; font-size: 1.6rem; letter-spacing: 1px;
}
.section-link {
  font-size: 0.85rem; color: var(--accent); font-weight: 500;
  transition: var(--transition);
}
.section-link:hover { color: var(--accent-hover); }

/* ===== LEVEL CARDS ===== */
.level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.level-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px;
  text-align: center; cursor: pointer; transition: var(--transition);
  position: relative; overflow: hidden;
}
.level-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(245,158,11,0.06));
  opacity: 0; transition: var(--transition);
}
.level-card:hover {
  transform: translateY(-4px); border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(245,158,11,0.1);
}
.level-card:hover::before { opacity: 1; }
.level-card-icon { font-size: 2rem; margin-bottom: 8px; }
.level-card-name { font-family: 'BebasNeue', sans-serif; font-size: 1.2rem; margin-bottom: 4px; position: relative; }
.level-card-count { font-size: 0.8rem; color: var(--text-muted); position: relative; }

/* ===== LEVEL GROUP (school-level sections) ===== */
.level-group-header {
  font-family: 'BebasNeue', sans-serif; font-size: 1.15rem;
  letter-spacing: 1px; color: var(--text-secondary);
  margin-bottom: 12px; margin-top: 20px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.level-group-header:first-child { margin-top: 0; }
.level-group-count {
  font-family: 'Poppins', sans-serif; font-size: 0.8rem;
  color: var(--text-muted); font-weight: 400; letter-spacing: 0;
}
.level-group-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 16px;
}

/* ===== CURRICULUM PILLS ===== */
.curriculum-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.curriculum-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-xl);
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: var(--transition);
}
.curriculum-pill:hover { border-color: var(--accent); transform: translateY(-2px); }
.curriculum-pill .dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.curriculum-pill .count {
  background: var(--bg-primary); padding: 2px 8px; border-radius: 12px;
  font-size: 0.75rem; color: var(--text-muted);
}

/* ===== BOOK CARDS ===== */
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.book-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  cursor: pointer; transition: var(--transition);
}
.book-card:hover {
  transform: translateY(-6px); border-color: rgba(255,255,255,0.15);
  box-shadow: var(--shadow-lg);
}
.book-card-cover {
  height: 160px; display: flex; align-items: center; justify-content: center;
  font-family: 'BebasNeue', sans-serif; font-size: 2.5rem; color: rgba(255,255,255,0.7);
  position: relative; overflow: hidden;
}
.book-card-cover::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40%;
  background: linear-gradient(transparent, rgba(0,0,0,0.3));
}
.book-card-body { padding: 16px; }
.book-card-title {
  font-size: 0.9rem; font-weight: 600; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.book-card-level { font-size: 0.75rem; color: var(--text-muted); }
.book-card-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 12px;
  background: rgba(245,158,11,0.15); color: var(--accent); font-weight: 600;
}
.book-card-dlp {
  font-size: 0.65rem; padding: 2px 6px; border-radius: 8px;
  background: rgba(46,204,113,0.15); color: #2ecc71; font-weight: 600;
}

/* ===== BROWSE PAGE ===== */
.browse-layout {
  display: grid; grid-template-columns: 260px 1fr;
  gap: 32px; padding: 32px 0;
}
.browse-sidebar {
  position: sticky; top: 80px; align-self: start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.filter-group { margin-bottom: 24px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-label {
  font-family: 'BebasNeue', sans-serif; font-size: 1rem;
  letter-spacing: 1px; margin-bottom: 12px; color: var(--text-secondary);
}
.filter-options { display: flex; flex-direction: column; gap: 6px; }
.filter-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 0.85rem; cursor: pointer; transition: var(--transition);
}
.filter-option:hover { background: var(--glow); }
.filter-option.active { background: rgba(245,158,11,0.1); color: var(--accent); }
.filter-option input[type="checkbox"],
.filter-option input[type="radio"] { display: none; }
.filter-check {
  width: 18px; height: 18px; border: 2px solid var(--border-light);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  transition: var(--transition); flex-shrink: 0;
}
.filter-option.active .filter-check {
  background: var(--accent); border-color: var(--accent);
}
.filter-option.active .filter-check::after {
  content: ''; width: 6px; height: 10px;
  border: solid var(--bg-primary); border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.filter-count {
  margin-left: auto; font-size: 0.75rem; color: var(--text-muted);
}
.browse-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.browse-results { font-size: 0.9rem; color: var(--text-secondary); }
.browse-sort select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.85rem;
  color: var(--text-primary); outline: none;
}
.browse-active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.active-filter-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-xl);
  background: rgba(245,158,11,0.12); color: var(--accent);
  font-size: 0.8rem; font-weight: 500;
}
.active-filter-tag button {
  font-size: 1rem; line-height: 1; color: var(--accent); opacity: 0.7;
}
.active-filter-tag button:hover { opacity: 1; }
.clear-filters-btn {
  padding: 4px 12px; border-radius: var(--radius-xl);
  background: transparent; border: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
  transition: var(--transition);
}
.clear-filters-btn:hover { border-color: var(--accent); color: var(--accent); }
.mobile-filter-toggle {
  display: none; padding: 10px 20px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--text-primary); margin-bottom: 16px;
}

/* ===== BOOK DETAIL ===== */
.book-detail { padding: 40px 0 60px; }
.breadcrumb {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 32px; font-size: 0.85rem; color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); transition: var(--transition); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border-light); }
.book-detail-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 48px; align-items: start;
}
.book-detail-cover {
  aspect-ratio: 3/4; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-family: 'BebasNeue', sans-serif; font-size: 4rem; color: rgba(255,255,255,0.6);
  position: relative; overflow: hidden; box-shadow: var(--shadow-lg);
}
.book-detail-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4));
}
.book-detail-info h1 {
  font-family: 'BebasNeue', sans-serif; font-size: 2.2rem;
  letter-spacing: 1px; margin-bottom: 8px;
}
.book-detail-subject { font-size: 1rem; color: var(--text-secondary); margin-bottom: 24px; }
.book-meta-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 32px;
}
.book-meta-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.book-meta-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.book-meta-value { font-size: 0.95rem; font-weight: 500; }
.download-section { margin-bottom: 32px; }
.download-section h2 {
  font-family: 'BebasNeue', sans-serif; font-size: 1.3rem;
  letter-spacing: 1px; margin-bottom: 16px;
}
.download-buttons { display: flex; flex-direction: column; gap: 12px; }
.download-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-radius: var(--radius-md);
  font-size: 0.95rem; font-weight: 600; transition: var(--transition);
  border: 1px solid transparent;
}
.download-btn:hover { transform: translateY(-2px); }
.download-btn-icon { font-size: 1.4rem; flex-shrink: 0; width: 28px; text-align: center; }
.download-btn-text { flex: 1; text-align: left; }
.download-btn-arrow { font-size: 1.1rem; opacity: 0.5; transition: var(--transition); }
.download-btn:hover .download-btn-arrow { opacity: 1; transform: translateX(4px); }
.download-btn.telegram {
  background: linear-gradient(135deg, #0088cc, #0077b5);
  color: #fff;
}
.download-btn.telegram:hover { box-shadow: 0 4px 20px rgba(0,136,204,0.3); }
.download-btn.pdf {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}
.download-btn.pdf:hover { box-shadow: 0 4px 20px rgba(231,76,60,0.3); }
.download-btn.gdrive {
  background: linear-gradient(135deg, #34a853, #2d8f47);
  color: #fff;
}
.download-btn.gdrive:hover { box-shadow: 0 4px 20px rgba(52,168,83,0.3); }
.download-unavailable {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px; border-radius: var(--radius-md);
  background: var(--bg-card); border: 1px dashed var(--border-light);
  color: var(--text-muted);
}
.download-unavailable-icon { font-size: 1.6rem; opacity: 0.5; flex-shrink: 0; }
.download-unavailable-text { font-size: 0.9rem; }
.related-section h2 {
  font-family: 'BebasNeue', sans-serif; font-size: 1.3rem;
  letter-spacing: 1px; margin-bottom: 16px;
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg-secondary); border-top: 1px solid var(--border);
  padding: 40px 0 24px;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px;
}
.footer-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.footer-brand img { width: 36px; height: 36px; border-radius: 50%; }
.footer-brand span { font-family: 'BebasNeue', sans-serif; font-size: 1.2rem; }
.footer-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.7; }
.footer-title { font-family: 'BebasNeue', sans-serif; font-size: 1rem; letter-spacing: 1px; margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-links a {
  font-size: 0.85rem; color: var(--text-muted); transition: var(--transition);
}
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border); padding-top: 20px;
  text-align: center; font-size: 0.8rem; color: var(--text-muted);
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.skeleton-card { height: 280px; border-radius: var(--radius-md); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state-text { font-size: 1rem; }

/* ===== SEARCH RESULTS DROPDOWN ===== */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-top: 8px;
  max-height: 400px; overflow-y: auto; z-index: 200;
  box-shadow: var(--shadow-lg); display: none;
}
.search-dropdown.active { display: block; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--glow); }
.search-result-color {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: 'BebasNeue', sans-serif; font-size: 0.9rem;
  color: rgba(255,255,255,0.7); flex-shrink: 0;
}
.search-result-info { flex: 1; min-width: 0; }
.search-result-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.5s ease forwards; opacity: 0; }
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .browse-layout { grid-template-columns: 1fr; }
  .browse-sidebar { position: static; display: none; }
  .browse-sidebar.open { display: block; }
  .mobile-filter-toggle { display: flex; align-items: center; gap: 8px; }
  .book-detail-layout { grid-template-columns: 1fr; }
  .book-detail-cover { max-width: 280px; margin: 0 auto; }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .hero h1 { font-size: 2.2rem; }
  .hero-stats { gap: 24px; }
  .nav-search { display: none; }
  .nav-links { display: none; }
  .mobile-menu-btn { display: block; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .book-card-cover { height: 120px; font-size: 2rem; }
  .book-meta-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .hero { padding: 48px 0 36px; }
  .hero-logo { width: 72px; height: 72px; }
  .hero h1 { font-size: 1.8rem; }
  .section { padding: 32px 0; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}
