:root {
  --trade-surface: #ffffff;
  --trade-field: #ffffff;
  --trade-ink: #202635;
  --trade-muted: #596273;
  --trade-line: #cbd1dd;
  --trade-backdrop: rgb(12 10 20 / .65);
  --trade-shadow: 0 24px 64px rgb(12 10 20 / .28);
  --trade-focus: #ea580c;
  --trade-error: #b42318;
  --trade-send: linear-gradient(180deg, #168647, #126836);
  --trade-send-ink: #ffffff;
  --trade-send-ring: #e3f0e8;
  --trade-photo-plate: linear-gradient(225deg, #F1F3F6 0%, #E4E6EB 40%, #D6D9E0 100%);
  --trade-photo-line: #c3c9d4;
  --trade-sheet-surface: var(--trade-surface);
  --trade-cover-mask: linear-gradient(to bottom, transparent 0%, #000 6%, #000 86%, transparent 100%);
}
html[data-theme="dark"] {
  --trade-surface: #211b2b;
  --trade-field: #18141f;
  --trade-ink: #f2f4f8;
  --trade-muted: #b8bfce;
  --trade-line: #51485f;
  --trade-error: #ffb4a9;
  --trade-send-ring: #b9c2d4;
}
.iphone-trade-heading { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
.iphone-trade-heading>div { flex:1 1 0; min-width:0; }
.iphone-trade-heading h4 { display:block; -webkit-line-clamp:unset; overflow:visible; min-height:0; line-height:1.45; }
/* CTA compacto: preserva as duas linhas do rótulo sem competir com o nome do aparelho. */
#productsContainer .product-card .iphone-trade-btn { box-sizing:border-box; flex:0 1 38%; width:38%; max-width:116px; min-width:0; min-height:38px; display:flex; align-items:center; justify-content:center; gap:5px; padding:6px 7px; font-size:9px; font-weight:800; line-height:1.2; text-align:center; letter-spacing:-.01em; cursor:pointer; }
/* O acabamento 3D do CTA é definido no fim de public/loja.html, após os estilos globais. */
.iphone-trade-btn svg { flex:none; width:16px; height:16px; }
.iphone-trade-btn span { display:block; min-width:0; max-width:100%; overflow-wrap:normal; text-wrap:balance; }
#iphoneTradeOverlay { position:fixed; inset:0; z-index:250000; background:var(--trade-backdrop); display:flex; align-items:center; justify-content:center; padding:20px; color:var(--trade-ink); letter-spacing:0; }
#iphoneTradeOverlay[hidden], #iphoneTradeOverlay [hidden] { display:none!important; }
.it-sheet { width:100%; max-width:620px; max-height:calc(100dvh - 40px); overflow:auto; overscroll-behavior:contain; background:var(--trade-surface); box-shadow:var(--trade-shadow); border:1px solid var(--trade-line); border-radius:8px; }
.it-header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 20px; }
.it-header h2 { font-size:20px; font-weight:800; line-height:1.3; margin:0; }
.it-close { width:36px; height:36px; flex:none; border:1.5px solid var(--thays-tactile-border); border-radius:50%; color:var(--thays-tactile-ink); background:var(--thays-tactile-bg); box-shadow:var(--thays-tactile-shadow); cursor:pointer; }
.it-cover { display:block; width:100%; height:auto; aspect-ratio:1920/908; object-fit:cover; object-position:center; }
/* Feather vertical: integra somente topo e base da foto ao fundo do modal. */
.it-cover {
  -webkit-mask-image: var(--trade-cover-mask);
  mask-image: var(--trade-cover-mask);
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
}
.it-form { padding:20px; }
.it-form fieldset { min-width:0; margin:0 0 20px; padding:0; border:0; }
.it-form legend { font-size:17px; font-weight:800; padding:0; margin-bottom:12px; }
.it-form label:not(.it-upload) { display:block; font-size:13px; font-weight:700; margin:12px 0 6px; }
.it-form input:not([type="file"]),.it-form select,.it-form textarea { display:block; width:100%; min-width:0; border:1px solid var(--trade-line); border-radius:8px; background:var(--trade-field); color:var(--trade-ink); padding:11px 10px; font-size:16px; line-height:1.4; }
.it-form textarea { resize:vertical; }
.it-form input::placeholder,.it-form textarea::placeholder { color:var(--trade-muted); }
.it-form :is(input,select,textarea,button):focus-visible,.iphone-trade-btn:focus-visible { outline:2px solid var(--trade-focus); outline-offset:3px; }
.it-pair { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; }
/* A área de detalhes ocupa espaço somente depois que modelo, capacidade e cor estiverem definidos. */
.it-selection-reveal { display:grid; grid-template-rows:0fr; opacity:0; transition:grid-template-rows .32s cubic-bezier(.2,.75,.25,1), opacity .22s ease; }
.it-selection-reveal.is-visible { grid-template-rows:1fr; opacity:1; }
.it-selection-clip { min-height:0; overflow:hidden; }
.it-selection { display:grid; grid-template-columns:78px minmax(0,1fr); align-items:center; gap:14px; margin:0; padding:12px 0; border-bottom:1px solid var(--trade-line); }
.it-plate { width:78px; height:90px; min-width:78px; box-sizing:border-box; display:grid; place-items:center; overflow:hidden; padding:0; background:transparent; border:0; border-radius:0; }
.it-selection img { display:block; width:68px; height:80px; max-width:100%; object-fit:contain; }
.it-selection-info { min-width:0; display:grid; gap:4px; }
.it-selection strong { min-width:0; font-size:14px; line-height:1.4; font-weight:800; overflow-wrap:normal; word-break:normal; }
.it-selection span { min-width:0; font-size:13px; line-height:1.4; color:var(--trade-muted); overflow-wrap:normal; word-break:normal; }
.it-selection b { min-width:0; font-size:clamp(16px,4vw,18px); line-height:1.3; overflow-wrap:normal; word-break:normal; }
.it-upload { position:relative; display:flex; align-items:center; justify-content:center; gap:10px; min-height:64px; padding:12px; border:1px dashed var(--trade-line); border-radius:8px; margin-top:16px; text-align:center; font-size:14px; font-weight:700; cursor:pointer; }
.it-upload small { display:block; font-size:12px; font-weight:400; color:var(--trade-muted); }
.it-upload input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.it-upload:focus-within { outline:2px solid var(--trade-focus); outline-offset:3px; }
#it-photo-error { font-size:13px; color:var(--trade-error); margin:8px 0; }
#it-photo-error:empty { display:none; }
#it-previews { display:flex; flex-wrap:wrap; gap:10px; margin-top:12px; }
#it-previews>div { position:relative; width:80px; height:80px; }
#it-previews img { width:100%; height:100%; object-fit:contain; background:var(--trade-field); border-radius:8px; }
#it-previews button { position:absolute; right:-4px; top:-4px; width:28px; height:28px; border-radius:50%; background:var(--thays-tactile-bg); color:var(--thays-tactile-ink); border:1px solid var(--trade-line); box-shadow:var(--thays-tactile-shadow); cursor:pointer; }
.it-note { font-size:12px; line-height:1.5; color:var(--trade-muted); margin:10px 0 14px; }
.it-send { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; min-height:48px; padding:12px; background:var(--trade-send); color:var(--trade-send-ink); border:2.5px solid var(--trade-send-ring); border-radius:12px; box-shadow:var(--thays-tactile-shadow); font-size:14px; font-weight:800; line-height:1.4; text-align:center; cursor:pointer; transition:transform .16s ease; }
.it-send svg { flex:none; }
.it-send:active { transform:translateY(1px); }
@media(max-width:639px) { #iphoneTradeOverlay { padding:10px; } .it-sheet { max-height:calc(100dvh - 20px); } .it-header { padding:12px 14px; } .it-form { padding:16px 14px; } .it-header h2 { font-size:18px; } }
@media(max-width:360px) { .it-selection { grid-template-columns:64px minmax(0,1fr); gap:10px; } .it-plate { width:64px; min-width:64px; height:82px; } .it-selection img { width:60px; height:76px; } }
@media(prefers-reduced-motion:reduce) { .it-send,.it-selection-reveal { transition:none; } }

/* Retorno acessível para compartilhamento nativo e alternativa manual. */
#it-share-status { margin:10px 0; color:var(--trade-ink); font-size:13px; line-height:1.5; }
#it-photo-downloads { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 12px; }
#it-photo-downloads a { display:inline-flex; align-items:center; min-height:36px; padding:7px 11px; border:1px solid var(--trade-line); border-radius:8px; color:var(--trade-ink); background:var(--trade-field); font-size:13px; font-weight:700; text-decoration:none; }
#it-open-whatsapp { margin:10px 0 14px; }
#it-open-whatsapp[hidden] { display:none!important; }



/* Identidade visual consolidada do modal de troca — alinhada à referência Light/Dark. */
:root {
  /* Light: superfície em branco-lavanda para continuar a tonalidade clara da capa. */
  --trade-sheet-surface: #f5f2fa;
  --trade-surface: #f5f2fa;
  --trade-field: #ffffff;
  --trade-ink: #17142b;
  --trade-muted: #625a70;
  --trade-line: #a94de2;
  --trade-backdrop: rgb(12 4 20 / .88);
  --trade-shadow: 0 18px 48px rgb(12 10 20 / .30);
  --trade-focus: #8b3fe0;
}
html[data-theme="dark"] {
  --trade-surface: #211b2b;
  --trade-field: #15001f;
  --trade-ink: #fffaff;
  --trade-muted: #d8c5e2;
  --trade-line: #a93fe0;
  --trade-backdrop: rgb(7 0 12 / .92);
  --trade-shadow: 0 20px 54px rgb(0 0 0 / .48);
  --trade-focus: #e879ff;
  --trade-sheet-surface: linear-gradient(180deg, #260039 0%, #21002f 52%, #1c0029 100%);
}

/* Backdrop neutro: sem halo roxo que destaque o recorte do banner. */
#iphoneTradeOverlay {
  background: var(--trade-backdrop);
  padding: 18px;
}
#iphoneTradeOverlay .it-sheet {
  box-sizing: border-box;
  width: min(620px, calc(100vw - 36px));
  max-width: 620px;
  max-height: calc(100dvh - 36px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--trade-line);
  border-radius: 18px;
  background: var(--trade-sheet-surface);
  color: var(--trade-ink);
  box-shadow: var(--trade-shadow);
}

/* Cabeçalho, banner e formulário compartilham a mesma família de tons. */
#iphoneTradeOverlay .it-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: linear-gradient(110deg, #f7f0ff 0%, #f1e7fc 100%);
}
#iphoneTradeOverlay .it-header h2 {
  color: var(--trade-ink);
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 800;
  line-height: 1.3;
}
#iphoneTradeOverlay .it-form {
  padding: 20px 22px 22px;
  background: transparent;
  color: var(--trade-ink);
}
#iphoneTradeOverlay .it-cover {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  object-position: center;
  -webkit-mask-image: var(--trade-cover-mask);
  mask-image: var(--trade-cover-mask);
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
}

/* Controles e divisórias preservam o violeta da arte sem competir com ela. */
#iphoneTradeOverlay .it-form legend {
  color: var(--trade-ink);
  font-size: clamp(17px, 1.4vw, 21px);
}
#iphoneTradeOverlay .it-form label:not(.it-upload) {
  color: var(--trade-ink);
  font-size: clamp(13px, 1.18vw, 16px);
}
#iphoneTradeOverlay .it-form input:not([type="file"]),
#iphoneTradeOverlay .it-form select,
#iphoneTradeOverlay .it-form textarea {
  border: 1.25px solid var(--trade-line);
  background: var(--trade-field);
  color: var(--trade-ink);
  font-size: clamp(15px, 1.25vw, 17px);
}
#iphoneTradeOverlay .it-form input::placeholder,
#iphoneTradeOverlay .it-form textarea::placeholder {
  color: var(--trade-muted);
}
#iphoneTradeOverlay .it-form :is(input,select,textarea,button):focus-visible {
  outline-color: var(--trade-focus);
}

/* Dark: o roxo da imagem continua suavemente pela superfície inteira do modal. */
html[data-theme="dark"] #iphoneTradeOverlay .it-sheet {
  background: var(--trade-sheet-surface);
}
html[data-theme="dark"] #iphoneTradeOverlay .it-header {
  /* Igual ao início da superfície do modal: o banner faz fade sobre esta cor,
     evitando a faixa horizontal entre o cabeçalho e a imagem. */
  background: #260039;
}
html[data-theme="dark"] #iphoneTradeOverlay .it-form {
  background: transparent;
}
html[data-theme="dark"] #iphoneTradeOverlay .it-form input:not([type="file"]),
html[data-theme="dark"] #iphoneTradeOverlay .it-form select,
html[data-theme="dark"] #iphoneTradeOverlay .it-form textarea {
  border-color: #a34dcc;
  background: #15001f;
  color: #fffaff;
}
html[data-theme="dark"] #iphoneTradeOverlay .it-form input::placeholder,
html[data-theme="dark"] #iphoneTradeOverlay .it-form textarea::placeholder {
  color: #d8c5e2;
}

/* Light: lavanda contínua, sem a faixa branca que separava banner e formulário. */
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-sheet {
  background: var(--trade-surface);
}
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-header {
  background: var(--trade-surface);
}
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-form {
  background: transparent;
}
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-form input:not([type="file"]),
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-form select,
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-form textarea {
  border-color: #a96be5;
  background: #fff;
  color: #17142b;
}

@media (max-width: 639px) {
  #iphoneTradeOverlay { padding: 10px; }
  #iphoneTradeOverlay .it-sheet {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  #iphoneTradeOverlay .it-header { padding: 12px 14px; }
  #iphoneTradeOverlay .it-form { padding: 16px 14px; }
  #iphoneTradeOverlay .it-header h2 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  #iphoneTradeOverlay .it-send,
  #iphoneTradeOverlay .it-selection-reveal { transition: none; }
}


/* Banner no topo do modal: remove o cabeçalho textual e mantém o fechar acessível. */
#iphoneTradeOverlay .it-sheet {
  position: relative;
}
#iphoneTradeOverlay .it-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
}
#iphoneTradeOverlay .it-cover {
  display: block;
  margin: 0;
  object-fit: cover;
  object-position: center top;
}
@media (max-width: 639px) {
  #iphoneTradeOverlay .it-close {
    top: 10px;
    right: 10px;
  }
}


/* Arte inteira, com bordas verticais fundidas à única superfície do formulário.
   A máscara não escurece o centro nem altera cores, largura ou proporção. */
#iphoneTradeOverlay .it-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 1600 / 912;
  object-fit: contain;
  object-position: center;
  -webkit-mask-image: var(--trade-cover-mask);
  mask-image: var(--trade-cover-mask);
}


/* Pré-visualizações das fotos anexadas: sem placa branca e com conteúdo centralizado. */
#it-previews {
  align-items: center;
  justify-content: flex-start;
}
#it-previews > div {
  display: grid;
  place-items: center;
  overflow: visible;
  background: transparent;
}
#it-previews img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
  border-radius: 8px;
}



/* Miniaturas responsivas: centralizadas e com fluxo próprio antes das instruções. */
#iphoneTradeOverlay #it-previews {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(72px, 88px));
  justify-content: center;
  justify-items: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 12px auto 18px;
  padding: 0 4px;
  position: relative;
  clear: both;
}
#iphoneTradeOverlay #it-previews > div {
  position: relative;
  width: 100%;
  max-width: 88px;
  min-width: 0;
  aspect-ratio: 1 / 1;
  height: auto;
  box-sizing: border-box;
  display: grid;
  place-items: center;
}
#iphoneTradeOverlay #it-previews img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
}
#iphoneTradeOverlay #it-photo-downloads,
#iphoneTradeOverlay #it-share-status,
#iphoneTradeOverlay #it-photo-error,
#iphoneTradeOverlay .it-note {
  position: relative;
  clear: both;
  max-width: 100%;
  overflow-wrap: anywhere;
}


/* Entrada suave do painel Troque seu iPhone — somente na abertura. */
@keyframes iphone-trade-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes iphone-trade-sheet-in {
  from {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(.97);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
@keyframes iphone-trade-cover-in {
  from {
    opacity: .72;
    transform: translate3d(0, 7px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}
#iphoneTradeOverlay:not([hidden]) {
  animation: iphone-trade-overlay-in 250ms ease-out both;
}
#iphoneTradeOverlay:not([hidden]) .it-sheet {
  animation: iphone-trade-sheet-in 400ms cubic-bezier(.22, 1, .36, 1) both;
  transform-origin: center;
}
#iphoneTradeOverlay:not([hidden]) .it-cover {
  animation: iphone-trade-cover-in 450ms ease-out 80ms both;
}
@media (prefers-reduced-motion: reduce) {
  #iphoneTradeOverlay:not([hidden]),
  #iphoneTradeOverlay:not([hidden]) .it-sheet,
  #iphoneTradeOverlay:not([hidden]) .it-cover {
    animation: none !important;
  }
}

/* Capa oficial do modal Troque seu iPhone: preenchimento integral e proporção nativa 1600x912. */
#iphoneTradeOverlay .it-cover {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 1600 / 912 !important;
  object-fit: cover !important;
  object-position: center center !important;
  margin: 0 !important;
  -webkit-mask-image: var(--trade-cover-mask) !important;
  mask-image: var(--trade-cover-mask) !important;
  mask-size: 100% 100% !important;
  mask-repeat: no-repeat !important;
}

/* Dark: superfície do modal mais suave, menos saturada e sem roxo quase preto. */
html[data-theme="dark"] #iphoneTradeOverlay {
  --trade-sheet-surface: linear-gradient(
    180deg,
    #302b38 0%,
    #2b2633 52%,
    #26222e 100%
  );
}
html[data-theme="dark"] #iphoneTradeOverlay .it-header {
  background: #302b38 !important;
}
html[data-theme="dark"] #iphoneTradeOverlay .it-form {
  background: transparent !important;
}

/* Refinamento Dark: campos em grafite-lavanda e capa superior sem máscara/fade. */
html[data-theme="dark"] #iphoneTradeOverlay .it-form input:not([type="file"]),
html[data-theme="dark"] #iphoneTradeOverlay .it-form select,
html[data-theme="dark"] #iphoneTradeOverlay .it-form textarea {
  background: #3a3443 !important;
  border-color: #887a9a !important;
  color: #fbf9ff !important;
  box-shadow: inset 0 1px 2px rgb(255 255 255 / .035) !important;
}

html[data-theme="dark"] #iphoneTradeOverlay .it-form input::placeholder,
html[data-theme="dark"] #iphoneTradeOverlay .it-form textarea::placeholder {
  color: #c9c1d2 !important;
  opacity: 1 !important;
}

html[data-theme="dark"] #iphoneTradeOverlay .it-form select option {
  background: #302b38;
  color: #fbf9ff;
}

#iphoneTradeOverlay .it-cover {
  -webkit-mask-image: var(--trade-cover-mask) !important;
  mask-image: var(--trade-cover-mask) !important;
  -webkit-mask-size: 100% 100% !important;
  mask-size: 100% 100% !important;
  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;
  opacity: 1 !important;
  filter: none !important;
  background: transparent !important;
}

/* Light: banner, cabeçalho e formulário compartilham a mesma base branco-lavanda. */
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-sheet {
  background: #f5f2fa !important;
}
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-header {
  background: #f5f2fa !important;
}
html:not([data-theme="dark"]) #iphoneTradeOverlay .it-form {
  background: #f5f2fa !important;
}

/* Validação explícita das seleções obrigatórias no formulário de troca. */
#iphoneTradeOverlay #it-selection-error {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid #d94b58;
  border-radius: 10px;
  color: #b42332;
  background: rgb(217 75 88 / .08);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
}
#iphoneTradeOverlay .it-form select[aria-invalid="true"] {
  border-color: #d94b58 !important;
  box-shadow: 0 0 0 2px rgb(217 75 88 / .14) !important;
}
html[data-theme="dark"] #iphoneTradeOverlay #it-selection-error {
  color: #ffb8bf;
  background: rgb(217 75 88 / .12);
}
