/* ========================================
   WooCommerce Flash Sale Popup Styles
   Version: 1.0.0
   ======================================== */

:root {
  --sp-primary: #4A90E2;
  --sp-primary-hover: #357ABD;
  --sp-secondary: #F5F7FA;
  --sp-text: #2C3E50;
  --sp-overlay: rgba(0, 0, 0, 0.55);
  --sp-bg: #FFFFFF;
  --sp-radius: 16px;
  --sp-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --sp-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Overlay */
.sp-overlay {
  position: fixed;
  inset: 0;
  background: var(--sp-overlay);
  backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.4s ease;
  display: none;
}
.sp-overlay.active { opacity: 1; }

/* Popup Container */
.sp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: 92%;
  max-width: 900px;
  background: var(--sp-bg);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
  z-index: 99999;
  display: none;
  overflow: hidden;
  font-family: var(--sp-font);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.sp-popup.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Slide Up Animation */
@keyframes spSlideUp {
  from { transform: translate(-50%, 40%) scale(0.9); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.sp-popup.animate-slideUp.active {
  animation: spSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Fade Out */
@keyframes spFadeOut {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}
.sp-popup.closing {
  animation: spFadeOut 0.3s ease forwards;
}

/* Layout */
.sp-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 480px;
}

/* Image Side */
.sp-image-col {
  position: relative;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sp-image-col img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sp-image-placeholder {
  text-align: center;
  color: #8898aa;
  padding: 2rem;
}
.sp-image-placeholder svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* Content Side */
.sp-content-col {
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

/* Close Button */
.sp-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
  color: #666;
}
.sp-close:hover {
  background: rgba(0,0,0,0.12);
  transform: rotate(90deg);
}
.sp-close svg { width: 18px; height: 18px; }

/* Typography */
.sp-headline {
  font-size: 2rem;
  font-weight: 800;
  color: var(--sp-primary);
  margin: 0 0 0.25rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.sp-subheadline {
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--sp-text);
  margin: 0 0 0.75rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.sp-description {
  display: inline-block;
  background: var(--sp-secondary);
  color: var(--sp-primary);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.35rem 1rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}
.sp-fine-print {
  font-size: 0.85rem;
  color: #8898aa;
  margin-bottom: 1.5rem;
}

/* Urgency */
.sp-urgency {
  font-size: 0.8rem;
  color: #e74c3c;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  animation: spPulse 2s infinite;
}
@keyframes spPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Countdown */
.sp-countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  max-width: 320px;
}
.sp-countdown-item {
  background: var(--sp-secondary);
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.04);
}
.sp-countdown-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--sp-text);
  display: block;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sp-countdown-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8898aa;
  margin-top: 0.35rem;
  font-weight: 600;
}

/* Form */
.sp-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sp-input-wrap {
  position: relative;
}
.sp-input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 2px solid #e1e8ed;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--sp-text);
  transition: all 0.2s ease;
  background: #fff;
  box-sizing: border-box;
}
.sp-input:focus {
  outline: none;
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}
.sp-input::placeholder { color: #a0aec0; }
.sp-input.error { border-color: #e74c3c; }
.sp-error-msg {
  color: #e74c3c;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: none;
}
.sp-error-msg.visible { display: block; }

/* CTA Button */
.sp-cta {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--sp-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(74, 144, 226, 0.35);
}
.sp-cta:hover {
  background: var(--sp-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}
.sp-cta:active { transform: translateY(0); }
.sp-cta:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.sp-cta-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spSpin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
.sp-cta.loading .sp-cta-spinner { display: inline-block; }
@keyframes spSpin { to { transform: rotate(360deg); } }

/* Dismiss */
.sp-dismiss {
  margin-top: 1rem;
  text-align: center;
}
.sp-dismiss-btn {
  background: none;
  border: none;
  color: var(--sp-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  font-family: inherit;
  transition: color 0.2s;
}
.sp-dismiss-btn:hover { color: var(--sp-primary-hover); }
.sp-dismiss-sub {
  font-size: 0.75rem;
  color: #a0aec0;
  margin-top: 0.25rem;
}

/* Success State */
.sp-success {
  display: none;
  text-align: center;
  padding: 1rem 0;
}
.sp-success.active { display: block; }
.sp-success-icon {
  width: 64px;
  height: 64px;
  background: #d4edda;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: #28a745;
}
.sp-success-headline {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--sp-text);
  margin-bottom: 0.5rem;
}
.sp-success-message {
  color: #666;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.sp-coupon-box {
  background: linear-gradient(135deg, #f5f7fa, #eef2f7);
  border: 2px dashed var(--sp-primary);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.sp-coupon-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8898aa;
  margin-bottom: 0.25rem;
}
.sp-coupon-code {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--sp-primary);
  letter-spacing: 0.1em;
  font-family: 'Courier New', monospace;
  user-select: all;
  cursor: pointer;
}
.sp-copy-hint {
  font-size: 0.75rem;
  color: #8898aa;
  margin-top: 0.5rem;
}

/* Focus Trap Indicator */
.sp-popup:focus { outline: none; }

/* ========================================
   MOBILE RESPONSIVE (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
  .sp-popup {
    width: 96%;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 14px;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.92);
  }
  .sp-popup.active {
    transform: translate(-50%, -50%) scale(1);
  }

  .sp-inner {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  /* Image becomes a compact banner on top */
  .sp-image-col {
    min-height: 160px;
    max-height: 200px;
    order: 1;
  }
  .sp-image-col img {
    object-fit: cover;
    object-position: center top;
  }

  .sp-content-col {
    padding: 1.5rem 1.25rem 1.25rem;
    order: 2;
  }

  .sp-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  .sp-headline {
    font-size: 1.35rem;
    margin-bottom: 0.15rem;
  }
  .sp-subheadline {
    font-size: 1.85rem;
    margin-bottom: 0.5rem;
  }
  .sp-description {
    font-size: 0.85rem;
    padding: 0.3rem 0.85rem;
  }
  .sp-fine-print {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .sp-urgency {
    font-size: 0.75rem;
    margin-bottom: 1rem;
  }

  .sp-countdown {
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    max-width: 100%;
  }
  .sp-countdown-item {
    padding: 0.6rem 0.25rem;
    border-radius: 8px;
  }
  .sp-countdown-number {
    font-size: 1.35rem;
  }
  .sp-countdown-label {
    font-size: 0.6rem;
    margin-top: 0.25rem;
  }

  .sp-form {
    gap: 0.65rem;
  }
  .sp-input {
    padding: 0.85rem 1rem;
    font-size: 16px; /* Prevents iOS zoom on focus */
    border-radius: 10px;
  }
  .sp-cta {
    padding: 0.95rem 1.25rem;
    font-size: 1rem;
    min-height: 48px; /* Better touch target */
    border-radius: 10px;
  }

  .sp-dismiss {
    margin-top: 0.75rem;
  }
  .sp-dismiss-btn {
    font-size: 0.85rem;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
  }

  .sp-success-headline {
    font-size: 1.5rem;
  }
  .sp-success-message {
    font-size: 0.9rem;
  }
  .sp-coupon-code {
    font-size: 1.25rem;
  }

  /* Landscape phones: side-by-side but smaller */
  @media (max-height: 500px) and (orientation: landscape) {
    .sp-popup {
      max-height: 95vh;
    }
    .sp-image-col {
      min-height: 100px;
      max-height: 140px;
    }
    .sp-content-col {
      padding: 1rem 1.25rem;
    }
  }
}

/* ========================================
   SMALL MOBILE (max-width: 380px)
   ======================================== */
@media (max-width: 380px) {
  .sp-popup {
    width: 98%;
    border-radius: 12px;
  }
  .sp-content-col {
    padding: 1.25rem 1rem 1rem;
  }
  .sp-headline {
    font-size: 1.2rem;
  }
  .sp-subheadline {
    font-size: 1.6rem;
  }
  .sp-countdown-number {
    font-size: 1.15rem;
  }
  .sp-countdown-label {
    font-size: 0.55rem;
  }
  .sp-cta {
    font-size: 0.95rem;
    padding: 0.85rem 1rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .sp-popup, .sp-overlay, .sp-close, .sp-cta, .sp-input {
    transition: none !important;
    animation: none !important;
  }
}

/* Print */
@media print {
  .sp-overlay, .sp-popup { display: none !important; }
}
