/**
 * JD Product Enhanced Styles - Plan B
 * Enhanced product options with multi-dimensional selection support
 */

/* ================================================================
   1. Option Container Enhancements
   ================================================================ */

.jd-configurator__group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e8e8e8;
}

.jd-configurator__group:last-child {
  border-bottom: none;
}

.jd-configurator__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.jd-configurator__label i {
  color: #666;
  font-size: 16px;
}

.jd-configurator__description {
  font-size: 12px;
  color: #999;
  margin-top: -8px;
  margin-bottom: 12px;
}

/* ================================================================
   2. Option Grid Layout
   ================================================================ */

.jd-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.jd-option-grid--large {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.jd-option-grid--small {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

@media (max-width: 768px) {
  .jd-option-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
  }
}

/* ================================================================
   3. Base Option Item Styles
   ================================================================ */

.jd-option-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  min-height: 60px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.jd-option-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Hover effect */
.jd-option-item:hover {
  border-color: #007bff;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
  transform: translateY(-2px);
}

/* Active state */
.jd-option-item.is-active {
  border-color: #007bff;
  background: linear-gradient(135deg, #f0f8ff 0%, #fff 100%);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Out of stock */
.jd-option-item.is-out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f5f5f5;
}

.jd-option-item.is-out-of-stock:hover {
  transform: none;
  box-shadow: none;
  border-color: #e0e0e0;
}

/* Disabled state */
.jd-option-item.is-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* ================================================================
   4. Color Swatch Option
   ================================================================ */

.jd-option-item--swatch .jd-option-item__swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-bottom: 8px;
  position: relative;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.jd-option-item--swatch:hover .jd-option-item__swatch {
  transform: scale(1.1);
}

.jd-option-item--swatch.is-active .jd-option-item__swatch {
  box-shadow: 0 0 0 2px #007bff, 0 0 0 4px rgba(0, 123, 255, 0.2);
}

/* Swatch types */
.jd-option-item__swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.jd-option-item__swatch:not(.has-image):not(.has-initial) {
  background: var(--swatch-color, #ccc);
}

/* Image swatch */
.jd-option-item__swatch.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Text swatch */
.jd-option-item__swatch.has-initial {
  background: #f0f0f0;
  color: #333;
  font-weight: 700;
  font-size: 16px;
}

/* ================================================================
   5. Image/Thumbnail Option
   ================================================================ */

.jd-option-item--image {
  padding: 8px;
}

.jd-option-item__thumbnail {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.jd-option-item__thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.jd-option-item--image:hover .jd-option-item__thumbnail img {
  transform: scale(1.05);
}

.jd-option-item--image.is-active .jd-option-item__thumbnail {
  box-shadow: 0 0 0 2px #007bff inset;
}

/* ================================================================
   6. Button Style Option
   ================================================================ */

.jd-option-item--button {
  min-height: 48px;
  padding: 12px 16px;
  justify-content: center;
}

.jd-option-item--button .jd-option-item__name {
  font-weight: 600;
  font-size: 14px;
}

.jd-option-item--button.is-active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

.jd-option-item--button.is-active .jd-option-item__name,
.jd-option-item--button.is-active .jd-option-item__price {
  color: #fff;
}

/* ================================================================
   7. Option Text and Labels
   ================================================================ */

.jd-option-item__name {
  font-size: 12px;
  color: #333;
  line-height: 1.3;
  font-weight: 500;
  margin-bottom: 4px;
}

.jd-option-item__price {
  font-size: 13px;
  color: #666;
  font-weight: 600;
}

.jd-option-item__price-diff {
  font-size: 11px;
  color: #28a745;
  font-weight: 600;
  margin-top: 2px;
}

.jd-option-item__price-diff.is-negative {
  color: #dc3545;
}

.jd-option-item__price-original {
  font-size: 11px;
  color: #999;
  text-decoration: line-through;
  margin-left: 4px;
}

/* ================================================================
   8. Badges and Labels
   ================================================================ */

.jd-option-item__badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff4757;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.jd-option-item__badge--popular {
  background: #ffa502;
}

.jd-option-item__badge--new {
  background: #2ed573;
}

.jd-option-item__badge--hot {
  background: #ff4757;
}

.jd-option-item__badge--sale {
  background: #ff6348;
}

/* ================================================================
   9. Stock Status Indicator
   ================================================================ */

.jd-option-item__stock {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #28a745;
  border: 2px solid #fff;
}

.jd-option-item__stock--low {
  background: #ffa502;
}

.jd-option-item__stock--out {
  background: #dc3545;
}

.jd-option-item__stock-text {
  font-size: 10px;
  color: #dc3545;
  margin-top: 4px;
  font-weight: 600;
}

/* ================================================================
   10. Out of Stock Overlay
   ================================================================ */

.jd-option-item.is-out-of-stock::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #dc3545;
  transform: rotate(-15deg);
  opacity: 0.7;
}

/* ================================================================
   11. Tooltip
   ================================================================ */

.jd-option-item__tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.jd-option-item__tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.85);
}

.jd-option-item:hover .jd-option-item__tooltip {
  opacity: 1;
}

/* ================================================================
   12. Loading Animation
   ================================================================ */

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

.jd-option-item.is-loading {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  pointer-events: none;
}

/* ================================================================
   13. Selection Animation
   ================================================================ */

@keyframes selectPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(0, 123, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
  }
}

.jd-option-item.just-selected {
  animation: selectPulse 0.4s ease-out;
}

/* ================================================================
   14. Mobile Optimization
   ================================================================ */

@media (max-width: 768px) {
  .jd-option-item {
    padding: 10px 6px;
    min-height: 50px;
  }

  .jd-option-item__name {
    font-size: 11px;
  }

  .jd-option-item__price {
    font-size: 12px;
  }

  .jd-option-item__thumbnail {
    width: 60px;
    height: 60px;
  }

  .jd-option-item--swatch .jd-option-item__swatch {
    width: 32px;
    height: 32px;
  }

  .jd-option-item__badge {
    font-size: 9px;
    padding: 2px 4px;
  }
}

/* ================================================================
   15. Dark Mode Support
   ================================================================ */

@media (prefers-color-scheme: dark) {
  .jd-option-item {
    background: #2c2c2c;
    border-color: #444;
    color: #fff;
  }

  .jd-option-item__name,
  .jd-option-item__price {
    color: #e0e0e0;
  }

  .jd-option-item:hover {
    background: #333;
  }

  .jd-option-item.is-active {
    background: linear-gradient(135deg, #1a3a52 0%, #2c2c2c 100%);
  }

  .jd-configurator__label {
    color: #e0e0e0;
  }
}

/* ================================================================
   16. Print Styles
   ================================================================ */

@media print {
  .jd-option-item {
    border: 1px solid #000;
    page-break-inside: avoid;
  }

  .jd-option-item:not(.is-active) {
    display: none;
  }

  .jd-option-item__badge,
  .jd-option-item__stock {
    display: none;
  }
}

/* ================================================================
   17. Accessibility
   ================================================================ */

.jd-option-item:focus-within {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.jd-option-item input[type="radio"]:focus + * {
  outline: none;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .jd-option-item {
    border-width: 3px;
  }

  .jd-option-item.is-active {
    border-width: 4px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .jd-option-item,
  .jd-option-item__thumbnail img,
  .jd-option-item__swatch {
    transition: none;
  }

  .jd-option-item:hover {
    transform: none;
  }

  .jd-option-item.just-selected {
    animation: none;
  }
}

/* ================================================================
   18. Custom Button Styles - Orange/Yellow Theme
   ================================================================ */

/* ================================================================
   19. Buy Now & Add to Cart Button Layout
   ================================================================ */

/* Button Container */
.jd-actions__buttons {
  width: 100%;
  margin-bottom: 16px;
}

/* All Primary Buttons - Orange Yellow Color - High Priority */
body .btn-primary,
body #compare-total,
body .btn.btn-primary,
#product-category .btn-primary,
#product-category #compare-total,
.container .btn-primary,
.container #compare-total,
#button-buy-now,
.jd-actions__buy-now,
#button-cart,
.jd-actions__cart {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%) !important;
  background-color: #FF9800 !important;
  border: none !important;
  border-color: #FF9800 !important;
  box-shadow: 0 12px 24px rgba(255, 152, 0, 0.35) !important;
  color: #fff !important;
  font-weight: 600 !important;
  transition: all 0.3s ease !important;
}

body .btn-primary:hover,
body .btn-primary:focus,
body #compare-total:hover,
body #compare-total:focus,
#product-category .btn-primary:hover,
#product-category #compare-total:hover,
.container .btn-primary:hover,
.container #compare-total:hover,
#button-buy-now:hover,
.jd-actions__buy-now:hover,
#button-cart:hover,
.jd-actions__cart:hover {
  background: linear-gradient(135deg, #FFB300 0%, #FF9800 100%) !important;
  background-color: #FFB300 !important;
  border-color: #FFB300 !important;
  box-shadow: 0 16px 32px rgba(255, 152, 0, 0.45) !important;
  transform: translateY(-2px) !important;
}

body .btn-primary:active,
body .btn-primary:focus-visible,
body #compare-total:active,
#product-category .btn-primary:active,
#product-category #compare-total:active,
.container .btn-primary:active,
.container #compare-total:active,
#button-buy-now:active,
.jd-actions__buy-now:active,
#button-cart:active,
.jd-actions__cart:active {
  background: linear-gradient(135deg, #F57C00 0%, #E65100 100%) !important;
  background-color: #F57C00 !important;
  border-color: #F57C00 !important;
  transform: translateY(0) !important;
}

/* Quantity increase/decrease buttons - match theme */
.jd-quantity__btn {
  transition: all 0.2s ease;
}

.jd-quantity__btn:hover {
  background: #f8f9fa !important;
  border-color: #FFA500 !important;
  color: #FF8C00 !important;
}

/* Mobile Responsive - Buy Now & Add to Cart */
@media (max-width: 768px) {
  .jd-actions__buttons {
    flex-direction: column;
    gap: 12px !important;
  }
  
  #button-buy-now,
  #button-cart,
  .jd-actions__buy-now,
  .jd-actions__cart {
    width: 100%;
    font-size: 16px !important;
    padding: 14px 20px !important;
  }
  
  .jd-actions__buttons .btn-lg {
    font-size: 16px;
    padding: 14px 20px;
  }
}

/* Tablet view */
@media (min-width: 769px) and (max-width: 991px) {
  #button-buy-now,
  #button-cart {
    font-size: 15px;
    padding: 13px 18px;
  }
}

