/* ============================================
   BASE WRAPPER FIX
   ============================================ */
.spi-wrapper {
  position: relative;
  display: block;
  overflow: hidden;
  /* Fixes mysterious gaps/white space under images */
  line-height: 0;
  font-size: 0;
  max-width: 100%; /* Ensures responsive images don't overflow */
}

/* Ensure the image inside fills the wrapper correctly */
/* Ensure the image inside fills the wrapper corresctly */
.spi-wrapper img {
  /* REMOVED: display: block; max-width: 100%; height: auto; */
  /* We want to preserve the original image styles */
}

.pinterest-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  margin-right: 6px;
  vertical-align: middle;
  display: inline-block;
}

/* Base Button */
.spi-btn {
  position: absolute;
  z-index: 999; /* High Z-index to sit on top of everything */
  cursor: pointer;
  line-height: 1; /* Reset line-height for text */
  display: flex;
  align-items: center;
  text-decoration: none !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.9);
  white-space: nowrap; /* Prevents text breaking */
  overflow: hidden; /* Added for shine effect */
}

/* Premium Shine Effect */
.spi-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-20deg);
  z-index: 1;
}

/* ============================================
   POSITIONING (Coordinates relative to Image)
   ============================================ */
.spi-btn.top-left {
  top: 15px;
  left: 15px;
}
.spi-btn.top-right {
  top: 15px;
  right: 15px;
}
.spi-btn.bottom-left {
  bottom: 15px;
  left: 15px;
}
.spi-btn.bottom-right {
  bottom: 15px;
  right: 15px;
}

/* ============================================
   HOVER LOGIC
   ============================================ */
.spi-wrapper:hover .spi-btn,
.spi-wrapper.spi-always-show .spi-btn {
  opacity: 1;
  transform: scale(1);
  animation: spi-breathe 4s ease-in-out infinite;
}

.spi-wrapper:hover .spi-btn::before,
.spi-wrapper.spi-always-show .spi-btn::before {
  animation: spi-shine 4s infinite;
}

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

@keyframes spi-shine {
  0% { left: -150%; }
  20% { left: 150%; }
  100% { left: 150%; }
}

.spi-btn:hover {
  transform: scale(1.05) translateY(-2px) !important;
}

/* ============================================
   DESIGNS
   ============================================ */
/* 1. Red */
.spi-btn.design-1 {
  background-color: #e60023;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 9px 16px;
  border-radius: 24px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.spi-btn.design-1:hover {
  background-color: #ad001b;
}

/* 2. White */
.spi-btn.design-2 {
  background-color: #fff;
  color: #111 !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 9px 16px;
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.spi-btn.design-2:hover {
  background-color: #f0f0f0;
}
.spi-btn.design-2 .pinterest-icon {
  fill: #e60023;
}

/* 3. Dark */
.spi-btn.design-3 {
  background-color: #111;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 9px 16px;
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.spi-btn.design-3:hover {
  background-color: #000;
}

/* 4. Rounded Square */
.spi-btn.design-4 {
  background-color: #e60023;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(230, 0, 35, 0.3);
}
.spi-btn.design-4:hover {
  background-color: #ad001b;
}

/* 5. Glass */
.spi-btn.design-5 {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #e60023 !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 9px 16px;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.spi-btn.design-5:hover {
  background: rgba(255, 255, 255, 1);
}
.spi-btn.design-5 .pinterest-icon {
  fill: #e60023;
}

/* 6. Icon Only */
.spi-btn.design-6 {
  background-color: #e60023;
  color: #fff !important;
  font-size: 0;
  padding: 11px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(230, 0, 35, 0.3);
  width: 40px;
  height: 40px;
  justify-content: center;
}
.spi-btn.design-6:hover {
  background-color: #ad001b;
}
.spi-btn.design-6 .pinterest-icon {
  width: 18px;
  height: 18px;
  margin: 0;
}

/* 7. Outlined */
.spi-btn.design-7 {
  background-color: transparent;
  border: 2px solid #fff;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  font-family: sans-serif;
  padding: 8px 16px;
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}
.spi-btn.design-7:hover {
  background-color: #fff;
  color: #e60023 !important;
}
.spi-btn.design-7:hover .pinterest-icon {
  fill: #e60023;
}

/* 8. Gradient */
.spi-btn.design-8 {
  background: linear-gradient(135deg, #e60023 0%, #c60019 100%);
  color: #fff !important;
  font-size: 14px;
  font-weight: 700;
  font-family: sans-serif;
  padding: 11px 20px;
  border-radius: 28px;
  box-shadow: 0 4px 12px rgba(230, 0, 35, 0.4);
}

/* ============================================
   RECIPE POPUP
   ============================================ */
.spi-recipe-popup {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  padding: 12px;
  z-index: 10000;
  max-width: 350px;
  width: auto;
  transform: translateY(50px) scale(0.95);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  visibility: hidden;
  border: 1px solid rgba(0,0,0,0.05);
}

.spi-recipe-popup.spi-show {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Design Modifiers */
/* 1. Modern Minimalist (Standard) */
.spi-recipe-popup.popup-design-1 {
    background: #ffffff;
    border: 1px solid #f0f0f0;
}

/* 2. Glassmorphism */
.spi-recipe-popup.popup-design-2 {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}
.spi-recipe-popup.popup-design-2 .spi-btn-save {
    background: linear-gradient(135deg, #e60023 0%, #ff4d6d 100%);
    box-shadow: 0 4px 15px rgba(230, 0, 35, 0.3);
}

/* 3. Compact Bubble */
.spi-recipe-popup.popup-design-3 {
    background: #1a1a1a;
    color: #fff;
    border-radius: 50px;
    padding: 8px 10px 8px 8px;
    max-width: 280px;
}
.spi-recipe-popup.popup-design-3 .spi-recipe-popup-img {
    border-radius: 50%;
    width: 45px;
    height: 45px;
}
.spi-recipe-popup.popup-design-3 .spi-recipe-popup-title {
    color: #fff;
    font-size: 13px;
}
.spi-recipe-popup.popup-design-3 .spi-recipe-popup-cta {
    color: #aaa;
    font-size: 11px;
}
.spi-recipe-popup.popup-design-3 .spi-btn-save {
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 12px;
}
.spi-recipe-popup.popup-design-3 .spi-recipe-popup-close {
    background: #333;
    color: #eee;
    border: none;
}

/* Image */
.spi-recipe-popup-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* Content */
.spi-recipe-popup-content {
  flex-grow: 1;
  margin-right: 24px;
}

.spi-recipe-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  margin-bottom: 4px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.spi-recipe-popup-cta {
  font-size: 12px;
  color: #666;
}

/* Save Button (Mini version of main button) */
.spi-recipe-popup .spi-btn-save {
  background-color: #e60023;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.spi-recipe-popup .spi-btn-save:hover {
  background-color: #ad001b;
}

.spi-recipe-popup .pinterest-icon {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  fill: currentColor;
}

/* Close Button */
.spi-recipe-popup-close {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  color: #555;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: all 0.2s;
  font-size: 14px;
  line-height: 1;
}

.spi-recipe-popup-close:hover {
  background: #f0f0f0;
  color: #000;
  transform: scale(1.1);
}

/* Mobile Responsive (Phones & Tablets) */
@media screen and (max-width: 768px) {
  .spi-recipe-popup {
    bottom: 120px; /* Above bottom bars */
    right: 0;
    left: auto;
    width: 50px;
    height: 50px;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 50% !important;
    transform: translateX(120px) rotate(0deg);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: none !important;
  }
  
  .spi-recipe-popup.spi-show {
    transform: translateX(0) rotate(0deg);
  }

  /* Hide textual content to save space */
  .spi-recipe-popup-content {
    display: none;
  }

  /* Make image circular and add spinning animation */
  .spi-recipe-popup-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: spi-spin-delay 8s ease-in-out infinite;
    object-fit: cover;
  }

  @keyframes spi-spin-delay {
    0%, 10% { transform: rotate(0deg); }
    40%, 100% { transform: rotate(360deg); }
  }

  /* Make the save button invisible but cover the entire circle */
  .spi-btn-save {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    padding: 0;
    margin: 0;
    z-index: 10;
  }

  /* Add a tiny Pinterest badge so users know it's for saving */
  .spi-recipe-popup::after {
    content: '';
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 18px;
    height: 18px;
    background: #e60023 url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="%23fff" xmlns="http://www.w3.org/2000/svg"><path d="M12 0C5.373 0 0 5.373 0 12c0 4.99 3.063 9.248 7.35 11.08-.102-.942-.194-2.388.04-3.416.212-.924 1.366-5.786 1.366-5.786s-.348-.696-.348-1.724c0-1.616.937-2.822 2.104-2.822.992 0 1.472.745 1.472 1.638 0 .998-.636 2.49-0.964 3.872-.274 1.156.58 2.1 1.72 2.1 2.064 0 3.65-2.176 3.65-5.312 0-2.78-1.998-4.726-4.846-4.726-3.53 0-5.602 2.648-5.602 5.386 0 1.066.41 2.208.922 2.828.102.122.116.23.086.354-.094.39-.304 1.232-.346 1.398-.054.22-.174.266-.4.16-1.492-.694-2.424-2.87-2.424-4.622 0-3.766 2.736-7.222 7.892-7.222 4.146 0 7.37 2.954 7.37 6.9 0 4.114-2.594 7.426-6.196 7.426-1.21 0-2.346-.628-2.736-1.37l-.744 2.836c-.27.998-1.002 2.248-1.492 3.01C9.66 23.904 10.8 24 12 24c6.627 0 12-5.373 12-12S16.627 0 12 0z"/></svg>') center center no-repeat;
    background-size: 10px;
    border-radius: 50%;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    pointer-events: none;
  }

  .spi-recipe-popup-close {
    display: none;
  }
}
