/* Convertify Forms — vanilla CSS com Custom Properties */

/* ── Tokens padrão (override via style inline no wrapper) ── */
.cvf-form {
  --cvf-primary: #0a84ff;
  --cvf-bg: #ffffff;
  --cvf-text: #111111;
  --cvf-border: #d1d5db;
  --cvf-radius: 8px;
  --cvf-font: system-ui, -apple-system, sans-serif;
  --cvf-shadow: 0 2px 12px rgba(0,0,0,.10);
}

/* ── Form wrapper ── */
.cvf-form {
  background: var(--cvf-bg);
  color: var(--cvf-text);
  font-family: var(--cvf-font);
  border-radius: var(--cvf-radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-sizing: border-box;
}

/* ── Header ── */
.cvf-header { text-align: center; margin-bottom: 20px; }
.cvf-logo   { max-height: 56px; max-width: 180px; margin-bottom: 12px; object-fit: contain; }
.cvf-title  { font-size: 1.25rem; font-weight: 700; margin: 0 0 6px; color: var(--cvf-text); }
.cvf-subtitle { font-size: .9rem; color: color-mix(in srgb, var(--cvf-text) 70%, transparent); margin: 0; }

/* ── Fields ── */
.cvf-fields { display: flex; flex-direction: column; gap: 14px; }
.cvf-field  { display: flex; flex-direction: column; gap: 4px; }
.cvf-label  { font-size: .85rem; font-weight: 600; color: var(--cvf-text); }

.cvf-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border: 1.5px solid var(--cvf-border);
  border-radius: calc(var(--cvf-radius) - 2px);
  font-size: 1rem;
  font-family: var(--cvf-font);
  color: var(--cvf-text);
  background: var(--cvf-bg);
  transition: border-color .15s;
  outline: none;
}
.cvf-input:focus { border-color: var(--cvf-primary); }
.cvf-input.cvf-invalid { border-color: #ef4444; }
textarea.cvf-input,
.cvf-textarea { min-height: 110px; resize: vertical; }
select.cvf-input { appearance: auto; }

/* ── Submit ── */
.cvf-submit {
  margin-top: 4px;
  padding: 12px;
  background: var(--cvf-primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--cvf-radius) - 2px);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--cvf-font);
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  width: 100%;
}
.cvf-submit:hover  { opacity: .88; }
.cvf-submit:active { transform: scale(.98); }
.cvf-submit:disabled { opacity: .6; cursor: not-allowed; }

/* ── Hidden override — garante que display:flex não vaze com o atributo hidden ── */
.cvf-success[hidden],
.cvf-error-msg[hidden],
.cvf-widget-panel[hidden],
.cvf-lightbox[hidden] { display: none !important; }

/* ── Success ── */
.cvf-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 0;
  text-align: center;
}
.cvf-success-icon { width: 48px; height: 48px; color: var(--cvf-primary); }
.cvf-success-msg  { font-size: 1rem; font-weight: 600; }

/* ── Error ── */
.cvf-error-msg {
  margin-top: 10px;
  padding: 10px 14px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: calc(var(--cvf-radius) - 2px);
  font-size: .9rem;
}

/* ── Floating button ── */
.cvf-floating {
  --cvf-floating-color: #25D366;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
}
.cvf-floating-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--cvf-floating-color);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: .95rem;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
}
.cvf-floating-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.cvf-floating-btn svg   { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Lightbox ── */
.cvf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cvf-lightbox[hidden] { display: none; }
.cvf-lightbox.cvf-opening .cvf-lightbox-panel { animation: cvf-slide-in .25s ease; }
.cvf-lightbox.cvf-closing .cvf-lightbox-panel  { animation: cvf-slide-out .2s ease forwards; }

@keyframes cvf-slide-in  { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }
@keyframes cvf-slide-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateY(20px); } }

.cvf-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  cursor: pointer;
}
.cvf-lightbox-panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  width: min(90vw, 480px);
}
.cvf-lightbox-panel .cvf-form {
  border-radius: 12px;
  box-shadow: none;
  max-width: 100%;
}
.cvf-lightbox-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #6b7280;
  z-index: 2;
  line-height: 1;
  padding: 4px;
}
.cvf-lightbox-close:hover { color: #111; }

/* ── Widget lateral ── */
.cvf-widget {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
}
.cvf-widget-toggle {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  padding: 16px 10px;
  background: var(--cvf-primary, #0a84ff);
  color: #fff;
  border: none;
  border-radius: 8px 0 0 8px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: -2px 0 10px rgba(0,0,0,.15);
}
.cvf-widget-panel {
  position: absolute;
  right: 100%;
  top: 0;
  width: min(90vw, 360px);
  box-shadow: var(--cvf-shadow);
  border-radius: 8px 0 0 8px;
  overflow: hidden;
}
.cvf-widget-panel[hidden] { display: none; }
.cvf-widget-panel .cvf-form { border-radius: 0; max-width: 100%; }

/* ── Context inline ── */
.cvf-context-inline { box-shadow: var(--cvf-shadow); }

/* ── Loading spinner on submit ── */
.cvf-submit.cvf-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cvf-spin .6s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}
@keyframes cvf-spin { to { transform: rotate(360deg); } }
