@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
  /* Light Theme Colors (Default) */
  --bg-color: #f4f9fb;
  --text-main: #111b2b;
  --text-muted: #64748b;
  --header-bg: rgba(244, 249, 251, 0.85);
  
  --primary-color: #00c6d9; /* Teal accent */
  --primary-hover: #00a6b7;
  --gold-accent: #f5b041;
  
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.05);
  --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
  
  --input-bg: #ffffff;
  --input-border: rgba(0, 0, 0, 0.1);
  --input-focus: #00c6d9;
  
  --banner-bg: #0d2746;
  --banner-text: #ffffff;
  
  --toggle-bg: #1e293b;
  --toggle-icon: #ffffff;
  
  /* Additional */
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(0,0,0,0.03);
}

[data-theme="dark"] {
  /* Dark Theme Colors */
  --bg-color: #051421; /* Very dark blue matching image */
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --header-bg: rgba(5, 20, 33, 0.85);
  
  --card-bg: #0b1f32;
  --card-border: rgba(0, 198, 217, 0.15); /* Teal slight border */
  --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  
  --input-bg: rgba(255, 255, 255, 0.03);
  --input-border: rgba(0, 198, 217, 0.3);
  --input-focus: #00c6d9;
  
  --toggle-bg: #00c6d9;
  --toggle-icon: #051421;

  --sidebar-active: #0b1f32;
  --sidebar-hover: rgba(255,255,255,0.03);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* Background Pattern Overlay */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
  background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M50 0 L100 50 L50 100 L0 50 Z" fill="none" stroke="%2300c6d9" stroke-width="0.5"/></svg>');
  background-size: 100px 100px;
}
[data-theme="dark"] .bg-pattern { opacity: 0.05; }

/* ---------------- HEADER ---------------- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 6%;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--card-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon svg {
  width: 38px;
  height: 38px;
  color: var(--primary-color);
}

.logo-text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}

nav ul {
  display: flex;
  list-style: none;
  gap: 32px;
}

nav a {
  color: var(--text-main);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  padding-bottom: 6px;
}

nav a:hover {
  color: var(--primary-color);
}

nav a.active {
  color: var(--gold-accent);
}

nav a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--gold-accent);
  border-radius: 2px;
}

/* ---------------- SEARCH BAR ---------------- */
.global-search {
  max-width: 650px;
  margin: 30px auto;
  position: relative;
  z-index: 10;
}

.global-search input {
  width: 100%;
  padding: 16px 24px 16px 50px;
  border-radius: 50px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  box-shadow: var(--box-shadow);
}

.global-search input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 198, 217, 0.15);
}

.global-search i {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}

/* ---------------- HOME HERO BANNER ---------------- */
.hero-banner {
  background: var(--banner-bg);
  border-radius: 20px;
  margin: 20px 6%;
  padding: 40px 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--box-shadow);
}
.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(0,198,217,0.1) 0%, transparent 60%);
  target: none;
}

.banner-content h1 {
  color: var(--banner-text);
  font-size: 32px;
  font-weight: 700;
  max-width: 400px;
  line-height: 1.4;
  z-index: 2;
  position: relative;
}

.banner-illustration {
  z-index: 2;
  position: relative;
}
.banner-illustration i {
  font-size: 120px;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 0 30px rgba(0,198,217,0.5);
}

.banner-arrow {
  color: rgba(255,255,255,0.5);
  font-size: 24px;
  cursor: pointer;
  z-index: 2;
  padding: 10px;
}
.banner-arrow:hover { color: white; }

/* ---------------- CONTAINER & GRID ---------------- */
.container {
  padding: 40px 6%;
}

.section-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
}

.book-row-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-all {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.view-all:hover { text-decoration: underline; }

.horizontal-scroll {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 20px;
  scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar { display: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* ---------------- BOOK CARD ---------------- */
.book-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--box-shadow);
  text-decoration: none;
  color: var(--text-main);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 25px rgba(0, 198, 217, 0.2);
}

.book-cover {
  width: 100%;
  height: 240px;
  border-radius: 10px;
  object-fit: cover;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6); /* Fallback */
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  position: relative;
}

.book-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Hover Overlay in Dark Mode styles (neon) */
.hover-overlay {
  position: absolute;
  top: 16px; left: 16px; right: 16px; height: 240px;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s;
  gap: 15px;
}

.book-card:hover .hover-overlay {
  opacity: 1;
}

[data-theme="light"] .hover-overlay { display: none; } /* Show normally below instead */

.hover-overlay-icons {
  display: flex;
  gap: 12px;
}
.hover-overlay-icons div {
  background: rgba(255,255,255,0.1);
  padding: 8px;
  border-radius: 8px;
  color: white;
  text-align: center;
  font-size: 12px;
  backdrop-filter: blur(4px);
}
.hover-overlay-icons div i { font-size: 16px; margin-bottom: 4px; display: block; }
.hover-overlay .rating { color: var(--gold-accent); font-weight: 600; font-size: 14px; }

/* ---------------- THEME TOGGLE ---------------- */
.theme-toggle {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 70px;
  height: 36px;
  background: var(--toggle-bg);
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.theme-toggle i {
  color: var(--toggle-icon);
  font-size: 14px;
  z-index: 2;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle .toggle-ball {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 30px;
  height: 30px;
  background: var(--bg-color);
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 1;
}

[data-theme="dark"] .theme-toggle .toggle-ball {
  transform: translateX(34px);
}


/* ---------------- CATALOG LAYOUT ---------------- */
.catalog-container {
  display: flex;
  padding: 20px 6%;
  gap: 40px;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
}

.filter-group {
  margin-bottom: 30px;
}

.filter-group h4 {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.filter-group ul {
  list-style: none;
}

.filter-group li {
  margin-bottom: 10px;
}

.filter-group a {
  text-decoration: none;
  color: var(--text-main);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.8;
}

.filter-group a:hover, .filter-group a.active-filter {
  opacity: 1;
  color: var(--primary-color);
}

.main-content {
  flex-grow: 1;
}

.catalog-search {
  max-width: 100%;
  margin: 0 0 30px 0;
}
.catalog-search input {
  background: transparent;
  border: 1px solid var(--primary-color);
  box-shadow: 0 0 15px rgba(0, 198, 217, 0.1);
}

/* ---------------- BOOK DETAILS LAYOUT ---------------- */
.book-detail-wrapper {
  display: flex;
  padding: 40px 6%;
  gap: 60px;
  align-items: flex-start;
}

.bd-cover {
  width: 320px;
  flex-shrink: 0;
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(0,198,217,0.15);
  border: 1px solid var(--card-border);
}

.bd-info {
  flex-grow: 1;
}

.bd-author {
  color: var(--text-muted);
  font-size: 18px;
  margin-bottom: 5px;
}

.bd-title {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 30px;
}

.bd-section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.bd-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.bd-actions {
  display: flex;
  gap: 20px;
  margin-bottom: 40px;
}

.btn {
  padding: 14px 30px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: #051421;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary-color);
  color: var(--primary-color);
}
.btn-outline:hover {
  background: rgba(0,198,217,0.1);
}

/* ---------------- AUDIO PLAYER ---------------- */
.floating-player {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 800px;
  background: var(--card-bg);
  border: 1px solid var(--primary-color);
  border-radius: 50px;
  padding: 15px 30px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(0,198,217,0.2);
  z-index: 100;
}

.player-controls { display: flex; gap: 15px; color: var(--text-main); font-size: 18px; cursor: pointer; }
.player-info { display: flex; align-items: center; gap: 15px; flex-grow: 1; }
.player-info img { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; }
.player-text h5 { font-size: 14px; margin-bottom: 3px; }
.player-text p { font-size: 11px; color: var(--text-muted); }

.progress-bar {
  flex-grow: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  position: relative;
  margin: 0 15px;
}
.progress-fill {
  position: absolute;
  left:0; top:0; height:100%; width: 45%;
  background: var(--primary-color);
  border-radius: 2px;
}
.player-volume { display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.vol-bar { width: 60px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; position:relative;}
.vol-fill { position:absolute; left:0; top:0; height:100%; width: 70%; background: var(--text-main); border-radius: 2px;}

/* ---------------- PROFILE LAYOUT ---------------- */
.profile-container {
  display: flex;
  padding: 40px 6%;
  gap: 40px;
}

.profile-sidebar {
  width: 260px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px 0;
  box-shadow: var(--box-shadow);
  border: 1px solid var(--card-border);
  height: fit-content;
}

.profile-nav {
  list-style: none;
}

.profile-nav li a {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 30px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.profile-nav li a:hover {
  background: var(--sidebar-hover);
}

.profile-nav li a.active {
  background: var(--sidebar-hover);
  border-left-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}

.profile-main {
  flex-grow: 1;
}

.profile-header {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 30px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 25px;
  box-shadow: var(--box-shadow);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
}

.stat-card h4 {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 15px;
  font-weight: 600;
}

.stat-number {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-sub { font-size: 12px; color: var(--text-muted); font-weight: 500;}

/* Custom Cover Generation */
.gen-cover {
  width: 100%;
  height: 240px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 15px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  text-align: center;
}
.c-blue { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.c-brown { background: linear-gradient(135deg, #5d4037, #8d6e63); }
.c-teal { background: linear-gradient(135deg, #00838f, #00bcd4); }
.c-dark { background: linear-gradient(135deg, #212121, #424242); }
.c-sand { background: linear-gradient(135deg, #d7ccc8, #bcaaa4); color: #3e2723; }
.c-red { background: linear-gradient(135deg, #8e0000, #b71c1c); }

.gen-cover-author { font-size: 10px; opacity: 0.8; }
.gen-cover-title { font-size: 22px; font-weight: 700; text-transform: uppercase; line-height: 1.2; font-family: 'Times New Roman', serif; }

.reading-progress { margin-top: 10px; }
.progress-text { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.bar-bg { width: 100%; height: 4px; background: var(--input-border); border-radius: 2px;}
.bar-fill { height: 100%; background: var(--primary-color); border-radius: 2px; }

/* Micro-animations */
.fade-in {
  animation: fadeIn 0.5s forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .catalog-container, .profile-container, .book-detail-wrapper {
      flex-direction: column;
  }
  .sidebar, .profile-sidebar, .bd-cover {
      width: 100%;
  }
  nav ul { display: none; } /* Add a mobile menu later if needed */
}
