/* ════════════════════════════════════════════════════════════════
   store.css — public storefront theme.
   Deliberately distinct from the admin app: warm paper/parchment
   palette, serif headings, generous spacing. Mobile-first, RTL-aware.
   ════════════════════════════════════════════════════════════════ */

:root {
  /* palette */
  --paper:        #faf6ef;
  --paper-card:   #ffffff;
  --ink:          #2a201a;
  --ink-soft:     #5c4f44;
  --ink-muted:    #9a8b7c;
  --accent:       #9c4a1a;        /* burnt sienna */
  --accent-soft:  #f3e3d6;
  --accent-dark:  #7a3712;
  --gold:         #b8860b;
  --success:      #2e7d4f;
  --success-soft: #e3f3e9;
  --danger:       #b00020;
  --border:       #e6dccd;
  --shadow:       0 1px 3px rgba(60, 40, 20, .08), 0 4px 16px rgba(60, 40, 20, .04);
  --shadow-lg:    0 8px 32px rgba(60, 40, 20, .14);
  --radius:       10px;
  --radius-sm:    6px;
  --maxw:         1200px;
  --serif:        Georgia, 'Amiri', 'Times New Roman', serif;
  --sans:         -apple-system, 'Segoe UI', 'Tahoma', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a   { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell ──────────────────────────────────────────────────────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ─────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--paper-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; flex-direction: row; align-items: center; gap: .625rem; cursor: pointer; }
.brand-text { display: flex; flex-direction: column; }
.brand-logo-img { flex-shrink: 0; border-radius: 50%; object-fit: contain; }
.brand-logo { font-size: 1.1rem; font-weight: 700; color: var(--accent); font-family: var(--serif); line-height: 1.3; }
.brand-tag { font-size: .72rem; color: var(--ink-muted); }

/* ── Hero logo ──────────────────────────────────────────────────── */
.hero-logo { display: flex; justify-content: center; margin-bottom: .75rem; }
.hero-logo img { border-radius: 50%; box-shadow: 0 4px 16px rgba(0,0,0,.12); }

.header-spacer { flex: 1; }

.header-actions { display: flex; align-items: center; gap: .75rem; }
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); position: relative;
}
.icon-btn:hover { background: var(--accent-soft); }
.cart-badge {
  position: absolute; top: -6px; inset-inline-end: -6px;
  background: var(--accent); color: #fff; font-size: .7rem;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── Nav links (desktop) ────────────────────────────────────────── */
.main-nav { display: none; gap: .25rem; }
.main-nav a {
  padding: .5rem .85rem; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 500;
}
.main-nav a:hover, .main-nav a.active { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }
@media (min-width: 768px) { .main-nav { display: flex; } }

/* ── Views ──────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }
.view-inner { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ── Hero ───────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 1.25rem;
  text-align: center;
}
.hero h1 { font-family: var(--serif); font-size: 2rem; color: var(--accent-dark); margin-bottom: .35rem; }
.hero p { color: var(--ink-soft); max-width: 600px; margin: 0 auto; }
@media (min-width: 768px) { .hero h1 { font-size: 2.5rem; } .hero { padding: 3.5rem 1.25rem; } }

/* ── Toolbar (search + filters) ─────────────────────────────────── */
.toolbar {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
  margin-bottom: 1.5rem;
}
.toolbar .search {
  flex: 1; min-width: 220px; position: relative;
}
.toolbar .search input {
  width: 100%; padding: .7rem 1rem .7rem 2.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; background: var(--paper-card);
}
.toolbar .search::before {
  content: '🔍'; position: absolute; inset-inline-start: .85rem; top: 50%;
  transform: translateY(-50%); opacity: .6;
}
.toolbar select {
  padding: .7rem .85rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--paper-card); font-size: .9rem; color: var(--ink-soft);
  cursor: pointer;
}

/* ── Promo banner ───────────────────────────────────────────────── */
.promo-wrap { margin-bottom: 1.5rem; }
.promo-banner {
  display: flex; align-items: center; gap: .85rem;
  background: linear-gradient(90deg, var(--success-soft), var(--paper-card));
  border: 1px solid var(--success); border-inline-start: 4px solid var(--success);
  border-radius: var(--radius); padding: .85rem 1.1rem;
  cursor: pointer; transition: box-shadow .15s, transform .1s;
  user-select: none;
}
.promo-banner:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-1px); }
.promo-banner:active { transform: translateY(0); }
.promo-banner:focus-visible { outline: 2px solid var(--success); outline-offset: 2px; }
.promo-icon { font-size: 1.5rem; }
.promo-text { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.promo-text strong { color: var(--success); }
.promo-text span { font-size: .85rem; color: var(--ink-soft); }
.promo-until { font-size: .75rem !important; color: var(--ink-muted) !important; }
.promo-arrow { font-size: 1.25rem; color: var(--success); opacity: .7; flex-shrink: 0; }

/* Bundle promotion banner variant */
.promo-banner--bundle {
  border-inline-start-color: var(--accent);
  background: linear-gradient(90deg, rgba(37,99,235,.06), var(--paper-card));
}
.promo-discount-label {
  font-size: .8rem;
  color: var(--success);
  font-weight: 600;
  margin-top: .15rem;
  display: block;
}
.promo-bundle-btn {
  flex-shrink: 0;
  align-self: center;
  white-space: nowrap;
}

/* Bundle group in cart */
.bundle-group {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.bundle-group-header {
  background: rgba(37,99,235,.07);
  padding: .5rem .875rem;
  font-weight: 600;
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.bundle-group .cart-item {
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.bundle-group .cart-item:last-child { border-bottom: none; }

/* ── Contact form card ──────────────────────────────────────────── */
.contact-form-card {
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.contact-form-card .form-group { margin-bottom: 1rem; }
.contact-form-card label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .875rem; }
.contact-form-card input,
.contact-form-card textarea {
  width: 100%; padding: .625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: .9rem;
  background: var(--bg-main); color: var(--ink);
  transition: border-color .15s;
}
.contact-form-card input:focus,
.contact-form-card textarea:focus {
  outline: none; border-color: var(--accent);
}
.contact-form-card textarea { resize: vertical; min-height: 110px; }

/* ── Book grid ──────────────────────────────────────────────────── */
.book-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 480px)  { .book-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .book-grid { grid-template-columns: repeat(3, 1fr); } }

/* Short description inside book card */
.book-short-desc {
  font-size: .8rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: .3rem 0 .5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card {
  background: var(--paper-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.book-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.book-cover-wrap {
  position: relative; aspect-ratio: 2/3; background: var(--accent-soft);
  cursor: pointer; overflow: hidden;
}
.book-cover { width: 100%; height: 100%; object-fit: cover; }
.book-cover--placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; opacity: .4;
}

.book-info { padding: .75rem .85rem 1rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.book-title {
  font-family: var(--serif); font-size: 1rem; font-weight: 600; color: var(--ink);
  line-height: 1.35; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-title:hover { color: var(--accent); }
.book-author, .book-publisher { font-size: .8rem; color: var(--ink-muted); }
.book-publisher { font-style: italic; }

.book-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-top: auto; padding-top: .5rem;
}

.badge {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 99px;
}
.badge-offer { background: var(--danger); color: #fff; position: absolute; top: .5rem; inset-inline-start: .5rem; }
.badge-stock     { background: var(--success-soft); color: var(--success); align-self: flex-start; margin-top: .4rem; }
.badge-out       { background: #fde8e8; color: var(--danger); align-self: flex-start; margin-top: .4rem; }
.badge-near-empty {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a;
  position: absolute; bottom: .5rem; left: .5rem;
  font-size: .7rem; padding: .15rem .45rem;
  animation: pulse-warning 2s ease-in-out infinite;
}
@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

/* ── Price ──────────────────────────────────────────────────────── */
.price { font-size: 1.05rem; font-weight: 700; color: var(--accent-dark); font-family: var(--serif); }
.price-discounted { display: flex; flex-direction: column; gap: 0; line-height: 1.1; }
.price-old { font-size: .75rem; color: var(--ink-muted); text-decoration: line-through; font-weight: 400; }
.price-new { font-size: 1.05rem; font-weight: 700; color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  border: none; border-radius: var(--radius-sm); padding: .6rem 1rem;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .15s, opacity .15s; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: .4rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #246540; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }

/* ── Empty / loading ────────────────────────────────────────────── */
.empty-state, .loading {
  text-align: center; padding: 3rem 1rem; color: var(--ink-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: .5rem; opacity: .5; }
.loading { color: var(--ink-soft); }

/* ── Book detail ────────────────────────────────────────────────── */
.detail-grid {
  display: grid; gap: 1.5rem; margin-bottom: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .detail-grid { grid-template-columns: 280px 1fr; } }
.detail-cover { aspect-ratio: 2/3; background: var(--accent-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.detail-cover .book-cover { width: 100%; height: 100%; object-fit: cover; }
.detail-cover .book-cover--placeholder { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 5rem; opacity: .4; }
.detail-title { font-family: var(--serif); font-size: 1.75rem; color: var(--ink); margin-bottom: .35rem; }
.detail-author { color: var(--ink-soft); font-size: 1.05rem; margin-bottom: .75rem; }
.detail-price { margin-bottom: 1rem; }
.detail-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.detail-section { margin-top: 1.5rem; }
.detail-section h4 { font-family: var(--serif); color: var(--accent-dark); margin-bottom: .5rem; border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.detail-section p { color: var(--ink-soft); }
.detail-short-desc p {
  font-size: 1rem;
  font-style: italic;
  color: var(--ink);
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: .75rem;
  line-height: 1.7;
  margin-top: .5rem;
}
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; }
.detail-list dt { color: var(--ink-muted); font-size: .85rem; }
.detail-list dd { color: var(--ink); }
.chip { display: inline-block; background: var(--accent-soft); color: var(--accent-dark); padding: .1rem .6rem; border-radius: 99px; font-size: .8rem; margin-inline-end: .35rem; }

/* ── Cart ───────────────────────────────────────────────────────── */
.cart-layout { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .cart-layout { grid-template-columns: 1fr 320px; } }
.cart-item {
  display: grid; grid-template-columns: 64px 1fr auto auto;
  gap: .85rem; align-items: center;
  background: var(--paper-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem; margin-bottom: .75rem;
}
.cart-item-cover { width: 64px; height: 80px; background: var(--accent-soft); border-radius: var(--radius-sm); overflow: hidden; }
.cart-item-cover img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-cover .cover-ph { display: flex; align-items: center; justify-content: center; height: 100%; opacity: .4; }
.cart-item-info h4 { font-family: var(--serif); font-size: .95rem; margin-bottom: .2rem; }
.cart-item-price { color: var(--accent-dark); font-weight: 600; }
.cart-item-qty { display: flex; align-items: center; gap: .5rem; }
.cart-item-qty button { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--paper); border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem; line-height: 1; }
.cart-item-qty button:hover { background: var(--accent-soft); }

.cart-summary {
  background: var(--paper-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  position: sticky; top: 80px; height: fit-content;
}
.cart-summary h3 { font-family: var(--serif); margin-bottom: 1rem; color: var(--accent-dark); }
.summary-row { display: flex; justify-content: space-between; padding: .35rem 0; }
.summary-total { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .75rem; font-size: 1.15rem; }
.summary-total strong { color: var(--accent-dark); font-family: var(--serif); }
.summary-note { font-size: .8rem; color: var(--ink-muted); margin: .5rem 0 1rem; }

/* ── Checkout form ──────────────────────────────────────────────── */
.checkout-form, .contact-card {
  background: var(--paper-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  max-width: 640px;
}
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .3rem; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .95rem; font-family: inherit;
  background: var(--paper);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 560px) { .form-row { grid-template-columns: 1fr 1fr; } }
.checkout-total {
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: .85rem 1rem; margin: 1.25rem 0;
}

/* ── Order done ─────────────────────────────────────────────────── */
.order-done { text-align: center; padding: 3rem 1rem; }
.order-done-icon { font-size: 4rem; margin-bottom: 1rem; }
.order-done h2 { font-family: var(--serif); color: var(--success); margin-bottom: .75rem; }
.order-done-num { font-size: 1.2rem; margin-bottom: .5rem; }
.order-done-eta { color: var(--ink-soft); max-width: 500px; margin: 0 auto 1.5rem; }

/* ── Contact ────────────────────────────────────────────────────── */
.contact-card h2 { font-family: var(--serif); color: var(--accent-dark); margin-bottom: .35rem; }
.contact-card .muted { color: var(--ink-muted); margin-bottom: 1.25rem; }
.contact-row { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.contact-row:last-child { border-bottom: none; }
.contact-row span { color: var(--ink-muted); }

/* ── Footer ─────────────────────────────────────────────────────── */
.site-footer {
  background: var(--paper-card); border-top: 1px solid var(--border);
  padding: 2rem 1.25rem; margin-top: auto;
}
.footer-inner { max-width: var(--maxw); margin: 0 auto; text-align: center; color: var(--ink-muted); font-size: .85rem; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(40, 28, 18, .55);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--paper-card); border-radius: var(--radius);
  max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--paper-card);
}
.modal-header h3 { font-family: var(--serif); color: var(--accent-dark); }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--ink-muted); line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 1.25rem; }

/* ── Toast ──────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.25rem; inset-inline-start: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: .5rem; align-items: center;
}
[dir="rtl"] #toast-container { transform: translateX(50%); }
.toast {
  background: var(--ink); color: #fff; padding: .75rem 1.25rem;
  border-radius: var(--radius); font-size: .9rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: #b8860b; }
.toast-info    { background: var(--ink-soft); }

/* ── RTL adjustments ────────────────────────────────────────────── */
[dir="rtl"] .toolbar .search input { padding: .7rem 2.5rem .7rem 1rem; }
[dir="rtl"] .toolbar .search::before { inset-inline-start: auto; inset-inline-end: .85rem; }
