/* ══════════════════════════════════════════════════════════════
   Modal - Modern Card Style
   ══════════════════════════════════════════════════════════════ */

#item-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#item-modal.open {
  display: flex;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#item-modal.closing {
  display: flex;
}

/* Backdrop */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#item-modal.open .modal-backdrop {
  opacity: 1;
}

#item-modal.closing .modal-backdrop {
  opacity: 0;
}

#item-modal.closing .modal-sheet {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: all 0.25s ease;
}

/* Card Container */
.modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: linear-gradient(145deg, #2a2a2a 0%, #1f1f1f 100%);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 
    0 25px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.15, 0.64, 1);
}

#item-modal.open .modal-sheet {
  opacity: 1;
  transform: scale(1) translateY(0);
}

#item-modal.closing .modal-sheet {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Accent Bar */
.modal-sheet::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ff3d00 0%, #d32f2f 50%, #a60b0b 100%);
  z-index: 10;
}

/* Close Button */
.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  cursor: pointer;
  z-index: 15;
  transition: all 0.2s cubic-bezier(0.34, 1.15, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.modal-close:hover {
  background: rgba(166, 11, 11, 0.9);
  transform: scale(1.1);
}

.modal-close:active {
  transform: scale(0.95);
}

/* Body */
.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Image Wrap */
.modal-img-wrap {
  position: relative;
  width: 100%;
  min-height: 280px;
  max-height: 380px;
  background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-img-wrap::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  pointer-events: none;
}

.modal-img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.modal-img-placeholder {
  width: 100%;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
  opacity: 0.6;
}

/* Loading Skeleton */
.modal-img-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #2a2a2a 0%, #3a3a3a 50%, #2a2a2a 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  z-index: 1;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Content */
.modal-content {
  padding: 28px 24px 32px;
  direction: rtl;
  position: relative;
}

.modal-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #FF9800;
  background: rgba(255, 152, 0, 0.12);
  padding: 6px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.modal-name {
  font-size: clamp(1.4rem, 5vw, 1.7rem);
  font-weight: 900;
  line-height: 1.3;
  color: #ffffff;
  margin-bottom: 14px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-desc {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.8;
  margin-bottom: 24px;
}

.modal-divider {
  height: 2px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
  margin-bottom: 24px;
}

/* Price Section */
.modal-price-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-price-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-discount-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff3d00 0%, #d32f2f 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.modal-price-old {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.4);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.modal-price-new {
  font-size: clamp(1.5rem, 5vw, 1.8rem);
  font-weight: 900;
  background: linear-gradient(135deg, #FFD54F 0%, #FFB74D 40%, #FF9800 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 6px rgba(255, 152, 0, 0.3));
}

/* Responsive */
@media (max-width: 768px) {
  #item-modal {
    padding: 16px;
  }
  
  .modal-sheet {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 20px;
  }
  
  .modal-img-wrap {
    min-height: 200px;
    max-height: 260px;
  }
  
  .modal-content {
    padding: 20px 18px 24px;
  }
  
  .modal-name {
    font-size: 1.3rem;
  }
  
  .modal-price-new {
    font-size: 1.4rem;
  }
  
  .modal-close {
    width: 36px;
    height: 36px;
    top: 12px;
    left: 12px;
  }
}

@media (max-width: 480px) {
  #item-modal {
    padding: 12px;
  }
  
  .modal-sheet {
    border-radius: 18px;
  }
  
  .modal-img-wrap {
    min-height: 180px;
    max-height: 240px;
  }
  
  .modal-content {
    padding: 18px 16px 22px;
  }
}

@media (min-width: 769px) {
  .modal-img-wrap {
    min-height: 300px;
    max-height: 400px;
  }
}
