/* ============================================================
   ZABAN ASAN — فروشگاه
   Shared by books.php, product.php, account.php and admin-shop.php.
   Every colour, radius and spacing value comes from the tokens in
   style.css, so the shop cannot drift away from the brand.
   ============================================================ */

/* ---------- shared page furniture ---------- */
.shop-hero { padding: var(--space-2xl) 0; text-align: center; }
.shop-hero h1 {
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 900; margin-bottom: var(--space-sm);
}
.shop-hero p { color: var(--text-light); font-size: var(--text-lg); }

.shop-section { padding: var(--space-xl) 0 var(--space-3xl); }

/* Message strip after a redirect: added to cart, order placed, wrong password. */
.shop-note {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: 700;
  margin-bottom: var(--space-lg);
  border: 1px solid transparent;
}
.shop-note--ok    { background: #E9F8EF; color: #1B6B3F; border-color: #BEE6CE; }
.shop-note--error { background: #FDECEC; color: #A32020; border-color: #F5C6C6; }
.shop-note--info  { background: var(--purple-100); color: var(--primary); border-color: #E0CEF5; }

.shop-empty {
  text-align: center; color: var(--text-light);
  padding: var(--space-2xl) 0; font-size: var(--text-lg);
}

/* ============================================================
   PRODUCT GRID (books.php)
   ============================================================ */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.shop-card {
  display: flex; flex-direction: column;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: var(--ease);
}
.shop-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(109,44,142,0.18);
}

/* Fixed aspect box so a tall photo and a wide one still line up in the grid. */
.shop-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--purple-50);
  overflow: hidden;
}
/* `contain`, not `cover`: a book cover cropped to fill the box loses the
   title off its edges. Whitespace around a photo is better than a photo
   with its own name cut off, and it also keeps portrait and landscape
   products looking equally deliberate side by side. */
.shop-card-media img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: var(--space-md);
  transition: transform .5s var(--ease-out, ease);
}
.shop-card:hover .shop-card-media img { transform: scale(1.05); }

/* Stand-in until the real photos are uploaded. */
.shop-card-media.is-empty,
.shop-gallery-main.is-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--purple-400); font-weight: 800; font-size: var(--text-sm);
  background: linear-gradient(135deg, var(--purple-50), var(--purple-100));
}

.shop-card-badge {
  position: absolute; top: 12px; inset-inline-start: 12px;
  background: var(--primary); color: var(--white);
  padding: 4px 12px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 700;
}

.shop-card-body { padding: var(--space-lg); display: flex; flex-direction: column; flex: 1; }
.shop-card-title { font-size: var(--text-lg); font-weight: 800; color: var(--text); line-height: 1.4; }
.shop-card-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; }

/* The teaser. Clamped to three lines so «مشاهده بیشتر» always has a job. */
.shop-card-desc {
  margin: var(--space-md) 0;
  font-size: var(--text-sm); line-height: 1.9; color: var(--text-light);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

.shop-card-foot {
  margin-top: auto; padding-top: var(--space-md);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--border);
}
.shop-price { font-weight: 900; color: var(--primary); font-size: var(--text-lg); }
.shop-price small { display: block; font-size: var(--text-xs); font-weight: 600;
  color: var(--text-muted); text-decoration: line-through; }

/* ============================================================
   PRODUCT PAGE (product.php)
   ============================================================ */
.shop-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2xl);
  align-items: start;
}
@media (max-width: 860px) { .shop-detail { grid-template-columns: 1fr; gap: var(--space-xl); } }

.shop-gallery-main {
  aspect-ratio: 1 / 1;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--purple-50);
  border: 1px solid var(--border);
}
/* Same reasoning as the card: show the whole cover, never a cropped one. */
.shop-gallery-main img { width: 100%; height: 100%; object-fit: contain; padding: var(--space-lg); }

.shop-thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.shop-thumb {
  width: 74px; height: 74px; padding: 0; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--r-sm);
  background: none; overflow: hidden; transition: var(--ease);
}
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-thumb.active, .shop-thumb:hover { border-color: var(--primary); }

.shop-detail h1 { font-size: clamp(var(--text-xl), 3.2vw, var(--text-3xl)); font-weight: 900; line-height: 1.35; }
.shop-detail-sub { color: var(--text-muted); margin-top: 6px; font-size: var(--text-sm); }

.shop-detail-price {
  margin: var(--space-lg) 0;
  font-size: var(--text-2xl); font-weight: 900; color: var(--primary);
}
.shop-detail-price del { font-size: var(--text-md); color: var(--text-muted); font-weight: 600; margin-inline-start: 10px; }

.shop-prose { line-height: 2.1; color: var(--text-light); font-size: var(--text-md); }
.shop-prose p { margin-bottom: var(--space-md); }

.shop-buy {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: var(--space-xl);
}
.shop-qty {
  display: flex; align-items: center;
  border: 2px solid var(--border); border-radius: var(--r-sm); overflow: hidden;
}
.shop-qty button {
  width: 40px; height: 44px; border: 0; background: var(--gray-100);
  font-size: var(--text-lg); font-weight: 800; color: var(--primary); cursor: pointer;
}
.shop-qty button:hover { background: var(--purple-100); }
.shop-qty input {
  width: 54px; height: 44px; border: 0; text-align: center;
  font-family: inherit; font-size: var(--text-md); font-weight: 800;
  -moz-appearance: textfield;
}
.shop-qty input::-webkit-outer-spin-button,
.shop-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.shop-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 30px; border: 0; border-radius: var(--r-sm);
  background: var(--primary); color: var(--white);
  font-family: inherit; font-size: var(--text-md); font-weight: 800;
  cursor: pointer; transition: var(--ease);
}
.shop-btn:hover { background: var(--primary-hover); transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(109,44,142,0.3); }
.shop-btn--ghost { background: none; color: var(--primary); border: 2px solid var(--border); }
.shop-btn--ghost:hover { background: var(--purple-100); border-color: var(--primary); box-shadow: none; }
.shop-btn--danger { background: var(--danger); }
.shop-btn--danger:hover { background: #C42B2B; box-shadow: 0 6px 18px rgba(229,62,62,0.3); }
.shop-btn--sm { padding: 8px 16px; font-size: var(--text-sm); font-weight: 700; }

.shop-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-light); font-size: var(--text-sm); font-weight: 700;
  margin-bottom: var(--space-lg);
}
.shop-back:hover { color: var(--primary); }

/* ============================================================
   FORMS — login, register, checkout, admin
   ============================================================ */
.shop-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-xl);
}
.shop-panel + .shop-panel { margin-top: var(--space-lg); }
.shop-panel h2 { font-size: var(--text-xl); font-weight: 800; margin-bottom: var(--space-lg); }

.shop-form-narrow { max-width: 480px; margin: 0 auto; }

.shop-field { margin-bottom: var(--space-md); }
.shop-field label {
  display: block; margin-bottom: 6px;
  font-size: var(--text-sm); font-weight: 700; color: var(--text);
}
.shop-field input,
.shop-field select,
.shop-field textarea {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: var(--r-sm);
  font-family: inherit; font-size: var(--text-md); color: var(--text);
  background: var(--white); transition: var(--ease);
}
.shop-field input:focus,
.shop-field select:focus,
.shop-field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--purple-100);
}
.shop-field textarea { min-height: 120px; line-height: 1.9; resize: vertical; }
.shop-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 5px; line-height: 1.7; }

/* Latin-only fields (username, password) read wrong under the page's RTL. */
.shop-field input.ltr { direction: ltr; text-align: left; }

.shop-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
@media (max-width: 620px) { .shop-form-row { grid-template-columns: 1fr; gap: 0; } }

/* ---------- tabs (login ⇄ register, and the account panel) ---------- */
.shop-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: var(--space-lg);
}
.shop-tab {
  padding: 9px 20px; border: 2px solid var(--border); border-radius: var(--r-full);
  background: none; font-family: inherit; font-size: var(--text-sm); font-weight: 700;
  color: var(--text-light); cursor: pointer; transition: var(--ease);
}
.shop-tab.active, .shop-tab:hover {
  border-color: var(--primary); background: var(--purple-100); color: var(--primary);
}
.shop-tabpane { display: none; }
.shop-tabpane.active { display: block; }

/* ---------- account header ---------- */
.shop-userbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-md);
  padding: var(--space-lg) var(--space-xl);
  background: linear-gradient(145deg, var(--purple-700), var(--purple-800));
  color: var(--white); border-radius: var(--r-lg);
  margin-bottom: var(--space-lg);
}
.shop-userbar h2 { color: var(--white); margin: 0; font-size: var(--text-lg); }
.shop-userbar p { color: rgba(255,255,255,0.75); font-size: var(--text-sm); margin-top: 4px; }
.shop-userbar .shop-btn { background: var(--white); color: var(--primary); }
.shop-userbar .shop-btn:hover { background: var(--purple-100); }

/* ---------- tables (cart, orders, admin lists) ---------- */
.shop-table-wrap { overflow-x: auto; }
.shop-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.shop-table th, .shop-table td {
  padding: 14px 12px; text-align: right;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.shop-table th { font-weight: 800; color: var(--text); background: var(--gray-100); white-space: nowrap; }
.shop-table tfoot td { font-weight: 900; color: var(--primary); font-size: var(--text-md); }
.shop-table .num { white-space: nowrap; }

.shop-qty-mini { display: inline-flex; align-items: center; gap: 6px; }
.shop-qty-mini button {
  width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--gray-100); font-size: var(--text-md); font-weight: 800;
  color: var(--primary); cursor: pointer; line-height: 1;
}
.shop-qty-mini button:hover { background: var(--purple-100); border-color: var(--primary); }
.shop-qty-mini span { min-width: 26px; text-align: center; font-weight: 800; }

/* ---------- order status ---------- */
.shop-status {
  display: inline-block; padding: 5px 14px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 800; white-space: nowrap;
}
.shop-status--new       { background: var(--purple-100); color: var(--primary); }
.shop-status--contacted { background: #FFF4E0; color: #A96A00; }
.shop-status--preparing { background: #E7F0FF; color: #1F4FA8; }
.shop-status--sent      { background: #E5F6FB; color: #17667C; }
.shop-status--done      { background: #E9F8EF; color: #1B6B3F; }
.shop-status--cancelled { background: #FDECEC; color: #A32020; }

.shop-order-card {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--space-lg); margin-bottom: var(--space-md);
  background: var(--white);
}
.shop-order-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: var(--space-md);
}
.shop-order-code { font-weight: 900; color: var(--text); }
.shop-order-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 3px; }
.shop-order-lines { list-style: none; font-size: var(--text-sm); color: var(--text-light); }
.shop-order-lines li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.shop-order-lines li:last-child { border-bottom: 0; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-shell { padding: var(--space-xl) 0 var(--space-3xl); }
.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-md); margin-bottom: var(--space-lg);
}
.admin-bar h1 { font-size: var(--text-2xl); font-weight: 900; }

.admin-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.admin-thumb { position: relative; width: 84px; }
.admin-thumb img {
  width: 84px; height: 84px; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--border); display: block;
}
.admin-thumb button {
  position: absolute; top: -6px; inset-inline-end: -6px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--danger); color: var(--white);
  font-size: 13px; line-height: 1; cursor: pointer;
}

.admin-mini-img {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--border);
}

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
