/**
 * Modern Poll Widget CSS
 * Styles for the customer-facing poll widget with modern design
 */

/* CSS Variables for easy customization */
:root {
  --pw-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --pw-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.2);
  --pw-radius: 20px;
  --pw-accent: #000000; /* Change to shop brand color if needed */
  --pw-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Main widget container - positioned at bottom right */
.poll-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2147483647; /* Max z-index to ensure it's always on top */
  font-family: var(--pw-font);
  perspective: 1000px;
}

/* Hidden state - slides down and fades out with scale */
.poll-widget-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: var(--pw-transition);
}

/* Visible state - slides up and fades in with scale */
.poll-widget-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: var(--pw-transition);
}

/* Modern glass-effect card container */
.poll-widget-card {
  width: 340px;
  border-radius: 20px;
  overflow: visible;
  position: relative;
  /* Glassmorphism effect */
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(7.3px);
  -webkit-backdrop-filter: blur(7.3px);
}

/* Close Button - Modern with icon */
.poll-widget-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.8);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: #666;
  transition: 0.2s;
  backdrop-filter: blur(4px);
}

.poll-widget-close:hover {
  background: #eee;
  color: #000;
}

/* Header Section */
.poll-header {
  padding: 20px 20px 15px;
  text-align: center;
}

/* Small badge label above question */
.poll-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: #888;
  display: block;
  margin-bottom: 6px;
}

/* Poll question heading */
.poll-question {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: #111;
}

/* Grid Layout for Options */
.poll-options-grid {
  display: flex;
  padding: 0 12px 20px;
  gap: 8px;
  position: relative;
  height: 180px; /* Fixed height for consistent layout */
  overflow: hidden; /* Clip images properly */
}

/* Individual poll option (clickable card) */
.poll-option {
  flex: 1;
  position: relative;
  cursor: pointer;
  border-radius: 16px;
  overflow: hidden;
  transition: var(--pw-transition);
  height: 100%;
  /* Add a transparent border by default to prevent layout shift when selected */
  border: 3px solid transparent;
  /* Use box-sizing to include border in the element's width/height */
  box-sizing: border-box;
}

/* Image wrapper for better control */
.poll-img-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Product image inside option */
.poll-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

/* Hover effect - zoom in on image */
.poll-option:hover .poll-img-wrapper img {
  transform: scale(1.1);
}

/* Dimmed state for non-selected options */
.poll-option.dimmed {
  opacity: 0.5;
  filter: grayscale(0.5);
}

/* Selected state - add accent border */
.poll-option.selected {
  border-color: var(--pw-accent);
}

/* VS Badge - centered between options */
.poll-vs-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  color: #000;
  font-weight: 900;
  font-size: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  z-index: 5;
  pointer-events: none; /* Don't interfere with clicks */
}

/* Text overlay at bottom of image with gradient */
.poll-option-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  padding: 20px 10px 10px;
  text-align: center;
}

/* Product title inside the overlay */
.poll-option-title {
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Checkmark icon for selected state */
.poll-check-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 40px;
  height: 40px;
  background: var(--pw-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Show checkmark when option is selected */
.poll-option.selected .poll-check-icon {
  transform: translate(-50%, -50%) scale(1);
}

/* Thank You Screen */
.poll-thank-you {
  padding: 40px 20px;
  text-align: center;
}

.poll-thank-you h3 {
  margin: 10px 0 5px;
  font-size: 18px;
  color: #111;
}

.poll-thank-you p {
  margin: 0;
  color: #666;
  font-size: 14px;
}

/* Animated Checkmark SVG - centered in thank you screen */
.success-checkmark {
  display: flex;
  justify-content: center;
  align-items: center;
}

.success-checkmark svg {
  width: 50px;
  height: 50px;
}

/* Circle animation */
.checkmark__circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #000;
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

/* Check animation */
.checkmark__check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  stroke: #000;
  stroke-width: 3;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

/* Keyframe for drawing the checkmark */
@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

/* ProductPoll Branding Badge - Offset positioning */
.productpoll-branding-badge {
  position: absolute;
  bottom: 0;
  right: 14px;
  transform: translateY(50%);
  z-index: 1;
}

.productpoll-branding-badge svg {
  height: 18px;
  width: auto;
  display: block;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .poll-widget {
    bottom: 10px;
    right: 10px;
  }

  .poll-widget-card {
    width: calc(100vw - 20px);
    max-width: 340px;
  }

  .poll-question {
    font-size: 16px;
  }

  .poll-options-grid {
    height: 160px;
  }

  .productpoll-branding-badge svg {
    height: 16px;
  }
}
