/* ============================================================
   ހިޔާވެހި  –  Main Stylesheet
   RTL · Dhivehi · Mobile-first
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────── */
@font-face {
  font-family: 'MVTyper';
  src: url('/fonts/mvtyper.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'MVTyper';
  src: url('/fonts/mvtypebold.ttf') format('truetype');
  font-weight: 700;
}

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --c-brand:      #1140a9;
  --c-brand-dark: #0c2e7a;
  --c-brand-pale: #e8edf8;
  --c-accent:     #f0a500;
  --c-accent-dk:  #c98a00;
  --c-surface:    #ffffff;
  --c-bg:         #f4f6fb;
  --c-text:       #0f1b3d;
  --c-muted:      #6b7a99;
  --c-border:     #dde3f0;

  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;

  --shadow-sm: 0 2px 8px rgba(17,64,169,.08);
  --shadow-md: 0 6px 24px rgba(17,64,169,.14);
  --shadow-lg: 0 16px 48px rgba(17,64,169,.18);

  --font: 'MVTyper', 'Faruma', 'A_Faruma', Arial, sans-serif;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--c-text);
  background: var(--c-bg);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
a   { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ── Safe-area / notch ─────────────────────────────────────── */
.safe-top    { padding-top:    env(safe-area-inset-top); }
.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* ── Container ─────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header / Nav ──────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-brand);
  color: #fff;
  box-shadow: 0 2px 12px rgba(11,28,73,.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.logo {
  font-weight: 700;
  font-size: 1.4rem;
  color: #fff;
  letter-spacing: .5px;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}
.nav-links a {
  color: rgba(255,255,255,.85);
  font-size: .95rem;
  transition: color var(--transition);
}
.nav-links a:hover { color: #fff; }

/* Cart button in header */
.cart-btn {
  position: relative;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: var(--r-md);
  padding: 7px 16px 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-weight: 700;
  transition: background var(--transition);
  white-space: nowrap;
}
.cart-btn:hover { background: rgba(255,255,255,.25); }
.cart-btn svg   { width: 20px; height: 20px; flex-shrink: 0; }
.cart-badge {
  position: absolute;
  top: -7px;
  left: -7px;
  background: var(--c-accent);
  color: #000;
  font-size: .7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.cart-badge.visible { display: flex; }

/* ── Hero Banner ────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--c-brand) 0%, var(--c-brand-dark) 100%);
  color: #fff;
  padding: 56px 0 48px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('/images/maincover.png') center/cover no-repeat;
  opacity: .18;
}
.hero-content { position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 14px;
}
.hero p {
  font-size: 1.1rem;
  opacity: .85;
  max-width: 540px;
}

/* ── Section Headings ──────────────────────────────────────── */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--c-border);
  border-radius: 1px;
}

/* ── Tag Filter ─────────────────────────────────────────────── */
.tag-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 20px 0 4px;
  direction: rtl;
}
.tag-pill {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.tag-pill:hover,
.tag-pill.active {
  background: var(--c-brand);
  border-color: var(--c-brand);
  color: #fff;
}

/* ── Book Grid ─────────────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 24px;
  padding: 8px 0 40px;
}

.book-card {
  background: var(--c-surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.book-card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--c-brand-pale);
  overflow: hidden;
  position: relative;
}
.book-card-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.book-card:hover .book-card-cover img {
  transform: scale(1.04);
}
.book-card-cover-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-brand);
  opacity: .35;
}

.book-card-body {
  padding: 14px 14px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.book-card-title {
  font-weight: 700;
  font-size: .97rem;
  line-height: 1.4;
  color: var(--c-text);
}
.book-card-author {
  font-size: .82rem;
  color: var(--c-muted);
}
.book-card-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-brand);
  margin-top: auto;
  padding-top: 8px;
}

.book-card-footer {
  padding: 0 14px 14px;
  display: flex;
  gap: 8px;
}
.btn-cart {
  flex: 1;
  background: var(--c-brand);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: .88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition);
}
.btn-cart:hover { background: var(--c-brand-dark); }
.btn-cart svg   { width: 16px; height: 16px; }

.btn-detail {
  background: var(--c-brand-pale);
  color: var(--c-brand);
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.btn-detail:hover { background: var(--c-border); }
.btn-detail svg { width: 17px; height: 17px; }

/* ── Cart Toast (popup) ─────────────────────────────────────── */
.cart-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--c-text);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 16px 20px;
  min-width: 310px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  z-index: 9000;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .35s;
  opacity: 0;
  pointer-events: none;
  direction: rtl;
}
.cart-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: all;
}
.cart-toast-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: .97rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-toast-title svg { color: #4ade80; width: 20px; height: 20px; flex-shrink: 0; }
.cart-toast-actions {
  display: flex;
  gap: 10px;
}
.toast-btn {
  flex: 1;
  padding: 9px;
  border-radius: var(--r-sm);
  border: none;
  font-family: var(--font);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition);
}
.toast-btn:hover { opacity: .85; }
.toast-btn-continue {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.25);
}
.toast-btn-checkout {
  background: var(--c-accent);
  color: #000;
}

/* ── Cart Drawer (side panel) ──────────────────────────────── */
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.cart-overlay.open { opacity: 1; pointer-events: all; }

.cart-drawer {
  position: fixed;
  top: 0; left: 0;
  width: min(400px, 92vw);
  height: 100%;
  background: var(--c-surface);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  direction: rtl;
}
.cart-drawer.open { transform: translateX(0); }

.cart-drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cart-drawer-header h2 { font-size: 1.1rem; font-weight: 700; }

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--c-bg);
  border-radius: var(--r-md);
  padding: 12px;
}
.cart-item-img {
  width: 56px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  background: var(--c-brand-pale);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-title { font-weight: 700; font-size: .9rem; }
.cart-item-price { color: var(--c-brand); font-size: .88rem; margin-top: 4px; }

.cart-item-remove {
  background: none;
  border: none;
  color: var(--c-muted);
  padding: 2px;
  display: flex;
  transition: color var(--transition);
}
.cart-item-remove:hover { color: #e53e3e; }
.cart-item-remove svg { width: 18px; height: 18px; }

.cart-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--c-muted);
  font-size: .95rem;
}

.cart-drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 1rem;
}
.cart-total-label { color: var(--c-muted); }
.cart-total-price { font-weight: 700; font-size: 1.2rem; color: var(--c-text); }

.btn-primary {
  display: block;
  width: 100%;
  background: var(--c-brand);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  transition: background var(--transition);
  cursor: pointer;
}
.btn-primary:hover { background: var(--c-brand-dark); }

/* ── Book Detail Page ──────────────────────────────────────── */
.book-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  padding: 40px 0;
  align-items: start;
}
.book-detail-cover {
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  aspect-ratio: 2/3;
  background: var(--c-brand-pale);
}
.book-detail-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.book-detail-info { display: flex; flex-direction: column; gap: 16px; }
.book-detail-title { font-size: 2rem; font-weight: 700; line-height: 1.3; }
.book-detail-author { color: var(--c-muted); font-size: 1rem; }
.book-detail-price { font-size: 1.6rem; font-weight: 700; color: var(--c-brand); }
.book-detail-desc { line-height: 1.8; color: var(--c-text); }

.book-detail-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn-outline {
  background: var(--c-surface);
  color: var(--c-brand);
  border: 2px solid var(--c-brand);
  border-radius: var(--r-md);
  padding: 11px 20px;
  font-size: .95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  cursor: pointer;
}
.btn-outline:hover { background: var(--c-brand-pale); }

.tags-list { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-badge {
  background: var(--c-brand-pale);
  color: var(--c-brand);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.tag-badge:hover { background: var(--c-brand); color: #fff; }

/* ── Checkout Form ──────────────────────────────────────────── */
.checkout-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 0;
}
.checkout-card {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.checkout-header {
  background: var(--c-brand);
  color: #fff;
  padding: 24px 28px;
}
.checkout-header h1 { font-size: 1.3rem; font-weight: 700; }
.checkout-header p  { opacity: .75; font-size: .9rem; margin-top: 4px; }
.checkout-body { padding: 28px; }

.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: .9rem;
}
.form-label span { color: #e53e3e; margin-right: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: .97rem;
  color: var(--c-text);
  background: var(--c-bg);
  direction: rtl;
  text-align: right;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--c-brand); background: var(--c-surface); }

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

/* Payment method radio cards */
.payment-methods { display: flex; flex-direction: column; gap: 10px; }
.pm-card {
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.pm-card:hover { border-color: var(--c-brand); }
.pm-card.selected { border-color: var(--c-brand); background: var(--c-brand-pale); }
.pm-card input[type=radio] { accent-color: var(--c-brand); width: 18px; height: 18px; }
.pm-card-text { flex: 1; }
.pm-card-label { font-weight: 700; font-size: .95rem; }
.pm-card-desc   { font-size: .82rem; color: var(--c-muted); }
.pm-card-icon   { width: 36px; height: 36px; opacity: .7; }

/* Bank details block */
.bank-details-box {
  background: var(--c-brand-pale);
  border: 1.5px solid var(--c-brand);
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 14px;
  display: none;
}
.bank-details-box.visible { display: block; }
.bank-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: .9rem; }
.bank-row strong { color: var(--c-brand); }

/* Order summary sidebar */
.order-summary {
  background: var(--c-bg);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 24px;
}
.order-summary-title { font-weight: 700; margin-bottom: 12px; }
.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: .9rem;
  gap: 8px;
}
.summary-item:last-child { border-bottom: none; }
.summary-item-title { flex: 1; }
.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  font-weight: 700;
  font-size: 1.1rem;
}

/* File upload zone */
.file-upload-zone {
  border: 2px dashed var(--c-border);
  border-radius: var(--r-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--c-muted);
}
.file-upload-zone:hover,
.file-upload-zone.dragover {
  border-color: var(--c-brand);
  background: var(--c-brand-pale);
  color: var(--c-brand);
}
.file-upload-zone input { display: none; }
.file-upload-zone svg { width: 32px; height: 32px; margin: 0 auto 8px; }

/* ── Success Page ───────────────────────────────────────────── */
.success-page {
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
  padding: 0 20px;
}
.success-icon {
  width: 80px; height: 80px;
  background: #d1fae5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}
.success-icon svg { width: 40px; height: 40px; color: #059669; }
.success-page h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 10px; }
.success-page p  { color: var(--c-muted); margin-bottom: 28px; }
.order-number-badge {
  background: var(--c-brand-pale);
  border: 1.5px solid var(--c-brand);
  color: var(--c-brand);
  border-radius: var(--r-md);
  padding: 10px 24px;
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 28px;
  direction: ltr;
}

/* ── Footer ────────────────────────────────────────────────── */
.site-footer {
  background: var(--c-brand-dark);
  color: rgba(255,255,255,.65);
  padding: 32px 0 calc(32px + env(safe-area-inset-bottom));
  font-size: .88rem;
  text-align: center;
  margin-top: 48px;
}
.site-footer a { color: rgba(255,255,255,.8); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
  border-radius: var(--r-md);
}
.btn-full { width: 100%; }

/* ── Loading spinner ───────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Close button ──────────────────────────────────────────── */
.btn-close {
  background: rgba(0,0,0,.07);
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text);
  transition: background var(--transition);
  flex-shrink: 0;
}
.btn-close:hover { background: rgba(0,0,0,.15); }
.btn-close svg   { width: 18px; height: 18px; }

/* ── Toast notification ─────────────────────────────────────── */
.toast-notif {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--c-text);
  color: #fff;
  border-radius: var(--r-md);
  padding: 10px 20px;
  font-size: .9rem;
  z-index: 9999;
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast-notif.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .book-detail {
    grid-template-columns: 220px 1fr;
    gap: 28px;
  }
}

@media (max-width: 680px) {
  .nav-links { display: none; }

  .hero { padding: 40px 0 32px; }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 16px;
  }
  .book-detail {
    grid-template-columns: 1fr;
  }
  .book-detail-cover {
    max-width: 220px;
    margin: 0 auto;
  }
  .checkout-body { padding: 20px; }
  .checkout-header { padding: 20px; }
}
