/* ==========================================================================
   Impermanência — Checkout Modal (SuperFrete + Stripe) & Barra A/B
   ========================================================================== */

dialog#impCheckoutDialog,
dialog#impOrderSuccessDialog {
  border: 1px solid #CFB59F;
  border-radius: 14px;
  padding: 0;
  width: min(640px, 94vw);
  max-height: 92dvh;
  background: #FFFBF5;
  color: #2C201A;
  box-shadow: 0 24px 64px rgba(44, 32, 26, 0.35);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog#impCheckoutDialog::backdrop,
dialog#impOrderSuccessDialog::backdrop {
  background-color: rgba(28, 20, 16, 0.68);
  backdrop-filter: blur(4px);
}

.imp-modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px;
  background: #2C201A;
  color: #FFFBF5;
  border-bottom: 1px solid rgba(255, 251, 245, 0.12);
}

.imp-modal-header h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  color: #FFFBF5;
}

.imp-modal-header p {
  font-size: 12px;
  color: #E7C3A4;
  margin: 3px 0 0;
}

.imp-close-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFBF5;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.18s;
}

.imp-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.imp-modal-body {
  padding: 24px 26px 28px;
}

/* Resumo do Produto no Topo */
.imp-product-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #F4EDE2;
  border: 1px solid #D6C9B4;
  border-radius: 10px;
  margin-bottom: 22px;
}

.imp-product-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.imp-product-info img {
  width: 46px;
  height: auto;
  border-radius: 3px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.18);
}

.imp-product-title {
  font-weight: 600;
  font-size: 15px;
  color: #2C201A;
}

.imp-product-sub {
  font-size: 12px;
  color: #705D50;
}

.imp-qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFBF5;
  border: 1px solid #CFB59F;
  border-radius: 8px;
  padding: 4px 8px;
}

.imp-qty-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: #EDE0D1;
  color: #2C201A;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.imp-qty-val {
  font-size: 14px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* Fieldsets e Formulário */
.imp-fieldset {
  border: 1px solid #E1CBB6;
  border-radius: 10px;
  padding: 16px 18px 18px;
  margin: 0 0 18px 0;
  background: #FFFFFF;
}

.imp-fieldset legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #99462F;
  padding: 0 8px;
}

.imp-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.imp-field {
  margin-block-end: 14px;
}

.imp-field:last-child {
  margin-block-end: 0;
}

.imp-field-full {
  grid-column: 1 / -1;
}

.imp-field label {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #2C201A;
  margin-bottom: 3px;
  padding: 6px 0;
  margin-top: -6px;
}

.imp-hint {
  display: block;
  color: #705D50;
  font-size: 11.5px;
  margin-bottom: 5px;
  line-height: 1.35;
}

.imp-field input[type="text"],
.imp-field input[type="email"],
.imp-field input[type="tel"] {
  width: 100%;
  font-size: 1rem;
  padding: 11px 13px;
  min-height: 48px;
  border: 1.5px solid #CFB59F;
  border-radius: 8px;
  background: #FFFBF5;
  color: #2C201A;
  transition: border-color 0.15s, background-color 0.15s;
}

.imp-field input:focus-visible {
  outline: 3px solid #C97A52;
  outline-offset: 2px;
  border-color: #99462F;
}

/* Validação pós-interação (:user-invalid e :user-valid + fallback) */
.imp-error-msg {
  display: none;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 500;
  margin-top: 5px;
}

.imp-field input:user-invalid,
.imp-field input.user-invalid-fallback {
  border-color: #b91c1c;
  background-color: #fef2f2;
}

.imp-field input:user-invalid + .imp-error-msg,
.imp-field input.user-invalid-fallback + .imp-error-msg {
  display: block;
}

.imp-field input:user-valid,
.imp-field input.user-valid-fallback {
  border-color: #15803d;
}

/* CEP Row + SuperFrete Button */
.imp-cep-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.imp-cep-row input {
  flex: 1;
}

.imp-calc-freight-btn {
  padding: 0 18px;
  min-height: 48px;
  background: #263C3D;
  color: #FFFBF5;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s;
}

.imp-calc-freight-btn:hover {
  background: #1b2c2d;
}

.imp-calc-freight-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Opções de Frete SuperFrete (Radio Cards) */
.imp-shipping-options {
  margin-top: 12px;
  display: grid;
  gap: 9px;
}

.imp-shipping-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid #D6C9B4;
  border-radius: 9px;
  background: #FFFBF5;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.imp-shipping-card:hover {
  border-color: #99462F;
}

.imp-shipping-card:has(input:checked) {
  border-color: #99462F;
  background: #F6EFE6;
  box-shadow: 0 0 0 1px #99462F;
}

.imp-shipping-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.imp-shipping-left input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #99462F;
  margin: 0;
}

.imp-shipping-name {
  font-size: 14px;
  font-weight: 600;
  color: #2C201A;
}

.imp-shipping-meta {
  font-size: 12px;
  color: #705D50;
}

.imp-shipping-price {
  font-size: 15px;
  font-weight: 700;
  color: #99462F;
  white-space: nowrap;
}

.imp-superfrete-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #263C3D;
  background: #E2E9E6;
  padding: 3px 9px;
  border-radius: 99px;
  font-weight: 600;
  margin-top: 8px;
}

/* Resumo Financeiro */
.imp-totals-box {
  background: #F4EDE2;
  border: 1px solid #D6C9B4;
  border-radius: 10px;
  padding: 15px 18px;
  margin-bottom: 18px;
}

.imp-total-line {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: #584638;
  margin-bottom: 7px;
}

.imp-total-line.imp-grand-total {
  font-size: 17px;
  font-weight: 700;
  color: #2C201A;
  border-top: 1px solid #CFB59F;
  padding-top: 10px;
  margin-top: 8px;
  margin-bottom: 0;
}

.imp-submit-btn {
  width: 100%;
  min-height: 54px;
  background: #99462F;
  color: #FFFBF5;
  border: 0;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.18s, transform 0.15s;
}

.imp-submit-btn:hover {
  background: #7B3622;
  transform: translateY(-1px);
}

.imp-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.imp-security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
  font-size: 11.5px;
  color: #705D50;
  text-align: center;
  flex-wrap: wrap;
}

/* Barra Flutuante de Controle A/B + Admin Quick Link */
.imp-ab-toolbar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(33, 24, 18, 0.94);
  color: #FFFBF5;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.imp-ab-toolbar span.imp-ab-badge {
  background: #B5613A;
  color: #fff;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
}

.imp-ab-toolbar a {
  color: #F3CEAF;
  text-decoration: none;
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 500;
  transition: background 0.15s;
}

.imp-ab-toolbar a:hover,
.imp-ab-toolbar a.active {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}

@media (max-width: 640px) {
  .imp-form-grid {
    grid-template-columns: 1fr;
  }
  .imp-modal-body {
    padding: 18px 16px 24px;
  }
  .imp-modal-header {
    padding: 16px;
  }
}
