/**
 * Smart Multi-step Popup - Modern Premium Design
 * Version: 2.0.1
 * Mobile-first responsive design inspired by Figma
 */

/* CSS Variables for theming */
:root {
  --sms-primary: #8b5cf6;
  --sms-primary-hover: #7c3aed;
  --sms-primary-light: #a78bfa;
  --sms-primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --sms-overlay-bg: rgba(30, 20, 50, 0.85);
  --sms-popup-bg: #ffffff;
  --sms-card-bg: #ffffff;
  --sms-border-color: #e5e7eb;
  --sms-border-radius: 16px;
  --sms-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --sms-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --sms-text-color: #1f2937;
  --sms-text-secondary: #6b7280;
  --sms-error-color: #ef4444;
  --sms-success-color: #10b981;
  --sms-note-bg: #f0f9ff;
  --sms-note-border: #3b82f6;
  --sms-note-text: #1e40af;
}

/* Overlay - Mobile First */
.sms-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--sms-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 0;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Popup Container - Mobile First */
.sms-popup {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

/* Card Wrapper */
.sms-popup-card {
  background: var(--sms-card-bg);
  border-radius: var(--sms-border-radius);
  width: 100%;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

/* Remove any dark green bars that might appear */
.sms-popup-card::before,
.sms-popup-card::after,
.sms-popup-overlay::before,
.sms-popup-overlay::after,
.sms-popup::before,
.sms-popup::after {
  display: none !important;
  content: none !important;
}

/* Hide any elements with dark green background or color codes */
[style*="#128274"],
[style*="128274"],
[style*="rgb(18, 130, 116)"],
[class*="green-bar"],
[class*="top-bar"],
[class*="bottom-bar"],
div[style*="background"][style*="#128274"],
div[style*="background"][style*="128274"] {
  display: none !important;
}

/* Remove any top/bottom bars that might be added as wrapper divs */
.sms-popup-card > div:first-child:not(.sms-popup-header):not(.sms-popup-body):not(.sms-popup-footer)[style*="background"],
.sms-popup-card > div:last-child:not(.sms-popup-header):not(.sms-popup-body):not(.sms-popup-footer)[style*="background"] {
  display: none !important;
}

/* Ensure popup card starts and ends cleanly */
.sms-popup-card {
  border-top: none;
  border-bottom: none;
}

/* Remove any background colors that might create bars */
.sms-popup-overlay > *:first-child:not(.sms-popup),
.sms-popup > *:first-child:not(.sms-popup-card) {
  display: none !important;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
.sms-popup-header {
  position: relative;
  padding: 24px 24px 0 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 80px;
}

/* Close Button */
.sms-popup-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  background: transparent;
  color: var(--sms-text-secondary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.sms-popup-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.sms-popup-close:hover,
.sms-popup-close:focus {
  background: #f3f4f6;
  color: var(--sms-text-color);
  outline: none;
}

.sms-popup-close:active {
  transform: scale(0.95);
}

/* Icon Wrapper (for optional badge/icon) */
.sms-popup-icon-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  min-height: 64px;
  position: relative;
}

/* Icon Badge with Gradient and Glow */
.sms-popup-icon-wrapper::before {
  content: '';
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--sms-primary-gradient);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4), 0 0 40px rgba(139, 92, 246, 0.2);
  position: absolute;
  z-index: 1;
}

/* Body */
.sms-popup-body {
  flex: 1;
  padding: 0 24px 24px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Steps Container */
.sms-steps {
  padding: 0;
}

.sms-step {
  display: none;
}

.sms-step.active {
  display: block;
}

/* Title Section */
.sms-popup-title-section {
  text-align: center;
  margin-bottom: 24px;
  margin-top: 8px;
}

.sms-popup-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sms-text-color);
  margin: 0 0 12px 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.sms-popup-subtitle {
  font-size: 0.9375rem;
  color: var(--sms-text-secondary);
  margin: 0;
  line-height: 1.6;
  font-weight: 400;
  max-width: 100%;
}

/* Form Container */
.sms-popup-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Input Group */
.sms-popup-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Contact Information Fields - RTL Alignment */
.sms-contact-field {
  direction: rtl;
  text-align: right;
}

.sms-contact-field .sms-popup-input-label {
  text-align: right;
  direction: rtl;
}

.sms-contact-field .sms-popup-input {
  text-align: right;
  direction: rtl;
}

.sms-contact-field .sms-popup-input::placeholder {
  text-align: right;
  direction: rtl;
}

.sms-contact-field .sms-error-text {
  text-align: right;
  direction: rtl;
}

/* Ensure all contact info containers are RTL */
.sms-popup-form .sms-contact-field {
  direction: rtl;
}

.sms-popup-input-label {
  display: block;
  font-weight: 500;
  color: var(--sms-text-color);
  font-size: 0.875rem;
  margin: 0;
  text-align: left;
}

.text-red-500 {
  color: var(--sms-error-color);
}

/* Input Fields */
.sms-popup-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--sms-border-color);
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
  background: #ffffff;
  color: var(--sms-text-color);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  box-sizing: border-box;
}

.sms-popup-input:focus {
  border-color: var(--sms-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
  outline: none;
}

.sms-popup-input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.sms-popup-input:disabled {
  background: #f9fafb;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Error Text */
.sms-error-text {
  color: var(--sms-error-color);
  font-size: 0.8125rem;
  margin-top: 4px;
  font-weight: 500;
}

.sms-error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: var(--sms-error-color);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-weight: 500;
  text-align: center;
  font-size: 0.875rem;
}

/* Note Field */
.sms-note {
  background: var(--sms-note-bg);
  border: 1px solid var(--sms-note-border);
  color: var(--sms-note-text);
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: center;
}

/* Radio Group */
.sms-radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sms-radio-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 10px;
  transition: background-color 0.2s ease;
  min-height: 48px;
  touch-action: manipulation;
  border: 1.5px solid var(--sms-border-color);
  background: #ffffff;
}

.sms-radio-label:hover {
  background-color: #f9fafb;
  border-color: var(--sms-primary-light);
}

.sms-radio-label:active {
  background-color: #f3f4f6;
}

.sms-radio {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  cursor: pointer;
  accent-color: var(--sms-primary);
  touch-action: manipulation;
}

.sms-radio-label span {
  flex: 1;
  user-select: none;
  font-size: 0.9375rem;
  color: var(--sms-text-color);
}

/* Checkbox Group */
.sms-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sms-checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 10px;
  transition: background-color 0.2s ease;
  min-height: 48px;
  touch-action: manipulation;
  border: 1.5px solid var(--sms-border-color);
  background: #ffffff;
}

.sms-checkbox-label:hover {
  background-color: #f9fafb;
  border-color: var(--sms-primary-light);
}

.sms-checkbox-label:active {
  background-color: #f3f4f6;
}

.sms-checkbox {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  cursor: pointer;
  accent-color: var(--sms-primary);
  touch-action: manipulation;
}

.sms-checkbox-label span {
  flex: 1;
  user-select: none;
  font-size: 0.9375rem;
  color: var(--sms-text-color);
}

/* HTML Field */
.sms-html-field {
  margin: 0;
}

.sms-html-field a.sms__popup__a {
  background: var(--sms-primary-gradient);
  padding: 12px 20px;
  font-size: 0.9375rem;
  margin-top: 0;
  display: inline-block;
  color: #ffffff;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  min-height: 48px;
  line-height: 24px;
  box-sizing: border-box;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.sms-html-field a.sms__popup__a:hover,
.sms-html-field a.sms__popup__a:focus {
  background: var(--sms-primary-hover);
  outline: 2px solid var(--sms-primary);
  outline-offset: 2px;
}

/* Fields */
.sms-field {
  margin-bottom: 0;
}

.sms-field:last-child {
  margin-bottom: 0;
}

/* Actions - Redesigned Submission Area - Final Action Zone */
.sms-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 50%, #ffffff 100%);
  border-radius: 20px;
  padding: 28px 24px;
  margin-top: 32px;
  margin-bottom: 0;
  box-shadow: 0 8px 16px -4px rgba(139, 92, 246, 0.15), 0 4px 8px -2px rgba(139, 92, 246, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(139, 92, 246, 0.15);
  position: relative;
  overflow: hidden;
}

.sms-popup-actions::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--sms-primary-gradient);
  opacity: 0.8;
  border-radius: 20px 20px 0 0;
}

.sms-popup-actions::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.sms-popup-actions .sms-popup-button-primary {
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 16px -4px rgba(139, 92, 246, 0.4), 0 4px 8px -2px rgba(139, 92, 246, 0.3);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sms-popup-actions .sms-popup-button-primary:hover:not(:disabled) {
  box-shadow: 0 12px 24px -4px rgba(139, 92, 246, 0.5), 0 6px 12px -2px rgba(139, 92, 246, 0.4);
  transform: translateY(-2px);
}

.sms-popup-actions .sms-popup-button-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 8px -2px rgba(139, 92, 246, 0.3);
}

/* Buttons */
.sms-popup-button-primary,
.sms-popup-button-secondary {
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  font-family: inherit;
  width: 100%;
  min-height: 48px;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sms-popup-button-primary {
  background: var(--sms-primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.3), 0 2px 4px -1px rgba(139, 92, 246, 0.2);
}

.sms-popup-button-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.4), 0 4px 6px -2px rgba(139, 92, 246, 0.3);
}

.sms-popup-button-primary:active:not(:disabled) {
  transform: translateY(0);
}

.sms-popup-button-secondary {
  background: transparent;
  color: var(--sms-text-secondary);
  border: none;
  text-decoration: none;
  font-weight: 400;
}

.sms-popup-button-secondary:hover:not(:disabled) {
  background: transparent;
  color: var(--sms-text-color);
  text-decoration: underline;
}

.sms-popup-button-secondary:active:not(:disabled) {
  background: transparent;
}

.sms-popup-button-primary:disabled,
.sms-popup-button-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Footer */
.sms-popup-footer {
  padding: 16px 24px 24px 24px;
  border-top: 1px solid var(--sms-border-color);
  margin-top: auto;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--sms-text-secondary);
}

/* Trust Badge Icon */
.sms-popup-footer::before {
  content: '🔒';
  font-size: 0.875rem;
  display: inline-block;
}

/* Desktop/Tablet Styles (640px and up) */
@media (min-width: 640px) {
  .sms-popup-overlay {
    padding: 20px;
  }

  .sms-popup {
    max-width: 520px;
    width: 100%;
    padding: 20px;
  }

  .sms-popup-card {
    max-height: 90vh;
  }

  .sms-popup-header {
    padding: 32px 32px 0 32px;
  }

  .sms-popup-close {
    top: 24px;
    right: 24px;
  }

  .sms-popup-body {
    padding: 0 32px 32px 32px;
  }

  .sms-popup-title {
    font-size: 1.875rem;
  }

  .sms-popup-subtitle {
    font-size: 1rem;
  }

  .sms-popup-actions {
    flex-direction: column;
    gap: 12px;
  }

  .sms-popup-button-primary,
  .sms-popup-button-secondary {
    width: 100%;
  }

  .sms-popup-footer {
    padding: 20px 32px 32px 32px;
  }
}

/* Large Desktop (1024px and up) */
@media (min-width: 1024px) {
  .sms-popup {
    max-width: 520px;
  }

  .sms-popup-title {
    font-size: 2rem;
  }
}

/* Accessibility: Focus visible */
.sms-popup-close:focus-visible,
.sms-popup-button-primary:focus-visible,
.sms-popup-button-secondary:focus-visible,
.sms-popup-input:focus-visible,
.sms-radio:focus-visible,
.sms-checkbox:focus-visible {
  outline: 2px solid var(--sms-primary);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .sms-popup-overlay,
  .sms-popup-card,
  .sms-popup-close,
  .sms-popup-button-primary,
  .sms-popup-button-secondary,
  .sms-popup-input,
  .sms-radio-label,
  .sms-checkbox-label {
    animation: none;
    transition: none;
  }

  .sms-popup-button-primary:hover:not(:disabled),
  .sms-popup-button-secondary:hover:not(:disabled),
  .sms-popup-close:hover {
    transform: none;
  }
}

/* Print styles */
@media print {
  .sms-popup-overlay {
    display: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .sms-popup-card {
    border: 2px solid var(--sms-text-color);
  }

  .sms-popup-input {
    border-width: 2px;
  }

  .sms-popup-button-primary,
  .sms-popup-button-secondary {
    border-width: 2px;
  }
}
