:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #f59e0b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-dark: #0f172a;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1280px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

/* ===== HEADER ===== */
.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.logo:hover { color: var(--text); }
.logo-icon { font-size: 1.6rem; }
.logo-accent { color: var(--primary); }

.nav { display: flex; gap: 0.25rem; }

.nav-link {
  padding: 0.5rem 1rem;
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
  margin-left: auto;
  flex: 0 1 320px;
}

.search-bar input {
  border: none;
  background: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  color: var(--text);
}

.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 50%, #fefce8 100%);
  padding: 5rem 0;
  overflow: hidden;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1.25rem;
  color: var(--bg-dark);
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.hero-stats {
  display: flex;
  gap: 2.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
}

.hero-books {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  perspective: 800px;
}

.hero-book {
  transform: rotateY(-8deg) rotateX(3deg);
  transition: transform 0.4s;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 8px 8px 30px rgba(0,0,0,0.15);
}

.hero-book:nth-child(2) { transform: rotateY(-3deg) translateY(-15px); }
.hero-book:nth-child(3) { transform: rotateY(2deg) rotateX(-2deg); }
.hero-book:hover { transform: rotateY(0deg) rotateX(0deg) scale(1.05); }

.hero-book img {
  width: 100%;
  display: block;
  aspect-ratio: 2/3;
  object-fit: cover;
}

/* ===== SECTIONS ===== */
.section { padding: 4rem 0; }
.section-alt { background: var(--bg-alt); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.section-header h2 { font-size: 1.5rem; font-weight: 700; }

.see-all {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
}

/* ===== BOOK GRID ===== */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
  border: 1px solid var(--border);
}

.book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.book-cover {
  position: relative;
  aspect-ratio: 2/3;
  overflow: hidden;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}

.book-card:hover .book-cover img { transform: scale(1.05); }

.book-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-free { background: #10b981; color: #fff; }
.badge-new { background: var(--primary); color: #fff; }
.badge-bestseller { background: var(--accent); color: #fff; }

.book-info { padding: 0.75rem; }

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

.book-author {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.book-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.book-price .original {
  text-decoration: line-through;
  color: var(--text-lighter);
  font-weight: 400;
  font-size: 0.75rem;
  margin-left: 0.3rem;
}

/* ===== CATEGORIES ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.3s;
  text-decoration: none;
  color: var(--text);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  color: var(--primary);
}

.cat-icon { font-size: 2rem; }
.cat-name { font-weight: 600; font-size: 0.9rem; }

/* ===== AD CONTAINER ===== */
.ad-container {
  padding: 1.5rem 0;
  min-height: 90px;
  text-align: center;
}

/* ===== NEWSLETTER ===== */
.newsletter {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  padding: 4rem 0;
  color: #fff;
  text-align: center;
}

.newsletter h2 { font-size: 2rem; margin-bottom: 0.75rem; }
.newsletter p { opacity: 0.9; margin-bottom: 2rem; font-size: 1.05rem; }

.newsletter-form {
  display: flex;
  gap: 0.75rem;
  max-width: 480px;
  margin: 0 auto;
}

.newsletter-form input {
  flex: 1;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  outline: none;
}

.newsletter-form .btn {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
  white-space: nowrap;
}

.newsletter-form .btn:hover {
  background: var(--bg-alt);
  color: var(--primary-dark);
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg-dark);
  color: #cbd5e1;
  padding: 4rem 0 0;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer-col .logo { color: #fff; margin-bottom: 1rem; font-size: 1.2rem; }
.footer-col .logo-accent { color: #60a5fa; }
.footer-col > p { font-size: 0.9rem; line-height: 1.6; color: #94a3b8; }
.footer-col h4 { color: #fff; margin-bottom: 1rem; font-size: 0.95rem; }
.footer-col a { display: block; color: #94a3b8; font-size: 0.85rem; padding: 0.25rem 0; transition: color 0.2s; }
.footer-col a:hover { color: #60a5fa; }

.footer-bottom {
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
}

.footer-bottom a { color: #60a5fa; }

/* ===== PAGE LAYOUT ===== */
.page-header {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  padding: 3rem 0;
  text-align: center;
}

.page-header h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.page-header p { color: var(--text-light); font-size: 1.05rem; }

.content-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  padding: 2rem 0;
}

.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}

.sidebar-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.sidebar-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-card a {
  display: block;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: var(--text-light);
}

.sidebar-card a:hover { color: var(--primary); }

/* ===== CONTACT / ABOUT ===== */
.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.static-page h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.static-page h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
  color: var(--primary);
}

.static-page p {
  margin-bottom: 1rem;
  color: var(--text-light);
  line-height: 1.8;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.contact-form input,
.contact-form textarea {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--primary);
}

.contact-form textarea { min-height: 150px; resize: vertical; }

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-lighter);
  font-size: 1.1rem;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-cta { justify-content: center; }
  .hero-stats { justify-content: center; }
  .hero-books { max-width: 400px; margin: 0 auto; }
  .content-with-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .nav { display: none; }
  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: #fff;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    z-index: 99;
  }
  .mobile-toggle { display: block; margin-left: auto; }
  .search-bar { flex: 0 1 200px; }
  .hero { padding: 3rem 0; }
  .hero-cta { flex-direction: column; align-items: center; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1rem; }
  .footer-inner { grid-template-columns: 1fr; }
}
