/* ==========================================================================
   Product Detail Modal — Phase 3
   Full-screen overlay with image carousel, RTL support, mobile responsive
   ========================================================================== */

.pd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.pd-overlay--open {
  opacity: 1;
  visibility: visible;
}

.pd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pd-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-cream, #ece9e1);
  border-radius: 20px;
  direction: rtl;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  animation: pd-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pd-slide-up {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .pd-container {
    background: var(--bg-soft, #202124);
  }
}

/* Close button */
.pd-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.pd-close:hover { background: rgba(0,0,0,0.7); }

/* ---- Carousel ---- */
.pd-carousel-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  background: #1a1a1a;
}

.pd-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: transform;
}

.pd-slide {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
}
.pd-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pd-slide--empty {
  background: #2a2a2a;
}
.pd-no-image {
  color: #888;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 16px;
}

/* Carousel nav buttons */
.pd-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: #222;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0;
}
.pd-carousel-wrapper:hover .pd-carousel-btn,
.pd-carousel-btn:focus-visible { opacity: 1; }
.pd-carousel-btn:hover { background: #fff; }
.pd-carousel-prev { right: 8px; }
.pd-carousel-next { left: 8px; }

/* Dots */
.pd-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}
.pd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}
.pd-dot--active {
  background: #fff;
  transform: scale(1.3);
}

/* ---- Content ---- */
.pd-content {
  padding: 24px;
}

.pd-name {
  margin: 0 0 8px;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main, #1a1a1a);
}
.pd-price {
  margin: 0 0 16px;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-terracotta, #cc805f);
}
.pd-description {
  margin: 0 0 20px;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-sub, #57606a);
  white-space: pre-line;
}

/* Actions: quantity + CTA */
.pd-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pd-quantity {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--secondary-teal, #2c5f5d);
  border-radius: 10px;
  overflow: hidden;
}
.pd-qty-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--secondary-teal, #2c5f5d);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.pd-qty-btn:hover { background: rgba(44, 95, 93, 0.1); }
.pd-qty-val {
  min-width: 36px;
  text-align: center;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main, #1a1a1a);
}

.pd-add-to-cart {
  flex: 1;
  min-width: 160px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--primary-terracotta, #cc805f);
  color: #fff;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.pd-add-to-cart:hover { background: #b5684a; }
.pd-add-to-cart:active { transform: scale(0.97); }

/* ---- Loader / Skeleton ---- */
.pd-loader {
  padding: 24px;
  display: none;
}
.pd-skeleton {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 16px;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: pd-shimmer 1.2s infinite;
}
@keyframes pd-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Error State ---- */
.pd-error {
  padding: 40px 24px;
  text-align: center;
  display: none;
}
.pd-error p {
  margin: 0 0 16px;
  font-family: 'SaudiWeb', sans-serif;
  font-size: 15px;
  color: #d32f2f;
}
.pd-retry-btn {
  padding: 10px 28px;
  border: 2px solid var(--primary-terracotta, #cc805f);
  border-radius: 10px;
  background: transparent;
  color: var(--primary-terracotta, #cc805f);
  font-family: 'SaudiWeb', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.pd-retry-btn:hover { background: var(--primary-terracotta, #cc805f); color: #fff; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .pd-container {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .pd-carousel-wrapper {
    border-radius: 0;
  }
  .pd-carousel-btn {
    opacity: 1;
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
  .pd-name { font-size: 18px; }
  .pd-price { font-size: 17px; }
  .pd-content { padding: 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pd-overlay,
  .pd-container,
  .pd-carousel-track {
    transition: none;
    animation: none;
  }
}
