:root {
  --primary: #7C3AED;
  --primary-dark: #6D28D9;
  --primary-light: #EDE9FE;
  --accent: #D4AF37;
  --bg: #F9FAFB;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

html {
  direction: rtl;
  font-family: 'Tajawal', -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 70px;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

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

/* ============ HEADER ============ */
.header {
  background: var(--primary);
  color: white;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  max-width: 36px !important;
  min-height: 36px;
  max-height: 36px !important;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  flex-grow: 0;
  border: 2px solid rgba(255,255,255,0.3);
}

.logo {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn {
  color: white !important;
  font-size: 24px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-width: 32px;
  opacity: 1 !important;
  -webkit-text-fill-color: white;
  z-index: 10000;
}

.back-btn i {
  color: white !important;
  -webkit-text-fill-color: white;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 9999;
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--text-light);
  font-size: 10px;
  position: relative;
  transition: color 0.2s;
}

.nav-item.active { color: var(--primary); }
.nav-item i { font-size: 22px; margin-bottom: 2px; }

.nav-item-ig {
  position: relative;
}

.nav-item-ig .ig-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -22px;
  box-shadow: 0 4px 12px rgba(188,24,136,0.3);
}

.nav-item-ig .ig-icon-wrap i {
  font-size: 26px;
  color: white;
  margin-bottom: 0;
}

.nav-item-ig span {
  margin-top: 2px;
}

/* ============ SEARCH ============ */
.search-box {
  padding: 12px 0 4px;
  position: relative;
}

.search-filter-row .search-box {
  padding: 0;
}

.search-input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 25px;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  background: white;
  direction: rtl;
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 200;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
}

.search-result-item:active { background: var(--bg); }

.search-result-item img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
}

/* ============ CATEGORIES ============ */
.categories-scroll {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 0;
  scrollbar-width: none;
}

.categories-scroll::-webkit-scrollbar { display: none; }

.category-chip {
  flex-shrink: 0;
  padding: 7px 16px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-chip:active {
  background: var(--primary);
  color: white;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 0;
}

.category-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.category-card:active { transform: scale(0.98); }

.category-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.category-card .name {
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* ============ SECTION ============ */
.section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title a {
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
}

/* ============ PRODUCT GRID ============ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.2s;
  position: relative;
  min-width: 0; /* prevent grid blowout */
}

.product-card:active { transform: scale(0.97); }

.product-card .card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  width: 100%;
}

.product-card .card-media {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.product-card .card-carousel {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.product-card .carousel-item {
  width: 100%;
}

.product-card .no-image {
  aspect-ratio: 3/4;
  width: 100%;
}

.product-card .info {
  padding: 8px 10px 10px;
}

.product-card .name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.product-card .brand {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.product-card .price {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.product-card .old-price {
  font-size: 11px;
  color: var(--text-light);
  text-decoration: line-through;
  margin-left: 4px;
}

.product-card .out-of-stock {
  font-size: 11px;
  color: var(--danger);
  margin-top: 2px;
}

/* ============ PRODUCT DETAIL ============ */
.product-detail-media {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #f3f4f6;
  display: block;
}

.product-detail-info {
  padding: 16px 16px 24px;
}

.product-detail-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.4;
}

.product-detail-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

/* ============ OPTIONS ============ */
.option-group {
  margin-bottom: 16px;
}

.option-label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  font-family: 'Tajawal', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}

.option-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.option-btn:active { transform: scale(0.95); }

/* ============ QUANTITY ============ */
.quantity-control {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.quantity-btn {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-family: 'Tajawal', sans-serif;
  color: var(--text);
  transition: all 0.15s;
}

.quantity-btn:active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.quantity-value {
  font-size: 16px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

/* ============ SPECS ============ */
.specs-list h3 {
  font-size: 15px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.spec-label { color: var(--text-light); }

/* ============ CART ============ */
.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.cart-item img {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-details {
  font-size: 12px;
  color: var(--text-light);
}

.cart-item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* ============ CART SUMMARY ============ */
.cart-summary {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.cart-summary .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.cart-summary .total {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 16px;
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  direction: rtl;
  background: white;
  color: var(--text);
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: 12px; }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 8px;
}

/* ============ ALERTS ============ */
.alert {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-success { background: #D1FAE5; color: #065F46; }
.alert-error { background: #FEE2E2; color: #991B1B; }
.alert-warning { background: #FEF3C7; color: #92400E; }

/* ============ STATUS BADGES ============ */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending { background: #FEF3C7; color: #92400E; }
.status-confirmed { background: #DBEAFE; color: #1E40AF; }
.status-shipped { background: #E0E7FF; color: #3730A3; }
.status-delivered { background: #D1FAE5; color: #065F46; }
.status-cancelled { background: #FEE2E2; color: #991B1B; }

/* ============ NO IMAGE ============ */
.no-image {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 32px;
}

.no-image-sm {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}

/* ============ ORDER TIMELINE ============ */
.order-timeline {
  padding: 20px 0;
}

.timeline-step {
  display: flex;
  align-items: flex-start;
  padding-bottom: 24px;
  position: relative;
  gap: 12px;
}

.timeline-step:last-child { padding-bottom: 0; }
.timeline-step:last-child .timeline-line { display: none; }

.timeline-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  background: white;
}

.timeline-step.active .timeline-dot {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124,58,237,0.2);
}

.timeline-step.completed .timeline-dot {
  background: var(--success);
  border-color: var(--success);
}

.timeline-line {
  position: absolute;
  right: 10px;
  top: 22px;
  width: 2px;
  height: calc(100% - 12px);
  background: var(--border);
}

/* ============ MINI FOOTER ============ */
.mini-footer {
  text-align: center;
  padding: 24px 16px 80px;
  font-size: 12px;
  color: var(--text-light);
}

.mini-footer p {
  margin-bottom: 4px;
}

.mini-footer a {
  color: var(--text-light);
  text-decoration: none;
  opacity: 0.6;
  font-size: 11px;
}

.mini-footer a:active {
  color: var(--primary);
}

/* ============ UTILITY ============ */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }

/* ============ SEARCH + FILTER ROW ============ */
.search-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
}

.search-filter-row .search-input {
  padding: 12px 16px;
  font-size: 14px;
}

.filter-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.filter-btn:active {
  transform: scale(0.95);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============ FILTER PANEL ============ */
.filter-panel {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-group {
  margin-bottom: 16px;
}

.filter-group:last-of-type {
  margin-bottom: 10px;
}

.filter-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  padding: 8px 18px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:active {
  transform: scale(0.95);
}

.filter-chip.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-sm {
  padding: 8px 20px;
  font-size: 14px;
  border-radius: 10px;
}

/* ============ CARD CAROUSEL ============ */
.card-carousel {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.carousel-item {
  position: relative;
  width: 100%;
}

.carousel-item img,
.carousel-item video {
  width: 100%;
  display: block;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  border: none;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.carousel-prev { right: 4px; }
.carousel-next { left: 4px; }

.carousel-dots {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 5;
}

.carousel-dots .dot,
.detail-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: all 0.2s;
}

.carousel-dots .dot.active,
.detail-dots .dot.active {
  background: white;
  width: 14px;
  border-radius: 3px;
}

/* ============ DETAIL CAROUSEL ============ */
.detail-carousel {
  position: relative;
  overflow: hidden;
  background: #f3f4f6;
  width: 100%;
}

.detail-carousel-item {
  width: 100%;
}

.detail-carousel-item img,
.detail-carousel-item video {
  width: 100%;
  display: block;
}

.detail-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.detail-prev { right: 12px; }
.detail-next { left: 12px; }

.detail-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 5;
}

/* ============ CARD IG BUTTON ============ */
.card-ig-btn {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border: none;
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(188,24,136,0.4);
  transition: transform 0.15s;
}

.card-ig-btn:active {
  transform: scale(0.9);
}

/* ============ IG BUTTON (DETAIL) ============ */
.btn-ig {
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  color: white;
  margin-top: 16px;
}

/* ============ PRODUCT TAGS ============ */
.product-tag {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 10px;
  background: #F3F4F6;
  color: #6B7280;
  display: inline-block;
}

.product-tag.tag-primary {
  background: #EDE9FE;
  color: #7C3AED;
}

.product-tag.tag-color {
  background: #DBEAFE;
  color: #1E40AF;
}

.product-tag.tag-spec {
  background: #D1FAE5;
  color: #065F46;
}

/* ============ OPTION TAG (DISPLAY) ============ */
.option-tag {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #F9FAFB;
  font-size: 13px;
  color: var(--text);
  display: inline-block;
}

/* ============ CUSTOMER REVIEWS ============ */
.reviews-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.review-item {
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
}
.review-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
