/**
 * Flowpast Email Gating Styles
 * 
 * Handles:
 * - Gated vs Unlocked states
 * - Blur overlay for implementation guides
 * - Email popup modal
 * - Button state changes
 */

/* ============================================
   GATED STATE - Content is blurred/locked
   ============================================ */

/* Implementation Guide - Show Step 1, Blur Rest */
body.flowpast-gated .implementation-gated-section {
  position: relative;
}

body.flowpast-gated .implementation-step-1 {
  /* Step 1 always visible */
}

body.flowpast-gated .implementation-steps-locked {
  position: relative;
  filter: blur(6px);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* Blur Overlay Container */
.flowpast-blur-overlay {
  position: relative;
}

body.flowpast-gated .flowpast-blur-overlay::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.8) 30%,
    rgba(255, 255, 255, 0.95) 100%
  );
  z-index: 5;
  pointer-events: none;
}

/* Unlock CTA Overlay */
.flowpast-unlock-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  padding: 30px 40px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid #e5e7eb;
}

body.flowpast-unlocked .flowpast-unlock-overlay {
  display: none;
}

body.flowpast-unlocked .implementation-steps-locked {
  filter: none;
  user-select: auto;
  pointer-events: auto;
}

.flowpast-unlock-overlay h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1f2937;
}

.flowpast-unlock-overlay p {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #6b7280;
}

.flowpast-unlock-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: #04aa6d;
  color: #ffffff !important;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.flowpast-unlock-btn:hover {
  background: #059862;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(4, 170, 109, 0.3);
}

/* ============================================
   UNLOCKED STATE - Content is visible
   ============================================ */

body.flowpast-unlocked .flowpast-blur-overlay::before {
  display: none;
}

/* ============================================
   BUTTON STATES - Use Template vs Download
   ============================================ */

/* Gated State: Show "Use Template" / "Use Prompt" */
body.flowpast-gated .btn-when-unlocked {
  display: none !important;
}

body.flowpast-gated .btn-when-gated {
  display: inline-flex !important;
}

/* Unlocked State: Show "Download n8n" / "Copy Prompt" */
body.flowpast-unlocked .btn-when-unlocked {
  display: inline-flex !important;
}

body.flowpast-unlocked .btn-when-gated {
  display: none !important;
}

/* ============================================
   EMAIL POPUP MODAL
   ============================================ */

.flowpast-email-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: flowpast-fadeIn 0.2s ease;
}

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

.flowpast-popup-content {
  background: #ffffff;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: flowpast-slideUp 0.3s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.flowpast-popup-content .wpforms-head-container {
  display: none !important;
}

@keyframes flowpast-slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #6b7280;
  transition: all 0.2s ease;
  z-index: 10;
}

.popup-close:hover {
  background: #e5e7eb;
  color: #1f2937;
}

/* Popup Header */
.popup-header {
  padding: 32px 32px 0;
  text-align: center;
}

.popup-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #04aa6d 0%, #059862 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
}

.popup-title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px 0;
}

.popup-subtitle {
  font-size: 15px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

/* Popup Benefits */
.popup-benefits {
  padding: 20px 32px;
}

.popup-benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.popup-benefit-item:last-child {
  margin-bottom: 0;
}

.popup-benefit-check {
  width: 20px;
  height: 20px;
  background: #d1fae5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.popup-benefit-check svg {
  width: 12px;
  height: 12px;
  color: #059669;
}

.popup-benefit-text {
  font-size: 14px;
  color: #374151;
  line-height: 1.4;
}

/* Popup Form Section */
.popup-form-section {
  padding: 0 32px 32px;
}

/* WPForms Styling Override */
.popup-form-section .wpforms-container {
  margin: 0 !important;
}

.popup-form-section .wpforms-field {
  margin-bottom: 16px !important;
}

.popup-form-section .wpforms-field-label {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #374151 !important;
  margin-bottom: 6px !important;
}

.popup-form-section .wpforms-field input[type="email"],
.popup-form-section .wpforms-field input[type="text"] {
  width: 100% !important;
  padding: 14px 16px !important;
  border: 2px solid #e5e7eb !important;
  border-radius: 8px !important;
  font-size: 15px !important;
  transition: border-color 0.2s ease !important;
}

.popup-form-section .wpforms-field input:focus {
  outline: none !important;
  border-color: #04aa6d !important;
  box-shadow: 0 0 0 3px rgba(4, 170, 109, 0.1) !important;
}

.popup-form-section .wpforms-field-checkbox ul {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.popup-form-section .wpforms-field-checkbox li {
  margin-bottom: 8px !important;
}

.popup-form-section .wpforms-field-checkbox input[type="checkbox"] {
  margin-right: 8px !important;
}

.popup-form-section .wpforms-submit-container {
  margin-top: 20px !important;
}

.popup-form-section .wpforms-submit {
  width: 100% !important;
  padding: 16px 24px !important;
  background: #04aa6d !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 8px !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.popup-form-section .wpforms-submit:hover {
  background: #059862 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(4, 170, 109, 0.3) !important;
}

/* Popup Footer */
.popup-footer {
  padding: 16px 32px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  border-radius: 0 0 16px 16px;
}

.popup-footer p {
  font-size: 12px;
  color: #9ca3af;
  margin: 0;
}

.popup-footer a {
  color: #6b7280;
  text-decoration: underline;
}

/* ============================================
   SUCCESS STATE (After Email Submit)
   ============================================ */

.popup-success-section {
  display: none;
  padding: 40px 32px;
  text-align: center;
}

.popup-success-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 40px;
}

.popup-success-title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 8px 0;
}

.popup-success-subtitle {
  font-size: 15px;
  color: #6b7280;
  margin: 0 0 24px 0;
}

.popup-success-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-success-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border: none;
}

.popup-success-btn-primary {
  background: #04aa6d;
  color: #ffffff !important;
}

.popup-success-btn-primary:hover {
  background: #059862;
  transform: translateY(-2px);
}

.popup-success-btn-secondary {
  background: #f3f4f6;
  color: #374151 !important;
}

.popup-success-btn-secondary:hover {
  background: #e5e7eb;
}

/* ============================================
   PROMPT-SPECIFIC STYLES
   ============================================ */

/* Prompt Step 2 Locked State */
body.flowpast-gated .prompt-step-2-gated {
  position: relative;
}

body.flowpast-gated .prompt-step-2-gated .prompt-gated-content {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}

body.flowpast-unlocked .prompt-step-2-gated .prompt-gated-content {
  filter: none;
  user-select: auto;
  pointer-events: auto;
}

body.flowpast-unlocked .prompt-step-2-gated .flowpast-unlock-overlay {
  display: none;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
  .flowpast-popup-content {
    max-width: 100%;
    margin: 10px;
    max-height: 85vh;
  }

  .popup-header,
  .popup-benefits,
  .popup-form-section {
    padding-left: 20px;
    padding-right: 20px;
  }

  .popup-title {
    font-size: 20px;
  }

  .popup-icon {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .flowpast-unlock-overlay {
    padding: 20px;
    width: calc(100% - 40px);
  }

  .flowpast-unlock-overlay h4 {
    font-size: 16px;
  }

  .popup-success-buttons {
    gap: 10px;
  }
}

/* ============================================
   TOC SIDEBAR BUTTON UPDATES
   ============================================ */

/* Use Template Button - Gated State */
.toc-btn-use-template {
  background: transparent;
  color: #04aa6d !important;
  border: 2px solid #04aa6d;
}

.toc-btn-use-template:hover {
  background: #04aa6d;
  color: #ffffff !important;
}

/* Download Button - Unlocked State */
.toc-btn-download {
  background: #04aa6d;
  color: #ffffff !important;
  border: 2px solid #04aa6d;
}

.toc-btn-download:hover {
  background: #059862;
  border-color: #059862;
}

/* ============================================
   LOADING STATE FOR FORM
   ============================================ */

.popup-form-section.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}
