/* ============================================================
   VARIABLES
============================================================ */
:root {
  /* GAMING NEON PALETTE */
  --neon-cyan: #06b6d4;   /* Electric Cyan */
  --neon-pink: #f472b6;   /* Hot Pink */
  --neon-purple: #a855f7; /* Bright Purple */
  --neon-blue: #3b82f6;   /* Royal Blue */
  
  /* DARK MODE VARS (OLED) */
  --bg-dark: #000000;    
  --card-dark: #000000;
  --border-neon: rgba(6, 182, 212, 0.5);
  
  --text-main-dark: #f1f5f9;
  --text-muted-dark: #94a3b8;
  
  /* LIGHT MODE VARS */
  --bg-light: #f3f4f6;
  --text-main-light: #111827;
  --text-muted-light: #4b5563;
}

/* ============================================================
   RESET
============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================================
   MODES
============================================================ */
body.dark { background: #000000; color: var(--text-main-dark); }
body.light {
  background: radial-gradient(circle at top, #e5e7eb 0, #f9fafb 40%, #f3f4f6 100%);
  color: var(--text-main-light);
}

/* ============================================================
   COMMON
============================================================ */
.hidden { display: none !important; }
.page-section { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ============================================================
   HEADER (SCROLLS AWAY)
============================================================ */
header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
}

body.dark header {
  background: transparent;
  border-bottom: 1px solid rgba(6, 182, 212, 0.1);
}

body.light header {
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-controls { display: flex; gap: 0.5rem; }

header h1 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: 0.5px; }
body.dark header h1 { 
    background: linear-gradient(to right, var(--neon-cyan), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
}
body.light header h1 { color: #111827; }

.theme-toggle {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.dark .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  color: var(--neon-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
body.dark .theme-toggle:hover {
  box-shadow: 0 0 15px var(--neon-cyan);
  background: var(--neon-cyan);
  color: #000;
}

body.light .theme-toggle {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* ============================================================
   SEARCH BAR
============================================================ */
main { padding-top: 0.5rem; }
#search { margin-bottom: 1.5rem; }

#searchBar {
  margin: 0 auto;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  transition: all 0.3s ease;
}

body.dark #searchBar {
  background: #000000;
  border: 1px solid var(--neon-purple); 
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15); 
}
body.dark #searchBar:focus-within {
  border-color: var(--neon-pink);
  box-shadow: 0 0 20px rgba(244, 114, 182, 0.3);
}

body.light #searchBar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 25px rgba(148, 163, 184, 0.15);
}

#searchInput {
  flex: 1; border: none; outline: none; background: transparent; font-size: 0.95rem; padding: 0.45rem 0.85rem;
}
body.dark #searchInput { color: #fff; }
body.light #searchInput { color: #111827; }
#searchInput::placeholder { color: #64748b; }

#searchButton, #clearSearchButton {
  border-radius: 999px; border: none; padding: 0.45rem 0.85rem; cursor: pointer;
}
body.dark #searchButton { background: transparent; color: var(--neon-cyan); }
body.light #searchButton { background: #0f172a; color: #fff; }

#resultsInfo { text-align: center; margin-top: 0.5rem; font-size: 0.8rem; opacity: 0.8; }

/* ============================================================
   STICKY CATEGORY NAV (CENTERED)
============================================================ */
.category-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    
    display: flex;
    justify-content: center; /* Center Items on Desktop */
    gap: 0.8rem;
    overflow-x: auto;
    
    width: 100%;
    padding: 0.8rem 1.5rem;
    margin: 0 0 2rem 0;
    
    white-space: nowrap;
    backdrop-filter: blur(16px);
    
    -ms-overflow-style: none;
    scrollbar-width: none;
    
    transition: background 0.3s ease, border-color 0.3s ease;
}
.category-nav::-webkit-scrollbar { display: none; }

/* Mobile Override: Align Left for Scrolling */
@media (max-width: 768px) {
    .category-nav {
        justify-content: flex-start;
    }
}

body.dark .category-nav {
    background: rgba(0, 0, 0, 0.85);
    border-bottom: 1px solid rgba(6, 182, 212, 0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

body.light .category-nav {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.cat-nav-chip {
    padding: 0.4rem 1.2rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    flex-shrink: 0;
}

body.dark .cat-nav-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
}
body.dark .cat-nav-chip:hover {
    color: #fff;
    border-color: var(--neon-cyan);
    background: rgba(6, 182, 212, 0.1);
}
body.dark .cat-nav-chip.active {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
    border-color: var(--neon-cyan);
    transform: scale(1.05);
}

body.light .cat-nav-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
}
body.light .cat-nav-chip:hover {
    background: #f1f5f9;
    color: #0f172a;
}
body.light .cat-nav-chip.active {
    background: #0f172a;
    color: #fff;
    border-color: #0f172a;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

/* ============================================================
   SKELETON LOADING
============================================================ */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-grid {
    display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center;
}

.skeleton-card {
    width: 230px; height: 350px;
    border-radius: 18px;
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

body.light .skeleton-card {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
}

/* ============================================================
   CATEGORY BLOCKS
============================================================ */
.category-block {
    margin-bottom: 3.5rem; padding: 1.5rem; border-radius: 24px; position: relative; transition: all 0.3s ease;
    scroll-margin-top: 80px; /* Offset for sticky nav */
}

body.dark .category-block {
    background: rgba(10, 10, 10, 0.5); border: 1px solid var(--neon-cyan); 
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.05);
}
body.dark .category-block:hover {
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.15), inset 0 0 20px rgba(6, 182, 212, 0.05);
    border-color: #22d3ee;
}

body.light .category-block {
    background: #ffffff; border: 1px solid #e2e8f0; box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

/* ============================================================
   CATEGORY HEADER
============================================================ */
.category-header {
    position: relative; display: flex; align-items: center; justify-content: flex-end;
    padding: 0.4rem 1.2rem; min-height: 44px; border-radius: 999px; margin-bottom: 2rem; z-index: 5;
    background: linear-gradient(135deg, var(--neon-purple) 0%, var(--neon-pink) 100%);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.4), 0 0 20px rgba(244, 114, 182, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.cat-title {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    font-size: 1.15rem; font-weight: 800; margin: 0;
    color: #ffffff !important; text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    white-space: nowrap; text-transform: capitalize;
}

.cat-controls { display: flex; gap: 0.4rem; position: relative; z-index: 2; }

.ctrl-btn {
    width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; background: rgba(255,255,255,0.15); color: #fff;
    backdrop-filter: blur(4px); transition: all 0.2s;
}
.ctrl-btn:hover { background: #fff; color: var(--neon-pink); transform: translateY(-2px); box-shadow: 0 0 10px #fff; }

/* ============================================================
   BOOK CARDS
============================================================ */
.books-container { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; }
.books-container.list-view { flex-direction: column; justify-content: flex-start; }

.book-card {
  width: 230px; border-radius: 18px; padding: 0.9rem;
  position: relative; cursor: pointer; display: flex; flex-direction: column;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.dark .book-card { background: #000000; border: 1px solid rgba(6, 182, 212, 0.3); }
body.dark .book-card:hover {
  transform: translateY(-6px) scale(1.02); background: #050505;
  border-color: var(--neon-cyan); 
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.25), inset 0 0 10px rgba(6, 182, 212, 0.1);
}

body.light .book-card {
  background: linear-gradient(145deg, #ffffff, #f3f4f6); border: 1px solid transparent;
  box-shadow: 0 12px 32px rgba(148, 163, 184, 0.3);
}
body.light .book-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(148, 163, 184, 0.5); }

.bookmark-btn {
  position: absolute; top: 0.45rem; right: 0.45rem; padding: 0.3rem 0.5rem; border-radius: 999px; border: none;
  cursor: pointer; font-size: 0.9rem; z-index: 2; transition: transform 0.2s;
}
body.dark .bookmark-btn { background: #000000; color: #fbbf24; border: 1px solid #333; }
body.light .bookmark-btn { background: #fff; color: #f59e0b; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.bookmark-btn:hover { transform: scale(1.15); }

.book-cover {
  width: 100%; aspect-ratio: 2 / 3; border-radius: 12px;
  object-fit: cover; margin-bottom: 0.8rem; box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.book-info { display: flex; flex-direction: column; flex: 1; }
.book-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.3rem; line-height: 1.4; }
body.dark .book-title { color: #f8fafc; text-shadow: 0 0 10px rgba(0,0,0,0.3); }
body.light .book-title { color: #111827; }

.book-author { font-size: 0.85rem; margin-bottom: 0.2rem; }
body.dark .book-author { color: var(--neon-cyan); } 
body.light .book-author { color: #64748b; }

.book-links { margin-top: auto; }
.book-links a {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; padding: 0.6rem 1rem; border-radius: 999px; text-decoration: none;
  font-size: 0.85rem; font-weight: 600; transition: all 0.2s; border: none;
}
body.dark .book-links a {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple)); color: #fff;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}
body.dark .book-links a:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(6, 182, 212, 0.5); }
body.light .book-links a {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6); color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}
body.light .book-links a:hover { opacity: 0.95; transform: translateY(-1px); box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4); }

/* ============================================================
   MODALS
============================================================ */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; backdrop-filter: blur(5px); }

body.dark .modal-overlay { background: rgba(0, 0, 0, 0.9); }
body.light .modal-overlay { background: rgba(255, 255, 255, 0.5); }

.modal-dialog {
  position: relative; width: min(480px, 95vw); max-height: 90vh; overflow-y: auto;
  border-radius: 20px; padding: 1.5rem; transition: all 0.3s;
}

body.dark .modal-dialog { background: #000000; border: 1px solid var(--neon-cyan); box-shadow: 0 0 40px rgba(6, 182, 212, 0.15); }
body.light .modal-dialog { background: #ffffff; box-shadow: 0 25px 50px rgba(0,0,0,0.15); border: 1px solid #f1f5f9; }

.modal-close {
  position: absolute; top: 1rem; right: 1rem; border: none; background: transparent; font-size: 1.2rem; cursor: pointer;
}
body.dark .modal-close { color: #94a3b8; }
body.dark .modal-close:hover { color: #fff; text-shadow: 0 0 10px #fff; }
body.light .modal-close { color: #64748b; }
body.light .modal-close:hover { color: #000; }

.modal-book-header { display: flex; gap: 1rem; margin-bottom: 1rem; }
.modal-cover { width: 120px; border-radius: 8px; box-shadow: 0 10px 20px rgba(0,0,0,0.3); }

.modal-book-main h3 { margin: 0 0 0.5rem; font-size: 1.2rem; font-weight: 700; }
body.dark .modal-book-main h3 { color: var(--neon-cyan); }
body.light .modal-book-main h3 { color: #111827; }
.modal-author-category { font-size: 0.9rem; line-height: 1.5; }
body.dark .modal-author-category { color: #cbd5e1; }
body.light .modal-author-category { color: #4b5563; }

.tag-chip {
    padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; margin-left: 0.3rem; display: inline-block; vertical-align: middle;
}
body.dark .tag-chip { border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }
body.light .tag-chip { background: #f3f4f6; color: #374151; }

.modal-actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; }
.modal-btn {
    flex: 1; padding: 0.75rem; border-radius: 12px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    text-decoration: none; font-weight: 600; transition: transform 0.2s;
}
.modal-btn:hover { transform: translateY(-2px); }

body.dark .modal-btn:first-child { 
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple)); color: #fff; box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}
body.dark .modal-btn:nth-child(2) { background: #000; border: 1px solid #475569; color: #cbd5e1; }
body.dark .modal-btn:nth-child(2):hover { border-color: #fff; color: #fff; }
body.dark .modal-btn:nth-child(3) { background: transparent; border: 1px solid #a855f7; color: #a855f7; }
body.dark .modal-btn:nth-child(3):hover { background: #a855f7; color: #fff; box-shadow: 0 0 15px #a855f7; }

body.light .modal-btn:first-child { 
    background: linear-gradient(135deg, #2563eb, #7c3aed); color: #ffffff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
body.light .modal-btn:first-child:hover { box-shadow: 0 6px 15px rgba(37, 99, 235, 0.4); }
body.light .modal-btn:nth-child(2) { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
body.light .modal-btn:nth-child(2):hover { background: #e2e8f0; color: #0f172a; border-color: #94a3b8; }
body.light .modal-btn:nth-child(3) { background: #fdf2f8; color: #db2777; border: 1px solid #fbcfe8; }
body.light .modal-btn:nth-child(3):hover { background: #fce7f3; }

/* Related Books */
.related-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(148, 163, 184, 0.2); }
.related-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.8rem; }
body.dark .related-title { color: var(--neon-cyan); }
.related-grid { display: flex; gap: 0.8rem; overflow-x: auto; padding-bottom: 0.5rem; }
.related-card { min-width: 90px; width: 90px; cursor: pointer; transition: transform 0.2s; }
.related-card:hover { transform: translateY(-3px); }
.related-cover { width: 100%; aspect-ratio: 2/3; border-radius: 8px; object-fit: cover; box-shadow: 0 4px 8px rgba(0,0,0,0.3); margin-bottom: 0.3rem; }
.related-name { font-size: 0.7rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }


/* ============================================================
   MOBILE BOTTOM NAV
============================================================ */
.mobile-bottom-nav {
  position: fixed; bottom: 0; width: 100%; display: none;
  justify-content: space-around; padding: 0.8rem; z-index: 40;
}
body.dark .mobile-bottom-nav { background: rgba(0, 0, 0, 0.95); border-top: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(10px); }
body.light .mobile-bottom-nav { background: #fff; border-top: 1px solid #e5e7eb; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); }

.mobile-bottom-nav button { border: none; background: transparent; font-size: 1.4rem; cursor: pointer; }
body.dark .mobile-bottom-nav button { color: #64748b; }
body.dark .mobile-bottom-nav button:hover, body.dark .mobile-bottom-nav button:active { color: var(--neon-cyan); filter: drop-shadow(0 0 5px var(--neon-cyan)); }
body.light .mobile-bottom-nav button { color: #6b7280; }
body.light .mobile-bottom-nav button:hover, body.light .mobile-bottom-nav button:active { color: #2563eb; }

/* ============================================================
   RESPONSIVE 
============================================================ */
@media (max-width: 768px) {
  .mobile-bottom-nav { display: flex; }
  footer { margin-bottom: 70px; }
  .books-container:not(.list-view) .book-card { width: 45%; max-width: 200px; padding: 0.6rem; }
  .book-cover { margin-bottom: 0.5rem; }
  .category-header { padding: 0.4rem 1rem; }
  .cat-title { font-size: 1rem; }
}

footer { text-align: center; padding: 2rem; color: #64748b; font-size: 0.8rem; }
