/* ================================================================
   CB4 IA – Virtual Try-On  |  v1.8.0
   Modal renderizado no wp_footer — direto no <body>
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* ── Fontes ──────────────────────────────────────────────────── */
#cb4ia-modal-root,
#cb4ia-modal-root *,
.cb4ia-open-btn {
  font-family: 'DM Sans', sans-serif;
}
.cb4ia-title, .cb4ia-badge, .cb4ia-run,
.cb4ia-stat-val, .cb4ia-result-label,
.cb4ia-open-btn-label, .cb4ia-open-btn-badge,
.cb4ia-drop-title, .cb4ia-mini-label, .cb4ia-change {
  font-family: 'Syne', sans-serif;
}

/* ════════════════════════════════════════════════════════════════
   BOTÃO DE ABERTURA
   ════════════════════════════════════════════════════════════════ */
.cb4ia-open-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  padding: 14px 20px !important;
  border: 0 !important;
  border-radius: 16px !important;
  cursor: pointer;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #fff !important;
  background: linear-gradient(135deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%) !important;
  background-size: 200% 200% !important;
  animation: cb4iaGradShift 5s ease infinite;
  box-shadow: 0 4px 20px rgba(255,60,172,.35), inset 0 1px 0 rgba(255,255,255,.15) !important;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
  margin-top: 12px !important;
}
.cb4ia-open-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.12) 0%, transparent 60%);
  border-radius: inherit;
}
.cb4ia-open-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 32px rgba(255,60,172,.5), inset 0 1px 0 rgba(255,255,255,.2) !important;
}
.cb4ia-open-btn:active { transform: translateY(0) !important; }
.cb4ia-open-btn-icon   { font-size: 18px; position: relative; z-index: 1; }
.cb4ia-open-btn-label  { position: relative; z-index: 1; letter-spacing: .02em; }
.cb4ia-open-btn-badge  {
  position: relative; z-index: 1;
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 7px; border-radius: 999px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.25);
}
@keyframes cb4iaGradShift {
  0%,100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ════════════════════════════════════════════════════════════════
   MODAL — renderizado no <body> via wp_footer
   position:fixed funciona 100% aqui pois não há pai com transform
   ════════════════════════════════════════════════════════════════ */
#cb4ia-modal-root {
  /* Oculto por padrão */
  display: none;

  /* Cobre a tela toda */
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2147483647;

  /* Centraliza o conteúdo */
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#cb4ia-modal-root.cb4ia-open {
  display: flex;
}

/* Fundo escurecido — elemento separado para não interferir no stacking */
.cb4ia-overlay-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10,8,20,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 0;
}

/* ── Caixa branca ─────────────────────────────────────────────── */
.cb4ia-content {
  background: #fff;
  width: min(960px, calc(100vw - 24px));
  max-width: 960px;
  max-height: min(90vh, 840px);
  margin: auto;
  border-radius: 28px;
  position: relative;
  z-index: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.04),
    0 32px 80px rgba(0,0,0,.18),
    0 8px 24px rgba(0,0,0,.08);
  animation: cb4iaPop .25s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes cb4iaPop {
  from { transform: translateY(18px) scale(.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Barra de gradiente animada ──────────────────────────────── */
.cb4ia-top-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #FF3CAC, #784BA0, #2B86C5, #FF3CAC);
  background-size: 300% 100%;
  animation: cb4iaBarMove 4s linear infinite;
  z-index: 10;
}
@keyframes cb4iaBarMove {
  0%   { background-position: 0% 0%; }
  100% { background-position: 300% 0%; }
}

/* ── Botão fechar ────────────────────────────────────────────── */
.cb4ia-close {
  position: absolute; top: 16px; right: 18px;
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.05);
  color: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
  z-index: 20;
}
.cb4ia-close:hover { background: rgba(0,0,0,.1); color: rgba(0,0,0,.8); transform: scale(1.08); }

/* ── Header ──────────────────────────────────────────────────── */
.cb4ia-head { padding: 30px 56px 0 26px; }

.cb4ia-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: rgba(0,0,0,.4); margin-bottom: 12px;
  white-space: nowrap;
}
.cb4ia-badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, #FF3CAC, #2B86C5);
  animation: cb4iaDotPulse 2s ease-in-out infinite; flex-shrink: 0;
}
@keyframes cb4iaDotPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.75); }
}
.cb4ia-title {
  font-size: clamp(20px, 2.8vw, 28px); font-weight: 700;
  color: #0D0D14; line-height: 1.15;
  letter-spacing: -.02em; margin: 0 0 8px;
}
.cb4ia-title-grad {
  background: linear-gradient(135deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.cb4ia-note { font-size: 13px; color: rgba(0,0,0,.4); font-weight: 300; margin: 0; }

/* ── Body ────────────────────────────────────────────────────── */
.cb4ia-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  flex: 1; padding: 20px 26px 26px;
}

/* ── Grid ────────────────────────────────────────────────────── */
.cb4ia-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

@media (min-width: 720px) {
  .cb4ia-grid { grid-template-columns: 300px 1fr; gap: 24px; }
  .cb4ia-left { position: sticky; top: 0; align-self: start; }
}

.cb4ia-right { display: none; }
.cb4ia-result-visible .cb4ia-right { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 720px) {
  .cb4ia-result-visible .cb4ia-grid { grid-template-columns: 300px 1fr; }
  #cb4ia-modal-root:not(.cb4ia-result-visible) .cb4ia-left { max-width: 380px; margin: 0 auto; width: 100%; }
}

/* ── Input file ──────────────────────────────────────────────── */
.cb4ia-file { display: none; }

/* ── Drop zone ───────────────────────────────────────────────── */
.cb4ia-drop {
  border: 1.5px dashed rgba(0,0,0,.15); border-radius: 20px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  background: linear-gradient(135deg, rgba(255,60,172,.03), rgba(43,134,197,.03));
  transition: border-color .2s, transform .2s, background .2s;
  position: relative; overflow: hidden;
}
.cb4ia-drop::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,60,172,.05), rgba(43,134,197,.05));
  opacity: 0; transition: opacity .2s;
}
.cb4ia-drop:hover { border-color: rgba(255,60,172,.4); transform: translateY(-2px); }
.cb4ia-drop:hover::before { opacity: 1; }
.cb4ia-drop-icon-wrap { font-size: 30px; margin-bottom: 10px; display: block; }
.cb4ia-drop-title { font-size: 14px; font-weight: 700; color: #0D0D14; margin-bottom: 6px; }
.cb4ia-drop-sub { font-size: 12px; color: rgba(0,0,0,.4); line-height: 1.6; }

/* ── Preview ─────────────────────────────────────────────────── */
.cb4ia-preview { border-radius: 18px; border: 1px solid rgba(0,0,0,.07); overflow: hidden; background: #f5f5f8; }
.cb4ia-preview-img {
  width: 100%; height: 180px;
  object-fit: cover; object-position: top center; display: block;
}
.cb4ia-preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: rgba(0,0,0,.025);
  border-top: 1px solid rgba(0,0,0,.05);
}
.cb4ia-mini-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; color: rgba(0,0,0,.5); text-transform: uppercase; }
.cb4ia-change {
  border: 1px solid rgba(0,0,0,.1); padding: 5px 12px; border-radius: 8px;
  background: transparent; font-size: 11px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: rgba(0,0,0,.45); cursor: pointer; transition: all .15s;
}
.cb4ia-change:hover { border-color: rgba(0,0,0,.25); color: rgba(0,0,0,.7); }

/* ── Consent ─────────────────────────────────────────────────── */
.cb4ia-consent-line {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: rgba(0,0,0,.025); border: 1px solid rgba(0,0,0,.05); cursor: pointer;
}
.cb4ia-consent { margin-top: 2px; flex-shrink: 0; accent-color: #FF3CAC; width: 14px; height: 14px; }
.cb4ia-consent-line span { font-size: 12px; color: rgba(0,0,0,.45); line-height: 1.5; font-weight: 300; }

/* ── Botão gerar ─────────────────────────────────────────────── */
.cb4ia-actions { margin-top: 14px; }
.cb4ia-run {
  width: 100% !important; padding: 15px 20px !important;
  border: 0 !important; border-radius: 16px !important; cursor: pointer;
  font-size: 14px !important; font-weight: 800 !important; letter-spacing: .04em;
  color: #fff !important;
  background: linear-gradient(135deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%) !important;
  background-size: 200% 200% !important;
  animation: cb4iaGradShift 5s ease infinite;
  box-shadow: 0 4px 20px rgba(255,60,172,.3), inset 0 1px 0 rgba(255,255,255,.15) !important;
  display: inline-flex !important; align-items: center !important;
  justify-content: center !important; gap: 10px;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.cb4ia-run::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.12) 0%, transparent 60%);
}
.cb4ia-run:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(255,60,172,.45), inset 0 1px 0 rgba(255,255,255,.2) !important; }
.cb4ia-run:active:not(:disabled) { transform: translateY(0); }
.cb4ia-run:disabled { opacity: .4; cursor: not-allowed; animation: none; }
.cb4ia-run-text { position: relative; z-index: 1; }
.cb4ia-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  display: none; animation: cb4iaSpin .75s linear infinite;
  flex-shrink: 0; position: relative; z-index: 1;
}
@keyframes cb4iaSpin { to { transform: rotate(360deg); } }
.cb4ia-run.is-loading .cb4ia-spinner { display: inline-block; }
.cb4ia-run.is-loading .cb4ia-run-text { opacity: .85; }

/* ── Status ──────────────────────────────────────────────────── */
.cb4ia-status {
  margin-top: 10px; font-size: 12px; color: rgba(0,0,0,.4);
  min-height: 18px; text-align: center; font-style: italic;
}

/* ── Stats ───────────────────────────────────────────────────── */
.cb4ia-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.cb4ia-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; border-radius: 14px;
  background: #f5f5f8; border: 1px solid rgba(0,0,0,.05); gap: 4px;
  transition: border-color .2s, background .2s;
}
.cb4ia-stat:hover { border-color: rgba(255,60,172,.2); background: rgba(255,60,172,.03); }
.cb4ia-stat-val {
  font-size: 16px; font-weight: 800;
  background: linear-gradient(135deg, #FF3CAC, #2B86C5);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1;
}
.cb4ia-stat-lbl { font-size: 10px; color: rgba(0,0,0,.35); font-weight: 500; letter-spacing: .03em; }

/* ── Resultado header ────────────────────────────────────────── */
.cb4ia-result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cb4ia-result-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(0,0,0,.35); }
.cb4ia-result-badge {
  font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,60,172,.1), rgba(43,134,197,.1));
  border: 1px solid rgba(255,60,172,.25); color: #FF3CAC;
  letter-spacing: .05em; text-transform: uppercase;
}

/* ── Empty state ─────────────────────────────────────────────── */
.cb4ia-result-empty {
  border-radius: 20px; border: 1.5px dashed rgba(0,0,0,.1);
  background: linear-gradient(135deg, rgba(255,60,172,.02), rgba(43,134,197,.02));
  height: 320px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.cb4ia-result-empty-icon { font-size: 40px; opacity: .2; }
.cb4ia-result-empty-text { font-size: 13px; color: rgba(0,0,0,.25); font-weight: 300; }
.cb4ia-result-visible .cb4ia-result-empty { display: none; }

/* ── Skeleton ────────────────────────────────────────────────── */
.cb4ia-skeleton {
  height: min(400px, 55vh); border-radius: 20px;
  position: relative; overflow: hidden; background: #f0f0f5;
}
.cb4ia-shimmer {
  position: absolute; inset: 0; transform: translateX(-60%);
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.7) 50%, rgba(255,255,255,0) 100%);
  animation: cb4iaShimmer 1.5s ease-in-out infinite;
}
@keyframes cb4iaShimmer { 0% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }
.cb4ia-ai-loader {
  position: absolute; bottom: 16px; left: 16px; right: 16px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 14px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 16px rgba(0,0,0,.08); border: 1px solid rgba(0,0,0,.06);
}
.cb4ia-dots { display: flex; gap: 5px; }
.cb4ia-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, #FF3CAC, #2B86C5);
  animation: cb4iaDotBounce 1.2s ease-in-out infinite;
}
.cb4ia-dot:nth-child(2) { animation-delay: .2s; }
.cb4ia-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cb4iaDotBounce {
  0%,80%,100% { transform: scale(.55); opacity: .4; }
  40%          { transform: scale(1); opacity: 1; }
}
.cb4ia-ai-text { font-size: 12px; font-weight: 500; color: rgba(0,0,0,.55); }

/* ── Imagem resultado ────────────────────────────────────────── */
.cb4ia-img {
  width: 100% !important; height: auto;
  max-height: min(65vh, 560px); object-fit: contain;
  border-radius: 20px !important; display: block;
  box-shadow: 0 16px 48px rgba(0,0,0,.12);
  animation: cb4iaFade .3s cubic-bezier(.22,.61,.36,1);
}
@keyframes cb4iaFade {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Lock scroll ─────────────────────────────────────────────── */
body.cb4ia-lock { overflow: hidden !important; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .cb4ia-head { padding: 26px 52px 0 18px; }
  .cb4ia-body { padding: 16px 18px 20px; }
  .cb4ia-content { border-radius: 22px; }
  .cb4ia-preview-img { height: 160px; }
  .cb4ia-skeleton { height: 44vh; }
  .cb4ia-run { font-size: 13px !important; }
  .cb4ia-result-empty { height: 220px; }
}
