/* Top Phones — Futuristic cyber / glass UI */
:root {
  --tp-blue: #00d4ff;
  --tp-purple: #a855f7;
  --tp-pink: #f472b6;
  --tp-glass: rgba(255, 255, 255, 0.06);
  --tp-glass-border: rgba(255, 255, 255, 0.12);
  --tp-text: #e8edf7;
  --tp-muted: #94a3b8;
  --tp-bg: #030508;
  --tp-card: rgba(12, 14, 22, 0.65);
  --tp-font-display: "Orbitron", system-ui, sans-serif;
  --tp-font-body: "Tajawal", "Segoe UI", sans-serif;
  --tp-radius: 18px;
  --tp-shadow-neon: 0 0 24px rgba(0, 212, 255, 0.25), 0 0 48px rgba(168, 85, 247, 0.12);
  --tp-transition: 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Orbitron has no Arabic glyphs — use Tajawal for headings/UI in RTL */
html[dir="rtl"] {
  --tp-font-display: "Tajawal", "Segoe UI", sans-serif;
}

[data-theme="light"] {
  --tp-glass: rgba(255, 255, 255, 0.55);
  --tp-glass-border: rgba(15, 23, 42, 0.1);
  --tp-text: #0f172a;
  --tp-muted: #475569;
  --tp-bg: #f1f5f9;
  --tp-card: rgba(255, 255, 255, 0.75);
  --tp-shadow-neon: 0 8px 32px rgba(14, 165, 233, 0.15), 0 0 0 1px rgba(168, 85, 247, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100%;
}

body.tp-body {
  margin: 0;
  min-height: 100dvh;
  max-width: 100%;
  font-family: var(--tp-font-body);
  color: var(--tp-text);
  background: var(--tp-bg);
  line-height: 1.5;
  overflow-x: hidden;
}

.tp-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.tp-bg__gradient {
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(ellipse 50% 40% at 20% 20%, rgba(0, 212, 255, 0.18), transparent 55%),
    radial-gradient(ellipse 45% 35% at 85% 15%, rgba(168, 85, 247, 0.2), transparent 50%),
    radial-gradient(ellipse 40% 50% at 50% 100%, rgba(244, 114, 182, 0.08), transparent 45%);
  animation: tp-gradient-move 18s ease-in-out infinite alternate;
}

[data-theme="light"] .tp-bg__gradient {
  opacity: 0.85;
}

@keyframes tp-gradient-move {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-4%, 3%) scale(1.05); }
}

.tp-bg__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 20%, transparent 70%);
}

.tp-bg__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.45;
}

.glass-bar {
  background: var(--tp-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--tp-glass-border);
}

.tp-bottom-nav.glass-bar,
.tp-admin-nav.glass-bar {
  border-bottom: none;
}

.tp-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Flex + dir=rtl: ترتيب متناسق — الموبايل: تحكم | شعار (يعكس مع RTL) — الديسكتوب: تحكم | شعار وسط | قائمة */
.tp-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  min-height: 52px;
}

.tp-header__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  z-index: 2;
}

/* في العربية: أزرار اللغة والثيم أقرب لبداية السطر (يمين الشاشة) */
[dir="rtl"] .tp-header__controls {
  flex-direction: row-reverse;
}

.tp-logo {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  flex-shrink: 0;
  z-index: 1;
}

/* موبايل: الشعار في التدفق — مع RTL يظهر يسار، مع LTR يمين (مرآة طبيعية) */
@media (max-width: 899px) {
  .tp-header__inner {
    justify-content: space-between;
  }

  .tp-logo {
    position: relative;
    transform: none;
    margin: 0;
  }
}

/* ديسكتوب: الشعار وسط الشاشة فعلياً، والعمودان تحكم + قائمة على الأطراف */
@media (min-width: 900px) {
  .tp-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }
}

/* الشعار: نفس خط العناوين (أوربتون في LTR، تجوال في RTL) لعرض اسم المتجر من قاعدة البيانات بشكل صحيح */
.tp-logo__glow {
  font-family: var(--tp-font-display);
  font-weight: 900;
  font-size: clamp(1rem, 4vw, 1.35rem);
  letter-spacing: 0.08em;
  text-align: center;
  max-width: 70vw;
  background: linear-gradient(90deg, var(--tp-blue), var(--tp-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
  filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.4));
}

[dir="rtl"] .tp-logo__glow {
  letter-spacing: 0.04em;
  background: linear-gradient(-90deg, var(--tp-blue), var(--tp-purple));
  -webkit-background-clip: text;
  background-clip: text;
}

.tp-logo__sub {
  font-family: var(--tp-font-display);
  font-size: clamp(0.55rem, 2.5vw, 0.65rem);
  letter-spacing: 0.35em;
  color: var(--tp-muted);
  margin-top: 2px;
  text-align: center;
  max-width: 70vw;
}

[dir="rtl"] .tp-logo__sub {
  letter-spacing: 0.12em;
}

.tp-nav-desktop {
  display: none;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  /* بداية محور القراءة = باتجاه الشعار الوسطي في LTR و RTL */
  justify-content: flex-start;
  flex-shrink: 1;
  min-width: 0;
  z-index: 2;
}

.tp-nav-desktop a {
  color: var(--tp-text);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  transition: color var(--tp-transition), box-shadow var(--tp-transition);
}

.tp-nav-desktop a:hover {
  color: var(--tp-blue);
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.2);
}

.tp-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
  color: var(--tp-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s, box-shadow 0.3s;
  animation: tp-pulse-glow 3s ease-in-out infinite;
}

.tp-icon-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.35);
}

@keyframes tp-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.25); }
  50% { box-shadow: 0 0 18px 2px rgba(168, 85, 247, 0.25); }
}

[data-theme="light"] .tp-theme-toggle__moon,
[data-theme="dark"] .tp-theme-toggle__sun {
  display: none;
}

.tp-lang {
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
}

.tp-lang__btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  color: var(--tp-muted);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.tp-lang__btn.is-active {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(168, 85, 247, 0.2));
  color: var(--tp-text);
}

.tp-badge {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 4px;
  font-size: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tp-blue), var(--tp-purple));
  color: #fff;
  vertical-align: middle;
}

.tp-main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 0.85rem 5.25rem;
  width: 100%;
  min-width: 0;
}

.tp-main img,
.tp-main table,
.tp-main video {
  max-width: 100%;
  height: auto;
}

@media (max-width: 899px) {
  .tp-main {
    padding: 0.65rem 0.65rem 4.85rem;
  }

  .tp-hero {
    padding: 1.35rem 0.85rem;
    margin-bottom: 1.15rem;
  }

  .tp-section-title {
    margin-bottom: 0.6rem;
    font-size: 1.05rem;
  }

  .tp-grid {
    gap: 0.7rem;
    margin-bottom: 1.15rem;
  }
}

@media (min-width: 900px) {
  .tp-nav-desktop { display: flex; }
  .tp-bottom-nav { display: none !important; }
  .tp-main { padding: 1rem 1rem 2rem; }
}

/* Fixed to viewport — avoid filter/transform on body (breaks fixed positioning) */
.tp-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 9999;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding: 0.3rem 0 max(0.35rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--tp-glass-border);
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.tp-bottom-nav__item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.3rem 0.2rem;
  font-size: 0.62rem;
  color: var(--tp-muted);
  text-decoration: none;
  position: relative;
  transition: color 0.25s, transform 0.25s;
}

/* Label is always 2nd child (cart adds badge as 3rd) */
.tp-bottom-nav__item > span:nth-child(2) {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.tp-bottom-nav__item.is-active {
  color: var(--tp-blue);
  transform: translateY(-2px);
}

.tp-bottom-nav__icon {
  font-size: 1.2rem;
  filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.3));
}

.tp-bottom-nav__badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 18%;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.6rem;
  line-height: 16px;
  text-align: center;
  border-radius: 999px;
  background: var(--tp-purple);
  color: #fff;
}

.tp-bottom-nav__badge:empty,
.tp-bottom-nav__badge[data-cart-count="0"] {
  display: none;
}

/* Hero */
.tp-hero {
  position: relative;
  border-radius: calc(var(--tp-radius) + 8px);
  padding: 2rem 1.1rem;
  margin-bottom: 1.5rem;
  overflow-x: hidden;
  overflow-y: visible;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
  backdrop-filter: blur(16px);
  box-shadow: var(--tp-shadow-neon);
}

.tp-hero__title {
  font-family: var(--tp-font-display);
  font-size: clamp(1.6rem, 5vw, 2.75rem);
  font-weight: 800;
  margin: 0 0 0.5rem;
  line-height: 1.15;
  background: linear-gradient(110deg, #fff, var(--tp-blue) 40%, var(--tp-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="light"] .tp-hero__title {
  background: linear-gradient(110deg, #0f172a, #0284c7 45%, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
}

.tp-hero__sub {
  margin: 0 0 1.5rem;
  color: var(--tp-muted);
  max-width: 36ch;
}

.tp-slider {
  position: relative;
  width: 100%;
  border-radius: var(--tp-radius);
  overflow: hidden;
  border: 1px solid rgba(0, 212, 255, 0.25);
  min-height: 0;
}

.tp-slider__track {
  display: flex;
  width: 100%;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  /* مسار أفقي ثابت حتى يعمل translateX بشكل صحيح في صفحات RTL */
  direction: ltr;
}

.tp-slider__slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(168, 85, 247, 0.1));
}

html[dir="rtl"] .tp-slider__slide {
  direction: rtl;
}

html[dir="ltr"] .tp-slider__slide {
  direction: ltr;
}

.tp-slider__desc {
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 600px) {
  .tp-slider__slide {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.tp-slider__slide img {
  width: 100%;
  max-height: min(52vw, 320px);
  height: auto;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
  transform: rotate(-3deg);
  transition: transform 0.5s;
}

.tp-slider__slide:hover img {
  transform: rotate(0deg) scale(1.04);
}

.tp-slider__dots {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding: 0.75rem;
}

.tp-slider__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--tp-muted);
  opacity: 0.5;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.tp-slider__dot.is-active {
  opacity: 1;
  background: var(--tp-blue);
  box-shadow: 0 0 12px var(--tp-blue);
  transform: scale(1.2);
}

.tp-section-title {
  font-family: var(--tp-font-display);
  font-size: 1.15rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tp-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--tp-blue), transparent);
}

[dir="rtl"] .tp-section-title::after {
  background: linear-gradient(-90deg, var(--tp-blue), transparent);
}

.tp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .tp-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

.tp-card {
  position: relative;
  border-radius: var(--tp-radius);
  padding: 0.85rem;
  text-decoration: none;
  color: inherit;
  background: var(--tp-card);
  border: 1px solid var(--tp-glass-border);
  backdrop-filter: blur(12px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--tp-transition), box-shadow var(--tp-transition), border-color 0.3s;
}

.tp-card:hover {
  transform: scale(1.03) rotate(-1.2deg);
  border-color: rgba(0, 212, 255, 0.55);
  box-shadow: 0 12px 40px rgba(0, 212, 255, 0.15), 0 0 0 1px rgba(168, 85, 247, 0.25);
}

.tp-card__img-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.2);
}

.tp-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}

.tp-card:hover .tp-card__img-wrap img {
  transform: scale(1.08);
}

.tp-offer-badge {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tp-pink), var(--tp-purple));
  color: #fff;
  animation: tp-badge-pulse 2s ease-in-out infinite;
}

@keyframes tp-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.5); }
  50% { box-shadow: 0 0 14px 4px rgba(168, 85, 247, 0.45); }
}

.tp-card__name {
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0.65rem 0 0.25rem;
  line-height: 1.3;
}

.tp-card__price {
  font-family: var(--tp-font-display);
  font-size: 0.95rem;
  color: var(--tp-blue);
  margin-top: auto;
}

.tp-card__price--old {
  font-size: 0.75rem;
  color: var(--tp-muted);
  text-decoration: line-through;
  margin-inline-end: 0.35rem;
}

/* Brands marquee */
.tp-marquee {
  overflow: hidden;
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
  margin-bottom: 2rem;
  mask-image: linear-gradient(90deg, transparent, black 8%, black 92%, transparent);
}

.tp-marquee__track {
  display: flex;
  gap: 3rem;
  padding: 1rem 0;
  width: max-content;
  animation: tp-marquee 28s linear infinite;
}

@keyframes tp-marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

[dir="rtl"] .tp-marquee__track {
  animation-name: tp-marquee-rtl;
}

@keyframes tp-marquee-rtl {
  0% { transform: translateX(0); }
  100% { transform: translateX(50%); }
}

.tp-marquee__item {
  flex: 0 0 auto;
  opacity: 0.85;
  filter: grayscale(0.3);
  transition: filter 0.3s, opacity 0.3s;
}

.tp-marquee__item:hover {
  opacity: 1;
  filter: grayscale(0);
}

.tp-marquee__item img {
  height: 36px;
  width: auto;
  max-width: 100px;
  object-fit: contain;
}

/* Buttons */
.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 212, 255, 0.45);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(168, 85, 247, 0.15));
  color: var(--tp-text);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.3s;
  animation: tp-pulse-glow 4s ease-in-out infinite;
}

.tp-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 212, 255, 0.25);
}

.tp-btn--ghost {
  background: transparent;
  border-color: var(--tp-glass-border);
}

/* Forms */
.tp-form {
  max-width: 420px;
  margin: 0 auto;
}

.tp-field {
  margin-bottom: 1rem;
}

.tp-field label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--tp-muted);
}

.tp-field input,
.tp-field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
  color: var(--tp-text);
  font-family: inherit;
  font-size: 1rem;
}

.tp-field textarea {
  min-height: 90px;
  resize: vertical;
}

/* Product detail gallery */
.tp-gallery {
  border-radius: var(--tp-radius);
  overflow: hidden;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
}

.tp-gallery__main {
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.15);
}

.tp-gallery__main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tp-gallery__thumbs {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  overflow-x: auto;
}

.tp-gallery__thumbs button {
  flex: 0 0 56px;
  height: 56px;
  padding: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  background: none;
}

.tp-gallery__thumbs button.is-active {
  border-color: var(--tp-blue);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.35);
}

.tp-gallery__thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tables / cart */
.tp-table-wrap {
  overflow-x: auto;
  border-radius: var(--tp-radius);
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-card);
}

.tp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tp-table th,
.tp-table td {
  padding: 0.75rem 1rem;
  text-align: start;
  border-bottom: 1px solid var(--tp-glass-border);
}

.tp-table input[type="number"] {
  width: 56px;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--tp-glass-border);
  background: var(--tp-bg);
  color: var(--tp-text);
}

/* Scroll reveal */
.tp-reveal {
  opacity: 0;
  transform: translateY(28px) scale(0.98);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.tp-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* On .tp-main only — never on body (filter on ancestor breaks position:fixed bars) */
.tp-main.page-enter {
  animation: tp-page-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes tp-page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tp-alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 1px solid var(--tp-glass-border);
}

.tp-alert--ok {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.1);
}

.tp-alert--err {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
}

.tp-split-auth {
  display: grid;
  gap: 2rem;
}

@media (min-width: 800px) {
  .tp-split-auth {
    grid-template-columns: 1fr 1fr;
  }
}

.tp-muted {
  color: var(--tp-muted);
  font-size: 0.9rem;
}
