/* Digital Shop — single stylesheet. Clean, modern, mobile-first. */
:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 64px; /* sticky bottom menu */
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 16px; padding: 12px 16px; flex-wrap: wrap; }
.brand { font-size: 1.25rem; font-weight: 700; color: var(--brand); }
.brand:hover { text-decoration: none; }
.search-box { flex: 1; display: flex; gap: 0; position: relative; min-width: 200px; }
.search-box input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius) 0 0 var(--radius);
  font-size: .95rem;
}
.search-box button {
  padding: 9px 18px; background: var(--brand); color: #fff; border: none;
  border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-weight: 600;
}
.search-box button:hover { background: var(--brand-dark); }
.search-suggest {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); z-index: 30; max-height: 360px; overflow: auto;
}
.search-suggest a { display: flex; justify-content: space-between; padding: 9px 12px; color: var(--text); }
.search-suggest a:hover { background: var(--bg); text-decoration: none; }
.search-suggest .price { color: var(--muted); }

.top-nav { display: flex; gap: 12px; align-items: center; }
.nav-link { color: var(--text); font-weight: 500; }
.logout-btn {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--text); font-weight: 500; display: inline;
}
.logout-btn:hover { color: var(--brand); text-decoration: underline; }

/* Add-to-basket flash feedback */
.btn-success-flash { background: var(--success) !important; }
.btn-warn { background: var(--danger) !important; animation: shake .4s; }

/* Captcha question box */
.captcha-box {
  display: inline-block; padding: 6px 14px; margin-bottom: 6px;
  background: linear-gradient(135deg,#e0e7ff,#f8fafc);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-weight: 700; font-size: 1.1rem; letter-spacing: 1px; user-select: none;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.nav-cta { background: var(--brand); color: #fff; padding: 6px 14px; border-radius: var(--radius); }
.nav-cta:hover { background: var(--brand-dark); text-decoration: none; }
.badge {
  background: var(--brand); color: #fff; font-size: .75rem; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; min-width: 20px; display: inline-block; text-align: center;
}

/* Layout */
.main-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 24px 16px; }
.sidebar { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; height: fit-content; position: sticky; top: 76px; }
.sidebar h3 { font-size: .8rem; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.sidebar h3:first-child { margin-top: 0; }
.cat-menu { list-style: none; }
.cat-menu li a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.cat-menu li a:hover { background: var(--bg); text-decoration: none; }
.content { min-width: 0; }

@media (max-width: 820px) {
  .main-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

/* Cards / grids */
.section-title { font-size: 1.3rem; margin: 8px 0 16px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.product-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s;
}
.product-card:hover { transform: translateY(-2px); }
.product-card .thumb { aspect-ratio: 4/3; background: linear-gradient(135deg,#e0e7ff,#f8fafc); display: flex; align-items: center; justify-content: center; font-size: 2.4rem; }
.product-card .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card .title { font-weight: 600; color: var(--text); }
.product-card .title:hover { color: var(--brand); text-decoration: none; }
.product-card .meta { color: var(--muted); font-size: .82rem; margin-top: auto; }
.product-card .price { font-weight: 700; color: var(--brand-dark); font-size: 1.05rem; }
.product-card .price small { color: var(--muted); text-decoration: line-through; font-weight: 400; margin-left: 6px; font-size: .8rem; }

/* Skeleton loaders */
.skeleton { background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton-card { height: 260px; border-radius: var(--radius); }

/* Product detail */
.product-detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; }
@media (max-width: 820px) { .product-detail { grid-template-columns: 1fr; } }
.gallery .main-img { aspect-ratio: 4/3; background: linear-gradient(135deg,#e0e7ff,#f8fafc); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 4rem; }
.gallery .thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.gallery .thumbs img, .gallery .thumbs .thumb-item { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; background: #e0e7ff; }
.gallery .thumbs .thumb-item.active { border-color: var(--brand); }
.detail-info h1 { margin-bottom: 8px; }
.detail-info .stars { color: #f59e0b; }
.detail-info .price-big { font-size: 1.8rem; font-weight: 800; color: var(--brand-dark); margin: 12px 0; }
.detail-info .file-meta { color: var(--muted); margin-bottom: 16px; }
.btn { display: inline-block; padding: 10px 20px; border-radius: var(--radius); border: none; cursor: pointer; font-weight: 600; font-size: .95rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Comments */
.comment { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; background: var(--card); margin-bottom: 10px; }
.comment .author { font-weight: 600; }
.comment .time { color: var(--muted); font-size: .8rem; }
.review-form textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); font-family: inherit; }
.rating-stars { font-size: 1.4rem; cursor: pointer; }
.rating-stars span { color: #cbd5e1; }
.rating-stars span.active { color: #f59e0b; }

/* Forms (auth, contact, dashboard) */
.form-card { max-width: 460px; margin: 24px auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 4px; font-weight: 500; font-size: .9rem; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem;
}
.form-row .help { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.errorlist { color: var(--danger); font-size: .85rem; margin-top: 4px; list-style: none; }

/* Basket */
.basket-item { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: 8px; }
.basket-item .qty { width: 70px; }
.basket-total { text-align: right; font-size: 1.2rem; font-weight: 700; margin: 16px 0; }

/* Sticky bottom menu */
.sticky-bottom-menu {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--card);
  border-top: 1px solid var(--border); display: none; justify-content: space-around; padding: 8px 0; z-index: 40;
}
.sticky-bottom-menu a { color: var(--muted); font-size: .8rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
@media (max-width: 820px) { .sticky-bottom-menu { display: flex; } }

/* Footer */
.site-footer { background: var(--card); border-top: 1px solid var(--border); padding: 20px 0; margin-top: 32px; color: var(--muted); font-size: .88rem; text-align: center; }

/* Tables (dashboard) */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
table.data th { background: var(--bg); font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .75rem; }
table.data tr:last-child td { border-bottom: none; }
.status-badge { padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-approved, .status-paid, .status-verified { background: #dcfce7; color: #166534; }
.status-rejected, .status-failed, .status-cancelled { background: #fee2e2; color: #991b1b; }

.messages { list-style: none; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; }
.msg-success { background: #dcfce7; color: #166534; }
.msg-error, .msg-danger { background: #fee2e2; color: #991b1b; }
.msg-info { background: #dbeafe; color: #1e40af; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; list-style: none; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.muted { color: var(--muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }

/* Language switcher */
.lang-switcher { display: inline-flex; }
.lang-switcher select {
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .82rem; background: var(--card); cursor: pointer; color: var(--text);
}

/* RTL (Persian) overrides — everything that has an explicit left/right flips. */
body.rtl { direction: rtl; text-align: right; }
body.rtl .search-box input { border-radius: 0 var(--radius) var(--radius) 0; }
body.rtl .search-box button { border-radius: var(--radius) 0 0 var(--radius); }
body.rtl .search-suggest { left: auto; right: 0; }
body.rtl .cat-menu li a, body.rtl .form-row label { text-align: right; }
body.rtl table.data th, body.rtl table.data td { text-align: right; }
body.rtl .basket-item { grid-template-columns: 1fr auto auto auto; }
body.rtl .flex-between { flex-direction: row-reverse; }
