/* =========================================
   POLIOT UPSELL — UX/Premium CSS (OPTIMIZED)
   - Performance migliorata con CSS custom properties
   - Accessibilità potenziata
   - Animazioni GPU-accelerated
   ========================================= */

:root {
  /* Colors */
  --poliot-bg-primary: #fafafa;
  --poliot-bg-hover: #f6f6f9;
  --poliot-bg-added: #f0faf0;
  --poliot-border-light: #ececf1;
  --poliot-border-medium: #ededf2;
  --poliot-border-hover: #e6e6ee;
  --poliot-text-primary: #222;
  --poliot-text-secondary: #6a6a6a;
  --poliot-text-tertiary: #5a5a5a;
  
  /* Spacing */
  --poliot-gap-xs: 4px;
  --poliot-gap-sm: 6px;
  --poliot-gap-md: 10px;
  --poliot-gap-lg: 12px;
  --poliot-gap-xl: 14px;
  
  /* Border radius */
  --poliot-radius-sm: 10px;
  --poliot-radius-md: 12px;
  --poliot-radius-lg: 14px;
  --poliot-radius-full: 999px;
  
  /* Transitions */
  --poliot-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --poliot-transition-medium: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   BASE WRAPPERS
   ========================================= */

.poliot-upsell-inline,
.poliot-upsell-minicart-wrap,
.poliot-upsell-cart-wrap,
.poliot-upsell-checkout-wrap {
  font-size: 14px;
  line-height: 1.4;
  color: var(--poliot-text-primary);
}

/* =========================================
   SPRAY PILL COMPONENT
   ========================================= */

.poliot-upsell-pill {
  display: flex;
  align-items: flex-start;
  gap: var(--poliot-gap-md);
  padding: var(--poliot-gap-lg) var(--poliot-gap-xl);
  margin: 0;
  border-radius: var(--poliot-radius-md);
  background: var(--poliot-bg-primary);
  border: 1px solid var(--poliot-border-light);
  width: 100%;
  box-sizing: border-box;
  transition: 
    background var(--poliot-transition-fast),
    border-color var(--poliot-transition-fast),
    transform var(--poliot-transition-fast);
  will-change: background, border-color;
}

.poliot-upsell-pill:hover {
  background: var(--poliot-bg-hover);
  border-color: var(--poliot-border-hover);
}

/* Icon container */
.poliot-upsell-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--poliot-radius-full);
  background: #fff;
  border: 1px solid var(--poliot-border-medium);
  margin-top: 2px;
}

.poliot-upsell-icon .material-symbols-outlined {
  font-size: 18px;
  line-height: 1;
}

/* =========================================
   INTERACTIVE LABEL
   ========================================= */

.poliot-upsell-label {
  display: flex;
  align-items: flex-start;
  gap: var(--poliot-gap-md);
  width: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Checkbox styling */
.poliot-upsell-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Enhanced focus states for accessibility */
.poliot-upsell-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--poliot-text-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================
   TEXT CONTENT
   ========================================= */

.poliot-upsell-text {
  display: flex;
  flex-direction: column;
  gap: var(--poliot-gap-xs);
  width: 100%;
  min-width: 0;
}

.poliot-upsell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--poliot-gap-md);
  flex-wrap: wrap;
}

.poliot-upsell-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1px;
  min-width: 0;
  word-break: break-word;
}

.poliot-upsell-price {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.poliot-upsell-cta {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.poliot-upsell-hint {
  font-size: 12px;
  color: var(--poliot-text-secondary);
  line-height: 1.4;
}

/* =========================================
   ADDED STATE FEEDBACK
   ========================================= */

.poliot-upsell-label.is-added,
.poliot-gift-label.is-added {
  background: var(--poliot-bg-added);
  border-radius: var(--poliot-radius-sm);
  padding: 8px;
  margin: -8px;
  transition: background var(--poliot-transition-medium);
  animation: poliot-pulse 0.3s ease-out;
}

@keyframes poliot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.poliot-upsell-label.is-added .poliot-upsell-cta::after {
  content: " ✓ Aggiunto";
  font-weight: 700;
  margin-left: 6px;
}

/* =========================================
   WRAPPER SPACING
   ========================================= */

.poliot-upsell-minicart-wrap,
.poliot-upsell-cart-wrap,
.poliot-upsell-checkout-wrap {
  margin: var(--poliot-gap-lg) 0;
}

/* =========================================
   PDP — GIFT BOX SECTION
   ========================================= */

.poliot-upsell-inline {
  display: flex;
  flex-direction: column;
  gap: var(--poliot-gap-md);
  margin: 15px 0 10px;
  padding: var(--poliot-gap-xl);
  border-radius: var(--poliot-radius-lg);
  background: #fbfbfb;
  border: 1px solid var(--poliot-border-medium);
}

.poliot-upsell-legend {
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  line-height: 1.3;
}

.poliot-upsell-subtitle {
  font-size: 12px;
  color: var(--poliot-text-tertiary);
  margin: 0 0 4px;
  line-height: 1.4;
}

/* Gift options stack */
.poliot-gift-stack {
  display: flex;
  flex-direction: column;
  gap: var(--poliot-gap-lg);
}

/* =========================================
   GIFT ROW LAYOUT (image + text)
   ========================================= */

.poliot-gift-row {
  display: flex;
  align-items: flex-start;
  gap: var(--poliot-gap-lg);
}

/* Image column */
.poliot-gift-media {
  flex-shrink: 0;
}

/* Image trigger button */
.poliot-kit-image-trigger {
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
  display: block;
  transition: transform var(--poliot-transition-fast);
  will-change: transform;
}

.poliot-kit-image-trigger:hover {
  transform: scale(1.05);
}

.poliot-kit-image-trigger:focus-visible {
  outline: 2px solid var(--poliot-text-primary);
  outline-offset: 2px;
  border-radius: var(--poliot-radius-sm);
}

/* Thumbnail image */
.poliot-kit-thumb {
  display: block;
  width: 72px;
  height: auto;
  border-radius: var(--poliot-radius-sm);
  border: 1px solid #e8e8ee;
  background: #fff;
  object-fit: cover;
}

/* =========================================
   GIFT LABEL & TEXT
   ========================================= */

.poliot-gift-label {
  display: flex;
  align-items: flex-start;
  gap: var(--poliot-gap-md);
  width: 100%;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.poliot-gift-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.poliot-gift-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--poliot-text-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

.poliot-gift-text {
  display: flex;
  flex-direction: column;
  gap: var(--poliot-gap-sm);
  width: 100%;
  min-width: 0;
}

.poliot-gift-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--poliot-gap-md);
  flex-wrap: wrap;
}

.poliot-gift-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Limited edition badge */
.poliot-badge-limited {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color: #fff;
  border-radius: 4px;
  line-height: 1.2;
}

.poliot-gift-price {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.poliot-gift-hint {
  font-size: 12px;
  color: #606060;
  line-height: 1.5;
}

.poliot-gift-hint small {
  color: #7a7a7a;
  display: block;
  margin-top: 2px;
}

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

.poliot-kit-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  box-sizing: border-box;
}

.poliot-kit-lightbox.is-visible {
  display: flex;
  animation: poliot-fadeIn 0.2s ease-out;
}

@keyframes poliot-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.poliot-kit-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: poliot-backdropFade 0.2s ease-out;
}

@keyframes poliot-backdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.poliot-kit-lightbox__content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  margin: 0;
  z-index: 1;
  animation: poliot-scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes poliot-scaleIn {
  from { 
    opacity: 0;
    transform: scale(0.9);
  }
  to { 
    opacity: 1;
    transform: scale(1);
  }
}

.poliot-kit-lightbox__img {
  max-width: 100%;
  max-height: 86vh;
  display: block;
  border-radius: var(--poliot-radius-lg);
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Caption */
.poliot-kit-caption {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Close button */
.poliot-kit-lightbox__close {
  position: absolute;
  top: -12px;
  right: -12px;
  border: none;
  border-radius: var(--poliot-radius-full);
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  background: #fff;
  color: var(--poliot-text-primary);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  transition: transform var(--poliot-transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.poliot-kit-lightbox__close:hover {
  transform: scale(1.1);
}

.poliot-kit-lightbox__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* =========================================
   THEME COMPATIBILITY
   ========================================= */

.woocommerce div.product .poliot-upsell-inline {
  margin-top: 10px;
}

.woocommerce div.product form.cart .poliot-upsell-inline {
  margin-bottom: var(--poliot-gap-lg);
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */

@media (max-width: 768px) {
  .poliot-upsell-header,
  .poliot-gift-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--poliot-gap-xs);
  }
  
  .poliot-upsell-price,
  .poliot-gift-price {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .poliot-kit-thumb {
    width: 62px;
  }
  
  .poliot-upsell-inline {
    padding: var(--poliot-gap-lg);
  }
  
  .poliot-gift-row {
    gap: var(--poliot-gap-md);
  }
  
  .poliot-kit-lightbox {
    padding: 10px;
  }
  
  .poliot-kit-lightbox__close {
    top: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    font-size: 20px;
  }
}

/* =========================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .poliot-upsell-pill,
  .poliot-upsell-inline {
    border-width: 2px;
  }
  
  .poliot-kit-thumb {
    border-width: 2px;
  }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
  :root {
    --poliot-bg-primary: #1a1a1a;
    --poliot-bg-hover: #252525;
    --poliot-border-light: #333;
    --poliot-border-medium: #404040;
    --poliot-text-primary: #e0e0e0;
    --poliot-text-secondary: #999;
  }
}

/* =========================================
   PRINT STYLES
   ========================================= */

@media print {
  .poliot-kit-lightbox,
  .poliot-kit-image-trigger {
    display: none !important;
  }
}