/* ============================================================
   Checkout — modal de compra (Nutriland Loja)
   Herda a linguagem visual da LP (tokens.css): fontes Baloo/Bricolage,
   botões com sombra empilhada, eyebrow tracked, card teal estilo "Kit".
   Responsivo: desktop, Android e iOS (bottom-sheet no mobile).
   ============================================================ */

:root { color-scheme: light; }

/* Escopo próprio (não depende do reset da LP) */
.co-backdrop, .co-backdrop *, .co-backdrop *::before, .co-backdrop *::after {
  box-sizing: border-box;
}

/* ---------- Backdrop ---------- */
.co-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 50, 44, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.co-backdrop[data-open='true'] { opacity: 1; }
body.co-locked { overflow: hidden; }

/* ---------- Modal ---------- */
.co-modal {
  background: var(--cream-soft);
  width: 100%;
  max-width: 580px;
  border-radius: var(--r-card-lg);
  box-shadow: var(--shadow-float);
  margin: auto;
  position: relative;
  transform: translateY(14px) scale(0.985);
  transition: transform 0.22s cubic-bezier(.2,.9,.3,1.1);
  font-family: var(--font-body);
  color: var(--teal-deep);
  overflow: hidden;
}
.co-backdrop[data-open='true'] .co-modal { transform: translateY(0) scale(1); }

/* ---------- Header ---------- */
.co-head {
  position: relative;
  display: flex;
  align-items: center;
  padding: 22px 48px;
  background: var(--cream);
  border-bottom: 1.5px solid var(--line);
}
.co-head__titles { flex: 1; min-width: 0; text-align: center; }
.co-eyebrow {
  font-family: var(--font-label);
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--tomato);
}
.co-title {
  font-family: var(--font-title);
  font-weight: 700; font-size: 24px; line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 2px 0 0;
  color: var(--teal-deep);
}
.co-sub { font-size: 13px; color: var(--teal); opacity: 0.75; margin: 4px 0 0; }

.co-close {
  position: absolute; top: 12px; right: 12px;
  border: 0; background: transparent;
  width: 44px; height: 44px; flex-shrink: 0;
  font-size: 28px; line-height: 1; cursor: pointer;
  color: #8a978f; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s ease, color .15s ease;
}
.co-close:hover { background: var(--cream-deep); color: var(--teal-deep); }

/* ---------- Body / steps ---------- */
.co-body {
  padding: 22px 24px calc(24px + env(safe-area-inset-bottom, 0px));
}
.co-steps { display: none; }
.co-steps[data-active='true'] { display: block; animation: co-fade 0.25s ease; }
@keyframes co-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Resumo do produto (estilo card "Kit" da LP) ---------- */
.co-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--teal-deep); color: var(--cream);
  border-radius: var(--r-card);
  padding: 16px 18px;
  margin-bottom: 18px;
  position: relative; overflow: hidden;
}
.co-summary::before {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 140px; height: 140px; border-radius: 50%;
  background: var(--tomato); opacity: 0.22; filter: blur(28px);
  pointer-events: none;
}
.co-summary__name {
  font-family: var(--font-label); font-weight: 700; font-size: 15px;
  line-height: 1.25; position: relative;
}
.co-summary__price {
  font-family: var(--font-title); font-weight: 800; font-size: 24px;
  color: var(--lime); position: relative; white-space: nowrap;
}

/* ---------- Form ---------- */
.co-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.co-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.co-field--full { grid-column: 1 / -1; }
.co-field label {
  font-family: var(--font-label);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--teal-deep);
}
.co-field input,
.co-field select {
  font-family: var(--font-body);
  font-size: 16px; /* >=16px evita zoom automático no iOS */
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-btn-sm);
  background: #fff;
  color: var(--teal-deep);
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.co-field input::placeholder { color: #aeb6ae; }
.co-field select {
  height: 47px; /* alinha com a altura do input ao lado */
  appearance: none; -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%232a6b5f' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.co-field input:focus,
.co-field select:focus {
  outline: none;
  border-color: var(--teal-mid);
  box-shadow: 0 0 0 3px rgba(42,107,95,0.15);
}
.co-field input[aria-invalid='true'],
.co-field select[aria-invalid='true'] {
  border-color: var(--tomato);
  box-shadow: 0 0 0 3px rgba(205,71,75,0.12);
}
.co-field input:disabled { background: #f1ece0; color: #8a857a; }
.co-field__err { font-size: 11.5px; color: var(--tomato); font-weight: 600; min-height: 0; line-height: 1.3; }

/* ---------- CEP: linha com botão + status de consulta ---------- */
.co-cep-row { display: flex; gap: 8px; align-items: stretch; }
.co-cep-row input { flex: 1; min-width: 0; }
.co-cep-btn {
  flex-shrink: 0;
  font-family: var(--font-label);
  font-size: 12.5px; font-weight: 700;
  padding: 0 14px;
  border: 1.5px solid var(--teal-mid);
  border-radius: var(--r-btn-sm);
  background: #fff; color: var(--teal-deep);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, opacity .15s ease;
}
.co-cep-btn:hover { background: var(--teal-mid); color: var(--cream); }
.co-cep-btn:disabled { opacity: 0.55; cursor: default; }
.co-cep-status {
  font-family: var(--font-body);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  text-transform: none;
}
.co-cep-status[data-state='loading'] { color: var(--teal); }
.co-cep-status[data-state='loading']::before {
  content: ''; display: inline-block; vertical-align: -1px;
  width: 10px; height: 10px; margin-right: 5px;
  border: 2px solid rgba(42,107,95,0.3); border-top-color: var(--teal);
  border-radius: 50%; animation: co-spin 0.6s linear infinite;
}
.co-cep-status[data-state='ok'] { color: var(--teal-mid); }
.co-cep-status[data-state='error'] { color: var(--tomato); }

.co-check {
  grid-column: 1 / -1;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px; line-height: 1.45; color: var(--teal);
  margin: 4px 0 2px;
}
.co-check input {
  margin-top: 1px; width: 20px; height: 20px; flex-shrink: 0;
  accent-color: var(--tomato); cursor: pointer;
}
.co-check a { color: var(--teal-deep); font-weight: 700; text-underline-offset: 2px; }

/* ---------- Botões (sombra empilhada como a LP) ---------- */
.co-grid #co-submit { grid-column: 1 / -1; }
.co-btn {
  appearance: none; -webkit-appearance: none;
  border: 0; width: 100%;
  font-family: var(--font-body); font-weight: 800; font-size: 16px;
  padding: 16px 20px; min-height: 52px;
  border-radius: var(--r-btn);
  cursor: pointer;
  background: var(--tomato); color: var(--cream);
  margin-top: 14px;
  box-shadow: var(--shadow-stack-tomato);
  transition: transform .15s cubic-bezier(.2,.9,.3,1.2), box-shadow .15s ease, background-color .15s ease;
}
.co-btn:hover {
  background: #d8565a;
  box-shadow: 0 7px 0 -2px var(--tomato-deep), 0 16px 26px -10px rgba(0,0,0,.4);
  transform: translateY(2px);
}
.co-btn:active {
  box-shadow: 0 4px 0 -2px var(--tomato-deep), 0 10px 18px -10px rgba(0,0,0,.4);
  transform: translateY(4px);
}
.co-btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: var(--shadow-stack-tomato); transform: none; }

.co-btn--ghost {
  background: transparent; color: var(--teal-deep);
  border: 1.5px solid var(--line);
  box-shadow: none; margin-top: 10px; min-height: 48px;
  font-weight: 700;
}
.co-btn--ghost:hover { background: var(--cream); box-shadow: none; transform: none; }
.co-btn--ghost:active { transform: translateY(1px); box-shadow: none; }

/* ---------- Alertas ---------- */
.co-alert {
  background: #fbe3e3; color: #9c1f1f;
  border: 1px solid #f0c5c5;
  border-radius: var(--r-btn-sm);
  padding: 11px 14px; font-size: 13px; font-weight: 600;
  margin-bottom: 14px;
}
.co-alert[hidden] { display: none; }

/* ---------- Pagamento (Pix) ---------- */
.co-pay { text-align: center; }
.co-pay__amount {
  font-family: var(--font-title); font-weight: 800; font-size: 30px;
  color: var(--tomato); margin: 0;
}
.co-pay__hint { font-size: 13.5px; color: var(--teal); opacity: 0.8; margin: 6px 0 16px; line-height: 1.5; }
.co-qr {
  width: 224px; height: 224px;
  margin: 0 auto 16px;
  background: #fff;
  border-radius: var(--r-card);
  padding: 12px;
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-card);
}
.co-qr img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }

.co-copy { display: flex; gap: 8px; margin: 0 0 20px; }
.co-copy input {
  flex: 1; min-width: 0;
  font-family: var(--font-body); font-size: 12px;
  padding: 12px; border: 1.5px solid var(--line);
  border-radius: var(--r-btn-sm); background: #fff; color: var(--teal);
}
.co-copy button {
  border: 0; background: var(--teal-deep); color: var(--cream);
  font-family: var(--font-body); font-weight: 800; font-size: 14px;
  padding: 0 18px; min-height: 46px;
  border-radius: var(--r-btn-sm); cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, transform .1s ease;
}
.co-copy button:active { transform: translateY(1px); }
.co-copy button.copied { background: var(--lime); color: var(--teal-deep); }

.co-pay__proof-label {
  font-family: var(--font-label);
  font-size: 13px; font-weight: 700; color: var(--teal-deep);
  margin: 0 0 8px; text-align: left;
}
.co-upload {
  display: block;
  border: 1.5px dashed var(--teal-mid);
  border-radius: var(--r-card);
  padding: 20px 16px; text-align: center;
  background: var(--cream);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.co-upload:hover, .co-upload.dragover { background: var(--cream-deep); border-color: var(--teal-deep); }
.co-upload__label { font-size: 13.5px; color: var(--teal); line-height: 1.45; }
.co-upload__file { display: block; font-size: 13px; color: var(--teal-deep); font-weight: 800; margin-top: 8px; word-break: break-all; }
.co-upload input { display: none; }

/* ---------- Sucesso ---------- */
.co-success { text-align: center; padding: 12px 0 4px; }
.co-success__icon {
  width: 72px; height: 72px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--lime); color: var(--teal-deep);
  display: grid; place-items: center;
  box-shadow: 0 12px 0 -3px #9cae3f, 0 18px 28px -12px rgba(0,0,0,.3);
}
.co-success h3 {
  font-family: var(--font-title); font-weight: 700; font-size: 26px;
  color: var(--teal-deep); margin: 0 0 10px; letter-spacing: -0.02em;
}
.co-success p { font-size: 15px; color: var(--teal); line-height: 1.55; margin: 0 0 10px; max-width: 420px; margin-left: auto; margin-right: auto; }
.co-success a { color: var(--teal-deep); font-weight: 800; }

/* ---------- Spinner ---------- */
.co-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(250,243,227,0.5); border-top-color: var(--cream);
  border-radius: 50%; animation: co-spin 0.7s linear infinite;
  vertical-align: -3px; margin-right: 8px;
}
@keyframes co-spin { to { transform: rotate(360deg); } }

/* focus-visible consistente com a LP */
.co-modal :focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 6px; }

/* ============================================================
   RESPONSIVO
   ============================================================ */

/* Tablet pequeno */
@media (max-width: 600px) {
  .co-title { font-size: 22px; }
  .co-pay__amount { font-size: 26px; }
}

/* Mobile: vira bottom-sheet colado à base, ocupando a largura toda */
@media (max-width: 520px) {
  .co-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .co-modal {
    max-width: 100%;
    border-radius: 22px 22px 0 0;
    max-height: 100%;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(.2,.9,.3,1.05);
  }
  .co-backdrop[data-open='true'] .co-modal { transform: translateY(0); }

  /* header fixo no topo do sheet, corpo rola */
  .co-head { position: sticky; top: 0; z-index: 2; }
  .co-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }

  .co-grid { grid-template-columns: 1fr; gap: 13px; }
  .co-qr { width: 200px; height: 200px; }
  .co-summary { padding: 14px 16px; }
  .co-summary__price { font-size: 22px; }
}

/* Telas muito estreitas (≤340px) */
@media (max-width: 340px) {
  .co-head { padding: 18px 44px; }
  .co-body { padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .co-qr { width: 180px; height: 180px; }
}

/* Altura curta (paisagem no celular): topo alinhado e rolagem */
@media (max-height: 560px) {
  .co-backdrop { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .co-backdrop, .co-modal, .co-steps, .co-btn { transition: none; animation: none; }
}
