/* ========================================
   LOE MODAL — Letter of Engagement
   ======================================== */

/* Send LOE button in nav-buttons — inherits btn-back via HTML class,
   this rule just keeps .btn-send-loe as a JS hook with no visual override */
.nav-buttons__right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 12px);
}

/* ─── Overlay ─────────────────────────────────────────────────────────────── */

.loe-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  padding: 16px;
}

/* ─── Modal container ─────────────────────────────────────────────────────── */

.loe-modal {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 32px;
  scrollbar-width: thin;
}

.loe-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: #9CA3AF;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.loe-modal__close:hover {
  color: #374151;
  background: #F3F4F6;
}

.loe-modal__title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 8px;
}

.loe-modal__subtitle {
  font-size: 14px;
  color: #6B7280;
  margin: 0 0 24px;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

.loe-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.loe-modal__footer--center {
  justify-content: center;
}

/* ─── Buttons — match wizard btn-next / btn-back exactly ─────────────────── */

.loe-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: var(--spacing-sm, 8px) !important;
  padding: 10px 20px !important;
  border-radius: 12px !important;
  font-weight: var(--font-weight-medium, 500) !important;
  font-family: inherit !important;
  font-size: inherit !important;
  cursor: pointer !important;
  transition: all var(--transition-normal, 0.2s ease) !important;
  min-width: 120px !important;
  line-height: 1.4 !important;
  border: 1px solid transparent !important;
  text-decoration: none !important;
}

/* Primary = btn-next style */
.loe-btn--primary {
  background-color: var(--color-primary, #3B82F6) !important;
  color: var(--color-white, #ffffff) !important;
  border-color: var(--color-primary, #3B82F6) !important;
}

.loe-btn--primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover, #2563EB) !important;
  border-color: var(--color-primary-hover, #2563EB) !important;
  transform: translateY(-1px) !important;
}

.loe-btn--primary:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Secondary = btn-back style */
.loe-btn--secondary {
  background-color: var(--color-white, #ffffff) !important;
  color: var(--color-primary, #374151) !important;
  border-color: var(--color-border, #D1D5DB) !important;
}

.loe-btn--secondary:hover {
  background-color: var(--color-primary, #3B82F6) !important;
  color: var(--color-white, #ffffff) !important;
  border-color: var(--color-primary, #3B82F6) !important;
}

/* ─── Form ────────────────────────────────────────────────────────────────── */

.loe-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.loe-form__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.loe-form__label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.loe-form__label--required::after {
  content: ' *';
  color: #DC2626;
}

.loe-form__input {
  padding: 10px 14px;
  border: 1.5px solid #D1D5DB;
  border-radius: 8px;
  font-size: 14px;
  color: #1F2937;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.loe-form__input:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.loe-form__input:disabled {
  background: #F9FAFB;
  color: #9CA3AF;
}

.loe-form__error {
  font-size: 12px;
  color: #DC2626;
  margin: 0;
}

.loe-optional {
  font-weight: 400;
  color: #9CA3AF;
  font-size: 12px;
}

.loe-email-verify-hint {
  font-size: 12px;
  color: #6B7280;
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ─── OTP section ─────────────────────────────────────────────────────────── */

.loe-otp-section {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 20px;
  margin-top: 16px;
}

.loe-otp-section__info {
  font-size: 13px;
  color: #374151;
  margin: 0 0 16px;
  text-align: center;
}

.loe-otp-inputs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.loe-otp-digit {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border: 2px solid #D1D5DB;
  border-radius: 8px;
  color: #1F2937;
  transition: border-color 0.15s;
}

.loe-otp-digit:focus {
  outline: none;
  border-color: #3B82F6;
}

.loe-otp-digit.error {
  border-color: #DC2626;
}

/* ─── Signature ───────────────────────────────────────────────────────────── */

.loe-signature-wrapper {
  position: relative;
  border: 2px dashed #D1D5DB;
  border-radius: 10px;
  overflow: hidden;
  background: #FAFAFA;
  margin-bottom: 16px;
}

.loe-signature-canvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
  touch-action: none;
}

.loe-signature-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fff;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #6B7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.loe-signature-clear:hover {
  background: #F3F4F6;
  color: #374151;
}

/* ─── Preview stage ───────────────────────────────────────────────────────── */

.loe-preview-scroll {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 16px;
  background: #FAFAFA;
  margin-bottom: 16px;
  scrollbar-width: thin;
}

.loe-preview-content {
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #333;
  line-height: 1.6;
}

/* T&C checkbox for LOE — same style as step-6 checkout checkbox */
.loe-terms-section {
  margin-top: 4px;
}

.loe-terms-section .terms-checkbox-text {
  font-size: 12px !important;
  line-height: 1.5 !important;
}

/* Custom checkbox appearance — primary colour on check */
#loe-agree-checkbox {
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 18px !important;
  height: 18px !important;
  border: 2px solid var(--color-border, #D1D5DB) !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  position: relative !important;
  flex-shrink: 0 !important;
  margin-top: 2px !important;
  transition: background-color 0.15s, border-color 0.15s !important;
}

#loe-agree-checkbox:checked {
  background-color: var(--color-primary, #3B82F6) !important;
  border-color: var(--color-primary, #3B82F6) !important;
}

#loe-agree-checkbox:checked::after {
  content: "" !important;
  position: absolute !important;
  width: 5px !important;
  height: 9px !important;
  border: 2px solid #fff !important;
  border-top: none !important;
  border-left: none !important;
  transform: rotate(45deg) !important;
  top: 1px !important;
  left: 4px !important;
}

/* ─── Submitting state ────────────────────────────────────────────────────── */

.loe-submitting {
  text-align: center;
  padding: 40px 0;
}

.loe-submitting p {
  color: #6B7280;
  font-size: 14px;
  margin: 16px 0 0;
}

.loe-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #E5E7EB;
  border-top-color: var(--color-primary, #3B82F6);
  border-radius: 50%;
  animation: loe-spin 0.7s linear infinite;
  margin: 0 auto;
}

@keyframes loe-spin {
  to { transform: rotate(360deg); }
}

/* ─── Success state ───────────────────────────────────────────────────────── */

.loe-success {
  text-align: center;
  padding: 24px 0 8px;
}

.loe-success__icon {
  width: 60px;
  height: 60px;
  background: #DCFCE7;
  color: #16A34A;
  border-radius: 50%;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 576px) {
  .loe-modal {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .loe-modal__title {
    font-size: 17px;
  }

  .nav-buttons__right {
    flex-direction: column-reverse;
    width: 100%;
  }

  .acsm-wizard-container .btn-send-loe {
    width: 100%;
    justify-content: center;
  }

  .loe-otp-digit {
    width: 36px;
    height: 44px;
    font-size: 16px;
  }

  .loe-preview-scroll {
    max-height: 40vh;
  }
}
