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

:root {
  --primary: #1a56db;
  --primary-dark: #1341b0;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --mpesa: #00a550;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --white: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --card-shadow-hover: 0 10px 30px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ===== TOP BAR ===== */
.topbar {
  background: #111827;
  color: #d1d5db;
  font-size: 12.5px;
  padding: 7px 0;
}
.topbar-inner {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== HEADER ===== */
.header {
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon { font-size: 28px; }
.logo-name { font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.logo-tagline { font-size: 11px; color: var(--muted); }

.nav { display: flex; gap: 6px; margin-left: auto; }
.nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  transition: background .2s, color .2s;
}
.nav a:hover { background: #eff6ff; color: var(--primary); }

.cart-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .2s;
  white-space: nowrap;
}
.cart-btn:hover { background: var(--primary-dark); }
.cart-count {
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
}
.mobile-nav {
  display: none;
  flex-direction: column;
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}
.mobile-nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.mobile-nav.open { display: flex; }

/* ===== HERO ===== */
.hero {
  position: relative;
  background: linear-gradient(135deg, #1e3a8a 0%, #1a56db 50%, #0ea5e9 100%);
  color: white;
  padding: 90px 0 70px;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { position: relative; max-width: 720px; }
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: .3px;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 18px;
}
.hero p {
  font-size: 17px;
  opacity: .88;
  margin-bottom: 30px;
  max-width: 560px;
  line-height: 1.7;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 50px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 26px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: white;
  border: 2px solid rgba(255,255,255,.6);
}
.btn-outline:hover { background: rgba(255,255,255,.1); }
.full-width { width: 100%; justify-content: center; }

.hero-stats {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; }
.stat-n { font-size: 24px; font-weight: 800; }
.stat span:last-child { font-size: 12px; opacity: .7; text-transform: uppercase; letter-spacing: .5px; }

/* ===== CATEGORIES ===== */
.categories { background: white; padding: 30px 0; border-bottom: 1px solid var(--border); }
.cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.cat-card span { font-size: 26px; }
.cat-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}

/* ===== PRODUCTS SECTION ===== */
.products-section { padding: 60px 0; }
.section-header { text-align: center; margin-bottom: 36px; }
.section-header h2 { font-size: 32px; font-weight: 800; margin-bottom: 10px; }
.section-header p { color: var(--muted); font-size: 15px; }

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all .2s;
}
.tab:hover, .tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* ===== PRODUCT CARD ===== */
.product-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: all .25s;
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-3px);
}
.product-img {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  position: relative;
  overflow: hidden;
}
.product-img.has-cover {
  background: #f3f4f6;
  height: 200px;
}
.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.book-cover-fallback {
  font-size: 60px;
  align-items: center;
  justify-content: center;
}
.product-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.product-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.product-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.product-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 5px;
  line-height: 1.35;
}
.product-unit {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.product-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.product-per-unit {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.add-to-cart {
  margin-top: auto;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.add-to-cart:hover { background: var(--primary-dark); }
.add-to-cart.added { background: var(--accent); }

/* ===== ABOUT ===== */
.about-section {
  background: white;
  padding: 70px 0;
  border-top: 1px solid var(--border);
}
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}
.about-text h2 { font-size: 30px; font-weight: 800; margin-bottom: 16px; }
.about-text p { color: var(--muted); line-height: 1.75; margin-bottom: 14px; }
.about-list { list-style: none; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.about-list li { font-size: 14.5px; font-weight: 500; }
.about-img-placeholder {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  border: 2px dashed #bfdbfe;
}
.about-img-icon { font-size: 80px; margin-bottom: 16px; }
.about-img-placeholder p { font-weight: 700; font-size: 18px; color: var(--primary); }
.about-img-placeholder .small { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ===== CONTACT ===== */
.contact-section {
  background: linear-gradient(135deg, #1e3a8a, #1a56db);
  padding: 70px 0;
  color: white;
}
.section-header.light h2 { color: white; }
.section-header.light p { color: rgba(255,255,255,.75); }
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.contact-card {
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.contact-icon { font-size: 32px; margin-bottom: 12px; }
.contact-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.contact-card p { font-size: 14px; opacity: .85; line-height: 1.7; }

/* ===== FOOTER ===== */
.footer { background: #111827; color: #9ca3af; padding: 50px 0 30px; }
.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.footer-brand p { font-size: 13.5px; line-height: 1.7; margin-top: 10px; max-width: 280px; }
.footer-links h4 { color: white; font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.footer-links a { display: block; color: #9ca3af; text-decoration: none; font-size: 13.5px; margin-bottom: 8px; transition: color .2s; }
.footer-links a:hover { color: white; }
.payment-badges { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.pay-badge {
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
}
.pay-badge.mpesa { background: #00a550; color: white; }
.pay-badge.visa { background: #1a1f71; color: white; }
.pay-badge.mc { background: #eb001b; color: white; }
.footer-bottom {
  border-top: 1px solid #374151;
  padding-top: 24px;
  font-size: 13px;
  text-align: center;
  color: #6b7280;
}

/* ===== CART SIDEBAR ===== */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.cart-overlay.open { opacity: 1; pointer-events: all; }
.cart-sidebar {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: white;
  z-index: 201;
  display: flex;
  flex-direction: column;
  transition: right .35s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 20px rgba(0,0,0,.12);
}
.cart-sidebar.open { right: 0; }
.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.cart-header h2 { font-size: 20px; font-weight: 700; }
.close-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .2s;
}
.close-btn:hover { background: #f3f4f6; color: var(--text); }
.cart-items { flex: 1; overflow-y: auto; padding: 20px 24px; }
.empty-cart { text-align: center; padding: 60px 20px; }
.empty-cart div { font-size: 50px; margin-bottom: 14px; }
.empty-cart p { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-cart small { color: var(--muted); }

.cart-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item-icon { font-size: 30px; background: #f0f9ff; border-radius: 8px; padding: 8px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 13.5px; font-weight: 600; line-height: 1.35; margin-bottom: 3px; }
.cart-item-unit { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.cart-item-row { display: flex; align-items: center; gap: 10px; }
.qty-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border-radius: 6px;
  padding: 4px 8px;
}
.qty-ctrl button { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text); width: 20px; text-align: center; }
.qty-ctrl span { font-size: 14px; font-weight: 600; min-width: 20px; text-align: center; }
.cart-item-price { font-size: 14px; font-weight: 700; color: var(--primary); }
.remove-item { background: none; border: none; font-size: 14px; cursor: pointer; color: #ef4444; margin-left: auto; }

.cart-footer { padding: 20px 24px; border-top: 1px solid var(--border); }
.cart-total { display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.vat-note { font-size: 11.5px; color: var(--muted); margin-bottom: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-body { padding: 24px; }

.order-summary { background: #f9fafb; border-radius: 8px; padding: 14px; margin-bottom: 20px; }
.order-summary-item { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.order-summary-item.total { font-weight: 700; font-size: 14px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

.form-section { margin-bottom: 24px; }
.form-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border .2s;
  color: var(--text);
}
.form-group input:focus { border-color: var(--primary); }
.form-group small { font-size: 11.5px; color: var(--muted); }

.payment-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.pay-tab {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .2s;
  color: var(--muted);
}
.pay-tab.active { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.pay-tab-icon { font-size: 18px; }

.payment-form { background: #f9fafb; border-radius: 10px; padding: 18px; }
.payment-form.hidden { display: none; }

.mpesa-logo-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.mpesa-badge-large {
  background: var(--mpesa);
  color: white;
  font-size: 14px;
  font-weight: 900;
  padding: 6px 14px;
  border-radius: 6px;
  letter-spacing: .5px;
}
.mpesa-info { background: #dcfce7; border-radius: 8px; padding: 14px; margin-top: 14px; }
.mpesa-info p { font-size: 13px; margin-bottom: 4px; }
.mpesa-info .note { margin-top: 8px; font-style: italic; color: #166534; }

.card-brands { display: flex; gap: 8px; margin-bottom: 16px; }

.checkout-total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eff6ff;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 20px 0 16px;
  font-weight: 700;
  font-size: 16px;
}
.total-amount { font-size: 22px; color: var(--primary); }

/* ===== SUCCESS MODAL ===== */
.success-modal {
  text-align: center;
  padding: 50px 40px;
}
.success-icon { font-size: 64px; margin-bottom: 16px; }
.success-modal h2 { font-size: 26px; font-weight: 800; margin-bottom: 10px; color: var(--accent); }
.success-modal p { color: var(--muted); margin-bottom: 10px; line-height: 1.7; }
.order-ref {
  background: #f0f9ff;
  border: 1.5px dashed #93c5fd;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin: 16px 0;
}
.success-note { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav { display: none; }
  .nav-toggle { display: block; }
  .header-inner { flex-wrap: wrap; }

  .topbar-inner { flex-direction: column; gap: 4px; font-size: 11px; text-align: center; }

  .hero { padding: 50px 0 40px; }
  .hero h1 { font-size: 28px; }
  .hero-stats { gap: 24px; }

  .about-grid { grid-template-columns: 1fr; gap: 30px; }
  .about-image { order: -1; }

  .footer-inner { grid-template-columns: 1fr 1fr; }

  .cart-sidebar { width: 100vw; }

  .form-row { grid-template-columns: 1fr; }

  .products-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 480px) {
  .footer-inner { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
  .cats-grid { grid-template-columns: repeat(3, 1fr); }
}
