/* Format Card Selection Styles - Enhanced Version */
.ef-format-cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 0;
  width: 100%;
  padding-bottom: 4px;
}

.ef-format-card {
  background: #fff;
  border: 2px solid #e1e5e9;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  flex: 0 0 200px;
  min-width: 180px;
}

.ef-format-card:hover {
  border-color: #039a47;
  box-shadow: 0 8px 25px rgba(3, 154, 71, 0.12);
  transform: translateY(-3px);
}

.ef-format-card:active {
  transform: translateY(-1px);
  transition: transform 0.1s;
}

.ef-format-card.selected {
  border-color: #039a47;
  background: linear-gradient(135deg, #f8fffe 0%, #eefff5 100%);
  box-shadow: 0 6px 20px rgba(3, 154, 71, 0.15);
  transform: translateY(-2px);
}

.ef-format-card-inner {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: 100%;
  justify-content: space-between;
}

.ef-format-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 12px;
  margin-bottom: 16px;
  color: #64748b;
  transition: all 0.3s ease;
  position: relative;
}

/* Package/Box SVG Icon for single items */
.ef-format-card .ef-format-image svg {
  width: 32px;
  height: 32px;
}

.ef-format-card:hover .ef-format-image {
  background: linear-gradient(135deg, #e6fffa 0%, #b3f5d1 100%);
  color: #039a47;
  transform: scale(1.05);
}

.ef-format-card.selected .ef-format-image {
  background: linear-gradient(135deg, #039a47 0%, #025a32 100%);
  color: #fff;
  transform: scale(1.05);
  padding: 5px;
}

.ef-format-details {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ef-format-quantity {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1.2;
}

.ef-format-measure {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.ef-format-price {
  font-size: 16px;
  font-weight: 700;
  color: #039a47;
  background: rgba(3, 154, 71, 0.1);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  margin-top: auto;
}

.ef-format-check {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  background: #039a47;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ef-format-card.selected .ef-format-check {
  opacity: 1;
  transform: scale(1);
}

.ef-format-check svg {
  width: 14px;
  height: 14px;
  fill: white;
}

/* Selection pulse animation */
.ef-format-card.selected::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(3, 154, 71, 0.1);
  transform: translate(-50%, -50%);
  animation: pulseSelection 0.6s ease-out;
}

@keyframes pulseSelection {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

/* Title styling */
.rg-format-selection h4 {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
  margin-top: 0;
}

/* Hide the original hidden input */
.rg-format-selection .select-js-prodotto-qta {
  display: none !important;
}

/* Loading state */
.ef-format-card.loading {
  pointer-events: none;
  opacity: 0.6;
  position: relative;
}

.ef-format-card.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #039a47;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
  z-index: 10;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .ef-format-cards-container {
    gap: 12px;
    margin: 12px 0 20px 0;
  }

  .ef-format-card {
    flex: 0 0 160px;
    min-width: 150px;
    min-height: 120px;
  }

  .ef-format-card-inner {
    padding: 10px;
  }

  .ef-format-image {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
  }

  .ef-format-quantity {
    font-size: 13px;
  }

  .ef-format-price {
    font-size: 14px;
  }

  .rg-format-selection h4 {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .ef-format-cards-container {
    gap: 8px;
    flex-wrap: wrap;
  }

  .ef-format-card {
    flex: 0 0 140px;
    min-width: 130px;
    min-height: 110px;
  }

  .ef-format-card-inner {
    padding: 8px;
    text-align: center;
  }

  .ef-format-image {
    width: 28px;
    height: 28px;
    margin: 0 auto 6px auto;
  }

  .ef-format-details {
    text-align: center;
  }

  .ef-format-check {
    top: 6px;
    right: 6px;
  }

  .ef-format-price {
    font-size: 13px;
    font-weight: 700;
  }
}

/* Enhanced states for better feedback */
.ef-format-card:focus {
  outline: none;
  border-color: #039a47;
  box-shadow: 0 0 0 3px rgba(3, 154, 71, 0.1);
}

.ef-format-card[aria-selected="true"] {
  border-color: #039a47;
}

/* Improved accessibility */
.ef-format-card[role="button"]:focus-visible {
  outline: 2px solid #039a47;
  outline-offset: 2px;
}

/* Better spacing in the container */
.rg-format-selection {
  margin: 5px 0 0 0;
}

/* Error state (if needed) */
.ef-format-card.error {
  border-color: #dc2626;
  background: #fef2f2;
}

.ef-format-card.error:hover {
  border-color: #dc2626;
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.12);
}

/* Enhanced Quantity Input Styling */
.rg-input {
  margin-top: 16px;
}

.rg-input h4 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-family: inherit;
}

.ef-quantity-container {
  position: relative;
  display: inline-block;
  width: auto;
}

.js-prodotto-qta {
  background: #fff;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  width: 100px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

.js-prodotto-qta::-webkit-outer-spin-button,
.js-prodotto-qta::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.js-prodotto-qta:hover {
  border-color: #039a47;
  box-shadow: 0 4px 12px rgba(3, 154, 71, 0.08);
}

.js-prodotto-qta:focus {
  border-color: #039a47;
  box-shadow: 0 0 0 3px rgba(3, 154, 71, 0.1), 0 4px 12px rgba(3, 154, 71, 0.08);
  outline: none;
}

.js-prodotto-qta:disabled {
  background-color: #f5f5f5;
  border-color: #e1e5e9;
  color: #999;
  cursor: not-allowed;
}

/* Quantity Controls Enhancement */
.ef-quantity-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ef-quantity-controls {
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ef-quantity-controls:hover {
  border-color: #039a47;
  box-shadow: 0 4px 12px rgba(3, 154, 71, 0.08);
}

.ef-quantity-controls .js-prodotto-qta {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  flex: 1;
  min-width: 60px;
}

.ef-quantity-controls .js-prodotto-qta:hover,
.ef-quantity-controls .js-prodotto-qta:focus {
  border: none;
  box-shadow: none;
}

.ef-quantity-btn {
  background: #f8f9fa;
  border: none;
  padding: 8px 12px;
  font-size: 18px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 44px;
}

.ef-quantity-btn:hover {
  background: #039a47;
  color: #fff;
}

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

.ef-quantity-btn:disabled {
  background: #f5f5f5;
  color: #ccc;
  cursor: not-allowed;
}

.ef-quantity-btn:disabled:hover {
  background: #f5f5f5;
  color: #ccc;
  transform: none;
}

/* Alternative simple style */
.ef-quantity-simple .js-prodotto-qta {
  border-radius: 8px;
  border: 1px solid #ddd;
  padding: 10px 14px;
  font-size: 15px;
}

/* Responsive adjustments for quantity input */
@media (max-width: 768px) {
  .js-prodotto-qta {
    width: 80px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .ef-quantity-controls {
    border-radius: 10px;
  }

  .ef-quantity-btn {
    padding: 6px 10px;
    min-width: 36px;
    height: 40px;
    font-size: 16px;
  }

  .rg-input h4 {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .js-prodotto-qta {
    width: 70px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .ef-quantity-controls {
    border-radius: 8px;
  }

  .ef-quantity-btn {
    padding: 5px 8px;
    min-width: 32px;
    height: 36px;
    font-size: 14px;
  }

  .ef-quantity-wrapper {
    gap: 8px;
  }
}

/* Promo Highlight for Multiple Items */
.ef-format-card.ef-promo-highlight {
  position: relative;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.2);
  animation: promoGlow 2s ease-in-out infinite;
}

.ef-format-card.ef-promo-highlight:before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  /* background: linear-gradient(45deg, #f59e0b, #fbbf24, #f97316, #ea580c); */
  background-size: 300% 300%;
  border-radius: inherit;
  z-index: -1;
  animation: gradientShift 3s ease infinite;
}

.ef-format-card.ef-promo-highlight:after {
  content: "PROMO";
  position: absolute;
  top: 12px;
  right: 6px;
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 8px;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
  animation: promoBadgePulse 1.5s ease-in-out infinite;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: auto;
  height: auto;
}

.ef-format-card.ef-promo-highlight .ef-format-image {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: white;
  animation: pulseIcon 2s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.ef-format-card.ef-promo-highlight .ef-format-image svg {
  color: white;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

.ef-format-card.ef-promo-highlight .ef-format-details {
  position: relative;
}

.ef-format-card.ef-promo-highlight .ef-format-quantity {
  color: #ea580c;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ef-format-card.ef-promo-highlight .ef-format-measure {
  color: #92400e;
  font-weight: 600;
}

.ef-format-card.ef-promo-highlight .ef-format-price {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
  animation: priceGlow 2.5s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.ef-format-card.ef-promo-highlight .ef-format-price:before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 3s ease-in-out infinite;
}

.ef-format-card.ef-promo-highlight:hover {
  border-color: #f97316;
  box-shadow: 0 8px 30px rgba(245, 158, 11, 0.35);
  transform: translateY(-4px) scale(1.03);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.ef-format-card.ef-promo-highlight:hover:after {
  animation: promoBadgePulse 0.8s ease-in-out infinite;
}

.ef-format-card.ef-promo-highlight.selected {
  /* background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); */
  border-color: #039a47;
  box-shadow: 0 8px 35px rgba(3, 154, 71, 0.3);
}

.ef-format-card.ef-promo-highlight.selected:before {
  /* background: linear-gradient(45deg, #039a47, #10b981, #16a34a, #039a47); */
}

.ef-format-card.ef-promo-highlight.selected .ef-format-image {
  /* background: linear-gradient(135deg, #039a47 0%, #16a34a 100%); */
}

.ef-format-card.ef-promo-highlight.selected:after {
  content: "PROMO";
  top: 45px;
  left: auto;
  right: 6px;
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  z-index: 5;
  width: 48px;
  height: 20px;
  transform: translateY(0);
  animation: promoBadgeSlideIn 0.3s ease-out forwards;
}

/* Keyframe Animations */
@keyframes promoGlow {
  0%,
  100% {
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.2);
  }
  50% {
    box-shadow: 0 6px 25px rgba(245, 158, 11, 0.35),
      0 0 0 2px rgba(245, 158, 11, 0.15);
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes pulseIcon {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes priceGlow {
  0%,
  100% {
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
  }
  50% {
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4),
      0 0 0 1px rgba(220, 38, 38, 0.2);
  }
}

@keyframes promoBadgePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  50%,
  100% {
    left: 100%;
  }
}

/* Enhanced sparkle effect */
.ef-format-card.ef-promo-highlight:hover:before {
  animation: gradientShift 1.5s ease infinite;
}

/* Reduce animations on mobile for performance */
@media (max-width: 768px) {
  .ef-format-card.ef-promo-highlight {
    animation-duration: 3s;
  }

  .ef-format-card.ef-promo-highlight .ef-format-image {
    animation-duration: 3s;
  }

  .ef-format-card.ef-promo-highlight .ef-format-price {
    animation-duration: 3.5s;
  }

  .ef-format-card.ef-promo-highlight:after {
    font-size: 8px;
    padding: 2px 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ef-format-card.ef-promo-highlight,
  .ef-format-card.ef-promo-highlight .ef-format-image,
  .ef-format-card.ef-promo-highlight .ef-format-price,
  .ef-format-card.ef-promo-highlight:before,
  .ef-format-card.ef-promo-highlight:after,
  .ef-format-card.ef-promo-highlight .ef-format-price:before {
    animation: none;
  }
}

@keyframes promoBadgeSlideIn {
  0% {
    transform: translateY(-10%);
    /* opacity: 0; */
  }
  100% {
    transform: translateY(0);
    /* opacity: 1; */
  }
}

.rg-inputs > div {
  gap: 5px;
  width: 100%;
}

.rg-input {
  margin-top: 5px;
}

.rg-inputs {
  gap: 10px;
}

.rg-prod-single-img {
  width: 40%;
}
