/* ============================================
   التصميم الأساسي
   ============================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Cairo', sans-serif; background: #fff; color: #1a1a1a; line-height: 1.6; }
a { text-decoration: none; color: inherit; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ============================================
   الترويسة (بدون واتساب)
   ============================================ */

header { 
    padding: 16px 0; 
    border-bottom: 1px solid #eee; 
    background: #fff; 
    position: sticky; 
    top: 0; 
    z-index: 999; 
    box-shadow: 0 2px 10px rgba(0,0,0,.03); 
}

header .container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 12px; 
    flex-wrap: wrap; 
}

.logo h1 { font-size: 24px; font-weight: 800; }
.logo h1 span { color: #25d366; }
.logo > span { 
    display: block; 
    font-size: 13px; 
    color: #25d366; 
    font-weight: 600; 
    margin-top: -4px; 
}

/* ============================================
   زر السلة
   ============================================ */

.cart-header,
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-btn {
    background: none;
    border: none;
    font-size: 24px;
    position: relative;
    cursor: pointer;
    color: #1a1a1a;
    padding: 8px;
    transition: 0.3s;
    width: auto;
    height: auto;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cairo', sans-serif;
}

.cart-btn:hover {
    transform: scale(1.1);
    background: transparent;
}

.cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    inset-inline-end: -6px;
    background: #25d366;
    color: #fff;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
    min-width: 20px;
    height: auto;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   واجهة السلة الجانبية
   ============================================ */

.cart-sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    z-index: 3000;
    transition: right 0.3s ease;
    box-shadow: -4px 0 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transform: none !important; /* override older transform-based sidebar */
}

.cart-sidebar.open {
    right: 0;
}

.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2999;
    display: none;
    opacity: 1;
    visibility: visible;
}

.cart-overlay.show,
.cart-overlay.open {
    display: block;
}

.cart-header-bar {
    padding: 20px 24px;
    border-bottom: 2px solid #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    color: #1a1a1a;
}

.cart-header-bar h3 {
    font-size: 20px;
    color: #1a1a1a;
    margin: 0;
}

.cart-header-bar h3 i {
    color: #25d366;
    margin-left: 10px;
}

.close-cart {
    background: #f5f5f5;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.close-cart:hover {
    background: #ff4444;
    color: #fff;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.empty-cart {
    text-align: center;
    color: #999;
    font-size: 16px;
    margin-top: 60px;
}

.cart-item,
.cart-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f5f5f5;
    gap: 10px;
    border: none;
    border-radius: 0;
    margin-bottom: 0;
}

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

.cart-item-code,
.cart-line .code {
    font-weight: 800;
    color: #25d366;
    font-size: 14px;
}

.cart-item-name,
.cart-line .name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin: 4px 0;
    color: #1a1a1a;
    line-height: 1.35;
}

.cart-item-qty,
.cart-line .qty-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.cart-item-qty button,
.cart-line .qty-row button {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: 0.3s;
    font-weight: 700;
}

.cart-item-qty button:hover,
.cart-line .qty-row button:hover {
    background: #25d366;
    color: #fff;
    border-color: #25d366;
}

.cart-item-qty span,
.cart-line .qty-row span {
    font-weight: 700;
    font-size: 16px;
    min-width: 24px;
    text-align: center;
}

.cart-remove,
.cart-line .remove {
    background: none;
    border: none;
    color: #ff4444;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    transition: 0.3s;
}

.cart-remove:hover,
.cart-line .remove:hover {
    transform: scale(1.2);
}

.cart-item img,
.cart-line img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    background: #f8f8f8;
    border-radius: 8px;
}

.cart-footer {
    padding: 20px 24px;
    border-top: 2px solid #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cart-total-line {
    font-size: 14px;
    color: #555;
}

.whatsapp-checkout {
    width: 100%;
    padding: 16px;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: 0.3s;
    font-family: 'Cairo', sans-serif;
}

.whatsapp-checkout:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.3);
    filter: none;
}

.whatsapp-checkout i {
    font-size: 22px;
}

.clear-cart-btn {
    width: 100%;
    border: 1px solid #ddd;
    background: #fff;
    color: #666;
    border-radius: 12px;
    padding: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
}

/* ============================================
   أزرار المنتجات
   ============================================ */

.product-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    flex-wrap: wrap;
}

.btn-details,
.btn-add-to-cart {
    flex: 1;
    min-width: 100px;
    border: none;
    border-radius: 24px;
    padding: 9px 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    text-align: center;
    transition: 0.3s;
}

.btn-details {
    background: #f0f0f0;
    color: #1a1a1a;
}

.btn-details:hover {
    background: #ddd;
}

.btn-add-to-cart {
    background: #1a1a1a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-add-to-cart:hover {
    background: #25d366;
    transform: scale(1.02);
}

.btn-add-to-cart i {
    font-size: 14px;
}

/* ============================================
   معرض الصور
   ============================================ */

.product-images {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    overflow: hidden;
}

.product-images img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    display: none;
    transition: opacity 0.3s;
}

.product-images img.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* أزرار التنقل في الصور */
.nav-arrows {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 6px;
    pointer-events: none;
}

.nav-arrows button {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    pointer-events: all;
    font-size: 16px;
    transition: 0.3s;
}

.nav-arrows button:hover {
    background: #25d366;
    transform: scale(1.1);
}

/* نقاط التنقل */
.image-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.image-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: 0.3s;
}

.image-dots span.active {
    background: #25d366;
    width: 24px;
    border-radius: 4px;
}

/* ============================================
   إشعارات
   ============================================ */

.notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 28px;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    z-index: 9999;
    animation: slideUp 0.4s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
}

.notification.success {
    background: #25d366;
}

.notification.error {
    background: #ff4444;
}

.notification.info {
    background: #2196F3;
}

@keyframes slideUp {
    from { transform: translateY(80px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   استجابة للشاشات الصغيرة
   ============================================ */

@media (max-width: 600px) {
    .cart-sidebar {
        right: -100%;
        width: 100%;
        max-width: 100%;
    }

    .cart-sidebar.open {
        right: 0;
    }
    
    .product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .product-images {
        min-height: 150px;
    }
    
    .product-images img {
        max-height: 140px;
    }
    
    .cart-header-bar h3 {
        font-size: 17px;
    }

    .notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* hide old header/float WA leftovers */
.whatsapp-float,
.whatsapp-header {
    display: none !important;
}


/* ============================================
   LIGHTBOX
   ============================================ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox.open {
  display: flex;
}

.lightbox-content {
  position: relative;
  width: min(1100px, 100%);
  max-height: 95vh;
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
  background: #111;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.lightbox-stage {
  position: relative;
  background: #0a0a0a;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-stage img#lightboxImage {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  transition: transform .25s ease;
  cursor: zoom-in;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.lightbox-close:hover { background: #ff4444; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  z-index: 4;
}

.lightbox-nav:disabled {
  opacity: .3;
  cursor: default;
}

.lightbox-prev { right: 12px; }
.lightbox-next { left: 12px; }
.lightbox-nav:hover:not(:disabled) { background: #25d366; }

.lightbox-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.55);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.lightbox-side {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #161616;
  color: #fff;
  overflow-y: auto;
  max-height: 95vh;
}

.lightbox-thumbnails {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lightbox-thumbnails img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: .75;
  background: #222;
}

.lightbox-thumbnails img.active,
.lightbox-thumbnails img:hover {
  border-color: #25d366;
  opacity: 1;
}

#lightboxDetails .product-code {
  color: #25d366;
  font-weight: 900;
  font-size: 18px;
}

#lightboxDetails .product-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.45;
  margin: 8px 0 12px;
}

#lightboxDetails .product-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#lightboxDetails .product-specs span {
  background: rgba(255,255,255,.08);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.lightbox-add-to-cart {
  width: 100%;
  border: none;
  background: #25d366;
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.lightbox-add-to-cart:hover { filter: brightness(1.05); }

.product-images {
  cursor: pointer;
}

.image-count {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  z-index: 2;
}

@media (max-width: 800px) {
  .lightbox-content {
    grid-template-columns: 1fr;
    max-height: 96vh;
  }
  .lightbox-stage { min-height: 280px; }
  .lightbox-stage img#lightboxImage { max-height: 45vh; }
  .lightbox-side { max-height: none; }
}
