/*
 * Contabileasy — Popup Multi-Step (standalone, vanilla)
 *
 * Markup limpo, sem classes Elementor, imune às mexidas do theme.min.js
 * do WordPress (que removia o popup original do DOM).
 *
 * O popup vive em <div id="cl-cta-popup"> no fim do <body>.
 *
 * Estados:
 *   [data-cl-popup="closed"] → invisível, fora do flow
 *   [data-cl-popup="open"]   → overlay fade-in, modal slide-up
 */

/* ============================================================
   Overlay
   ============================================================ */
#cl-cta-popup {
  display: none;
}
#cl-cta-popup[data-cl-popup="open"] {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(6, 57, 59, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: cl-overlay-fade 0.22s ease-out;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes cl-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   Modal card
   ============================================================ */
.cl-popup-card {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(6, 57, 59, 0.28);
  padding: 32px 28px 28px;
  position: relative;
  animation: cl-modal-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

@keyframes cl-modal-up {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cl-popup-title {
  font-size: 20px;
  font-weight: 700;
  color: #06393B;
  line-height: 1.3;
  margin: 0 0 22px;
  padding-right: 36px;
}

.cl-popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #06393B;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
  padding: 0;
}
.cl-popup-close:hover {
  background: #f4fbfb;
  color: #4EBBB6;
}
.cl-popup-close::before {
  content: '×';
  font-weight: 400;
}

/* ============================================================
   Form + steps
   ============================================================ */
.cl-popup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.cl-popup-step {
  display: none;
  flex-direction: column;
  gap: 12px;
}
.cl-popup-step[data-cl-step="active"] {
  display: flex;
}

.cl-popup-step-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #06393B;
  margin: 0;
}

/* ============================================================
   Inputs / Selects
   ============================================================ */
#cl-cta-popup .cl-popup-input,
#cl-cta-popup .cl-popup-select {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  width: 100% !important;
  height: 52px !important;
  padding: 0 44px 0 18px !important;
  margin: 0 !important;
  border: 1.5px solid #d8eeec !important;
  border-radius: 10px !important;
  background: #fff !important;
  font-family: inherit !important;
  font-size: 15px !important;
  color: #06393B !important;
  outline: none !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  position: relative !important;
  z-index: 2 !important;
  cursor: pointer !important;
  line-height: 52px !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  overflow: hidden !important;
}

#cl-cta-popup .cl-popup-input {
  cursor: text !important;
  padding-right: 18px !important;
}

/* Mata o widget jQuery UI selectmenu que o theme.min.js da Archub cria
   automaticamente em cima de TODO <select>. Mantém só o select nativo. */
#cl-cta-popup .ui-selectmenu-button,
#cl-cta-popup .cl-popup-select + .ui-selectmenu-button,
#cl-cta-popup .cl-popup-select-wrapper .ui-selectmenu-button {
  display: none !important;
}

.cl-popup-input::placeholder {
  color: #9ba8a7;
  opacity: 1;
}

.cl-popup-input:focus,
.cl-popup-select:focus {
  border-color: #4EBBB6;
  box-shadow: 0 0 0 3px rgba(78, 187, 182, 0.15);
}

.cl-popup-select-wrapper {
  position: relative;
  width: 100%;
}
.cl-popup-select-wrapper::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 18px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #4EBBB6;
  border-bottom: 2px solid #4EBBB6;
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
  z-index: 3;
}

.cl-popup-input.cl-invalid,
.cl-popup-select.cl-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* ============================================================
   Action buttons
   ============================================================ */
.cl-popup-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 6px;
}
.cl-popup-actions[data-cl-has-back="true"] {
  grid-template-columns: 1fr 1fr;
}

.cl-popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl-popup-btn--primary {
  background: #4EBBB6;
  color: #fff;
}
.cl-popup-btn--primary:hover {
  background: #3da9a4;
  transform: translateY(-1px);
}
.cl-popup-btn--primary[disabled] {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

.cl-popup-btn--secondary {
  background: #e6e6e6;
  color: #8a8a8a;
}
.cl-popup-btn--secondary:hover {
  background: #d8d8d8;
}

/* ============================================================
   Footer pill
   ============================================================ */
.cl-popup-footer {
  margin-top: 18px;
  padding: 12px 16px;
  background: #f4fbfb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #06393B;
}
.cl-popup-footer-icon {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #d8f1ef;
  color: #4EBBB6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}
.cl-popup-footer-icon::before { content: '✓'; }

/* ============================================================
   Inline error
   ============================================================ */
.cl-popup-error {
  margin-top: 4px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  animation: cl-shake 0.3s ease-in-out;
}
@keyframes cl-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ============================================================
   Body lock
   ============================================================ */
body.cl-popup-locked {
  overflow: hidden;
}

/* HTML hidden attribute precisa derrubar display:inline-flex dos botões */
#cl-cta-popup [hidden] {
  display: none !important;
}

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 540px) {
  .cl-popup-card {
    padding: 28px 20px 20px;
    border-radius: 12px;
  }
  .cl-popup-title { font-size: 18px; }
  .cl-popup-input,
  .cl-popup-select,
  .cl-popup-btn {
    height: 48px;
    font-size: 14px;
  }
  .cl-popup-footer {
    font-size: 10px;
    padding: 10px 14px;
  }
}
