/* =====================================================================
   تجارة كوم — نظام التصميم الموحد (الإصدار 2.0.0)
   خط واحد للموقع كله: المراعي (Almarai) مستضاف محليًا بصيغة woff2
   ===================================================================== */

@font-face { font-family: "Almarai"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/Almarai-Regular.woff2") format("woff2"), url("../fonts/Almarai-Regular.ttf") format("truetype"); }
@font-face { font-family: "Almarai"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/Almarai-Bold.woff2") format("woff2"), url("../fonts/Almarai-Bold.ttf") format("truetype"); }
@font-face { font-family: "Almarai"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/Almarai-ExtraBold.woff2") format("woff2"), url("../fonts/Almarai-ExtraBold.ttf") format("truetype"); }

:root {
  --tg-font: "Almarai", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --tg-primary: #5b3cc4;
  --tg-primary-600: #4a2fa8;
  --tg-primary-050: #f1edff;
  --tg-accent: #d6336c;
  --tg-success: #0f9d6a;
  --tg-success-050: #e7f8f1;
  --tg-warning: #b7791f;
  --tg-ink: #1b2233;
  --tg-ink-2: #3c4558;
  --tg-muted: #6b7385;
  --tg-line: #e6e8f0;
  --tg-bg: #f6f7fb;
  --tg-surface: #ffffff;
  --tg-radius: 14px;
  --tg-radius-sm: 10px;
  --tg-shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 6px 18px rgba(20, 24, 40, .06);
  --tg-shadow-lg: 0 10px 30px rgba(20, 24, 40, .12);
  --tg-max: 1240px;
}

/* ---- توحيد الخط في كل الصفحات القديمة والجديدة (يتجاوز الأنماط المضمنة) ---- */
html, body, h1, h2, h3, h4, h5, h6, p, a, span, div, td, th, li, label, small, strong, b, em,
input, button, select, textarea, option, .btn, .btnn, .form-control, .navbar, .dropdown-menu {
  font-family: var(--tg-font) !important;
}
/* عدم المساس بخطوط الأيقونات */
[class^="fa"], [class*=" fa-"], [class^="bi-"], [class*=" bi-"], .glyphicon, [class^="icon-"], [class*=" icon-"] {
  font-family: inherit;
}

body.tg {
  margin: 0;
  background: var(--tg-bg);
  color: var(--tg-ink);
  font-size: 16px;
  line-height: 1.7;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip; /* عناصر زخرفية قديمة لا تسبب تمريرًا أفقيًا على الجوال */
}
html:has(body.tg) { overflow-x: clip; }
:where(body.tg) img { max-width: 100%; height: auto; }
.tg a { color: inherit; }
.tg-container { width: 100%; max-width: var(--tg-max); margin-inline: auto; padding-inline: 16px; box-sizing: border-box; }
.tg-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------- الرأس ---------------------------- */
.tg-header {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--tg-line);
  direction: rtl; text-align: right;
}
.tg-header__row { display: flex; align-items: center; gap: 16px; min-height: 68px; }
.tg-logo { display: flex; align-items: center; flex-shrink: 0; }
.tg-header .tg-logo img { height: 42px; width: auto; max-width: none; display: block; }
.tg-search { flex: 1; display: flex; max-width: 560px; margin-inline: auto; }
.tg-search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 16px;
  border: 1px solid var(--tg-line); border-left: 0; border-radius: 0 999px 999px 0;
  background: var(--tg-bg); font-size: 15px; color: var(--tg-ink); outline: none;
}
.tg-search input:focus { border-color: var(--tg-primary); background: #fff; }
.tg-search button {
  height: 44px; padding: 0 18px; border: 0; border-radius: 999px 0 0 999px;
  background: var(--tg-primary); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.tg-search button:hover { background: var(--tg-primary-600); }
.tg-nav { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tg-nav a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  text-decoration: none; color: var(--tg-ink-2); font-size: 14px; font-weight: 700; white-space: nowrap;
}
.tg-nav a:hover { background: var(--tg-primary-050); color: var(--tg-primary); }
.tg-nav a.tg-nav__cta { background: var(--tg-primary); color: #fff; }
.tg-nav a.tg-nav__cta:hover { background: var(--tg-primary-600); color: #fff; }
.tg-menu-toggle { display: none; background: none; border: 1px solid var(--tg-line); border-radius: 10px; width: 44px; height: 44px; cursor: pointer; font-size: 20px; }

@media (max-width: 900px) {
  .tg-header__row { flex-wrap: wrap; gap: 10px; padding-block: 10px; }
  .tg-search { order: 3; flex-basis: 100%; max-width: none; }
  .tg-menu-toggle { display: inline-block; margin-inline-start: auto; }
  .tg-nav { display: none; order: 4; flex-basis: 100%; flex-wrap: wrap; padding-bottom: 6px; }
  .tg-header.is-open .tg-nav { display: flex; }
}

/* ---------------------------- عناصر عامة ---------------------------- */
.tg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  background: var(--tg-primary); color: #fff !important; text-decoration: none !important;
  font-size: 15px; font-weight: 700; cursor: pointer; transition: background .15s, transform .15s;
}
.tg-btn:hover { background: var(--tg-primary-600); }
.tg-btn:active { transform: translateY(1px); }
.tg-btn--lg { min-height: 54px; font-size: 17px; padding: 0 28px; }
.tg-btn--block { display: flex; width: 100%; box-sizing: border-box; }
.tg-btn--ghost { background: transparent; color: var(--tg-primary) !important; border-color: var(--tg-line); }
.tg-btn--ghost:hover { background: var(--tg-primary-050); }
.tg-btn--success { background: var(--tg-success); }
.tg-btn--success:hover { background: #0b7d54; }

.tg-card { background: var(--tg-surface); border: 1px solid var(--tg-line); border-radius: var(--tg-radius); box-shadow: var(--tg-shadow); }
.tg-section { margin-block: 28px; }
.tg-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tg-section__title { margin: 0; font-size: 22px; font-weight: 800; color: var(--tg-ink); }
.tg-muted { color: var(--tg-muted); }
.tg-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--tg-primary-050); color: var(--tg-primary); }
.tg-badge--free { background: var(--tg-success-050); color: var(--tg-success); }
.tg-empty { text-align: center; padding: 64px 16px; color: var(--tg-muted); }
.tg-empty h1, .tg-empty h2 { color: var(--tg-ink); font-size: 22px; }

/* ---------------------------- الواجهة الرئيسية ---------------------------- */
.tg-hero {
  background: transparent;
  color: var(--tg-ink); padding: 18px 0 8px; margin-bottom: 8px;
}
.tg-hero h1 { margin: 0 0 8px; font-size: clamp(22px, 3.4vw, 34px); font-weight: 800; line-height: 1.4; color: var(--tg-primary); }
.tg-hero__brand { color: #53565f; }
.tg-hero__brand-accent { color: #ff4e00; }
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .tg-hero__tagline {
    background-image: linear-gradient(135deg, #2b1b6e 0%, #5b3cc4 55%, #d6336c 130%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}
.tg-hero p { margin: 0; font-size: 16px; color: var(--tg-ink-2); }
.tg-hero__stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; font-size: 14px; }
.tg-hero__stats b { font-size: 20px; display: block; color: var(--tg-primary); }

.tg-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tg-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; flex: 1; min-width: 0; }
.tg-chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--tg-line);
  background: #fff; color: var(--tg-ink-2); text-decoration: none; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.tg-chip:hover { border-color: var(--tg-primary); color: var(--tg-primary); }
.tg-chip.is-active { background: var(--tg-primary); border-color: var(--tg-primary); color: #fff; }
.tg-select { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--tg-line); background: #fff; font-size: 14px; color: var(--tg-ink); }

/* ---------------------------- بطاقات المنتجات ---------------------------- */
.tg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.tg-product-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--tg-line); border-radius: var(--tg-radius);
  box-shadow: var(--tg-shadow); transition: transform .18s ease, box-shadow .18s ease; text-align: right;
}
.tg-product-card:hover { transform: translateY(-4px); box-shadow: var(--tg-shadow-lg); }
.tg-product-card__media { display: block; aspect-ratio: 16 / 10; background: linear-gradient(135deg, #eef0f7, #f8f9fc); overflow: hidden; }
.tg-product-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.tg-product-card:hover .tg-product-card__media img { transform: scale(1.04); }
.tg-product-card__body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.tg-product-card__title { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.55; color: var(--tg-ink); }
.tg-product-card__title a { text-decoration: none; color: inherit; }
.tg-product-card__title a::after { content: ""; position: absolute; inset: 0; } /* البطاقة كلها قابلة للنقر */
.tg-product-card__desc { margin: 0; font-size: 13px; color: var(--tg-muted); line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tg-product-card__seller { position: relative; z-index: 1; font-size: 12px; color: var(--tg-primary); text-decoration: none; font-weight: 700; align-self: flex-start; }
.tg-product-card__seller:hover { text-decoration: underline; }
.tg-product-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--tg-line); }
.tg-price { font-size: 19px; font-weight: 800; color: var(--tg-ink); }
.tg-price--free { color: var(--tg-success); }
.tg-meta { display: inline-flex; gap: 10px; font-size: 12px; color: var(--tg-muted); }
.tg-product-card__flag { position: absolute; top: 12px; right: 12px; z-index: 1; }

/* ---------------------------- ترقيم الصفحات ---------------------------- */
.tg-pagination { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 32px 0 8px; }
.tg-pagination a, .tg-pagination span {
  min-width: 40px; height: 40px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--tg-line); background: #fff; color: var(--tg-ink-2); text-decoration: none; font-weight: 700; box-sizing: border-box;
}
.tg-pagination a:hover { border-color: var(--tg-primary); color: var(--tg-primary); }
.tg-pagination .is-current { background: var(--tg-primary); border-color: var(--tg-primary); color: #fff; }

/* ---------------------------- صفحة المنتج ---------------------------- */
.tg-breadcrumb { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--tg-muted); margin: 18px 0 14px; }
.tg-breadcrumb a { color: var(--tg-muted); text-decoration: none; }
.tg-breadcrumb a:hover { color: var(--tg-primary); }
.tg-product { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.tg-product > * { min-width: 0; } /* يمنع المعرض من توسيع العمود على الجوال */
.tg-buybox { padding: 22px; position: sticky; top: 88px; }
.tg-buybox h1 { margin: 0 0 6px; font-size: 24px; font-weight: 800; line-height: 1.5; color: var(--tg-ink); }
.tg-buybox__price { font-size: 32px; font-weight: 800; margin: 14px 0 4px; color: var(--tg-ink); }
.tg-buybox__price del { font-size: 18px; color: var(--tg-muted); font-weight: 400; margin-inline-start: 8px; }
.tg-buybox__list { list-style: none; margin: 16px 0 0; padding: 14px 0 0; border-top: 1px solid var(--tg-line); display: grid; gap: 8px; font-size: 14px; color: var(--tg-ink-2); }
.tg-buybox__list li { display: flex; justify-content: space-between; gap: 10px; }
.tg-seller { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 10px; border-radius: 12px; background: var(--tg-bg); margin-top: 12px; }
.tg-seller:hover { background: var(--tg-primary-050); }
.tg-avatar { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--tg-primary), var(--tg-accent)); flex-shrink: 0; }
.tg-avatar--xl { width: 92px; height: 92px; font-size: 36px; border: 4px solid #fff; box-shadow: var(--tg-shadow); }
.tg-prose { padding: 22px; font-size: 16px; line-height: 2; color: var(--tg-ink-2); }
.tg-prose h2 { font-size: 19px; margin: 0 0 10px; color: var(--tg-ink); }
.tg-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tg-table th, .tg-table td { padding: 10px 12px; border-bottom: 1px solid var(--tg-line); text-align: right; }
.tg-table th { color: var(--tg-muted); font-weight: 700; background: var(--tg-bg); }
.tg-tags { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .tg-product { grid-template-columns: minmax(0, 1fr); }
  .tg-buybox { position: static; }
}

/* ---------------------------- المعرض ---------------------------- */
.tg-gallery { padding: 12px; }
.tg-gallery__stage { position: relative; border-radius: var(--tg-radius-sm); overflow: hidden; background: #0f1220; }
.tg-gallery__track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; direction: ltr; }
.tg-gallery__track::-webkit-scrollbar { display: none; }
.tg-gallery__slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; cursor: zoom-in; margin: 0; }
.tg-gallery__slide img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tg-gallery__nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .92); color: var(--tg-ink); font-size: 22px; line-height: 1; cursor: pointer; box-shadow: var(--tg-shadow); display: flex; align-items: center; justify-content: center;
}
.tg-gallery__nav--prev { right: 12px; }
.tg-gallery__nav--next { left: 12px; }
.tg-gallery__count { position: absolute; bottom: 10px; left: 12px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; direction: ltr; }
.tg-gallery__thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.tg-gallery__thumb { flex: 0 0 84px; height: 56px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #eef0f7; opacity: .65; transition: opacity .15s, border-color .15s; }
.tg-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-gallery__thumb.is-active, .tg-gallery__thumb:hover { opacity: 1; border-color: var(--tg-primary); }
.tg-gallery--single .tg-gallery__nav, .tg-gallery--single .tg-gallery__thumbs, .tg-gallery--single .tg-gallery__count { display: none; }
.tg-lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.tg-lightbox::backdrop { background: rgba(8, 10, 20, .92); }
.tg-lightbox img { position: absolute; inset: 0; margin: auto; max-width: 94vw; max-height: 88vh; object-fit: contain; }
.tg-lightbox__close { position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0; font-size: 24px; cursor: pointer; background: #fff; }
.tg-lightbox .tg-gallery__nav { position: absolute; }

/* ---------------------------- المتجر ---------------------------- */
.tg-store-hero { position: relative; height: 200px; border-radius: 0 0 28px 28px; background: linear-gradient(135deg, #2b1b6e, #5b3cc4 60%, #d6336c); background-size: cover; background-position: center; }
.tg-store-head { display: flex; gap: 18px; align-items: flex-end; margin-top: -54px; position: relative; flex-wrap: wrap; }
.tg-store-head__info { flex: 1; min-width: 220px; padding-bottom: 6px; }
.tg-store-head h1 { margin: 0; font-size: 26px; font-weight: 800; }
.tg-store-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.tg-stat { padding: 12px 18px; min-width: 120px; }
.tg-stat b { display: block; font-size: 22px; color: var(--tg-ink); }
.tg-stat span { font-size: 13px; color: var(--tg-muted); }

/* ---------------------------- النماذج ---------------------------- */
.tg-form { display: grid; gap: 16px; padding: 24px; }
.tg-field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.tg-field input, .tg-field textarea { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--tg-line); border-radius: 10px; font-size: 15px; background: #fff; color: var(--tg-ink); }
.tg-field input:focus, .tg-field textarea:focus { outline: 2px solid var(--tg-primary-050); border-color: var(--tg-primary); }
.tg-field small { color: var(--tg-muted); font-size: 12px; }
.tg-alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; }
.tg-alert--ok { background: var(--tg-success-050); color: #0b6b48; }
.tg-alert--err { background: #fdecef; color: #a1203f; }

/* ---------------------------- التذييل ---------------------------- */
.tg-footer { margin-top: 56px; background: #151a2b; color: #c9cede; padding: 36px 0 20px; text-align: center; }
.tg-footer a { color: #e6e9f2; text-decoration: none; }
.tg-footer a:hover { color: #fff; text-decoration: underline; }
.tg-footer__links { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-size: 14px; margin-bottom: 18px; }
.tg-footer__trust { display: flex; justify-content: center; align-items: center; gap: 22px; flex-wrap: wrap; margin: 20px 0; }
.tg-footer__trust img { background: #fff; border-radius: 10px; padding: 6px; }
.tg-footer__note { font-size: 13px; opacity: .85; max-width: 760px; margin: 0 auto 10px; line-height: 1.9; }
.tg-footer__copy { font-size: 12px; opacity: .6; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
