/**
 * Commerce overlays + utilitários mínimos usados por drawers/app.js.
 * Substitui a dependência acidental do Tailwind CDN na homepage SUN.
 */

.hidden,
[hidden] {
  display: none !important;
}

.sun-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.sun-overlay:not(.hidden) {
  display: block;
}

.sun-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 43, 58, 0.48);
  backdrop-filter: blur(4px);
}

.sun-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 28rem);
  background: var(--sun-surface);
  color: var(--sun-text);
  border-left: 1px solid var(--sun-border);
  box-shadow: var(--sun-shadow-hover);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow: hidden;
  z-index: 61;
}

.sun-drawer--wide {
  width: min(100%, 36rem);
}

/* ——— Checkout SUN drawer direito (Missão 12 design + Missão 14 estrutura) ——— */
.sun-checkout {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(100%, 720px);
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  background: var(--sun-surface);
  color: var(--sun-text);
  border: 0;
  border-left: 1px solid var(--sun-border);
  border-radius: 0;
  box-shadow: -12px 0 40px rgba(8, 43, 58, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#checkout-modal:not(.hidden) .sun-checkout {
  animation: sun-checkout-slide-in 240ms ease;
}
@keyframes sun-checkout-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  #checkout-modal:not(.hidden) .sun-checkout {
    animation: none;
  }
}
.sun-checkout__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sun-border);
  background: var(--sun-surface);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.sun-checkout__eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sun-action, #167A50);
}
.sun-checkout__head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--sun-primary, #082B3A);
}
.sun-checkout__step-label {
  display: none;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--sun-text-secondary);
}
.sun-checkout-stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  padding: 0;
}
.sun-checkout-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  min-height: 2.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--sun-border);
  background: var(--sun-surface-muted, #F5F8F7);
  color: var(--sun-text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}
.sun-checkout-step__num {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--sun-border);
  font-size: 0.72rem;
}
.sun-checkout-step__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sun-checkout-step.is-active {
  background: var(--sun-primary, #082B3A);
  border-color: var(--sun-primary, #082B3A);
  color: #fff;
}
.sun-checkout-step.is-active .sun-checkout-step__num {
  background: var(--sun-solar, #FFCB45);
  border-color: transparent;
  color: var(--sun-primary, #082B3A);
}
.sun-checkout-step.is-done {
  background: rgba(22, 122, 80, 0.1);
  border-color: rgba(22, 122, 80, 0.35);
  color: var(--sun-action, #167A50);
}
.sun-checkout-step.is-done .sun-checkout-step__num {
  background: var(--sun-action, #167A50);
  border-color: transparent;
  color: #fff;
}

.sun-checkout__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  align-items: stretch;
  -webkit-overflow-scrolling: touch;
}
.sun-checkout__main {
  overflow: visible;
  padding: 1.15rem 1.25rem calc(1.35rem + env(safe-area-inset-bottom, 0px));
  min-height: 0;
}
.sun-checkout-panel__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--sun-primary, #082B3A);
}
.sun-checkout-panel__lead {
  margin: 0 0 1rem;
  color: var(--sun-text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}
.sun-checkout-fields {
  display: grid;
  gap: 0.85rem;
}
.sun-checkout .sun-field input,
.sun-checkout .sun-field select {
  min-height: 48px;
  border-radius: 12px;
}
.sun-field__optional {
  font-weight: 500;
  color: var(--sun-text-secondary);
  text-transform: none;
  letter-spacing: 0;
}
.sun-checkout-privacy,
.sun-checkout-status {
  margin: 0.85rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--sun-text-secondary);
}
.sun-checkout-privacy a { color: var(--sun-action, #167A50); }
.sun-checkout-optin {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--sun-text-secondary);
}
.sun-checkout-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.25rem;
}
.sun-checkout-actions--split { justify-content: space-between; }
.sun-checkout-actions .sun-btn { min-height: 48px; }

.sun-pay-methods {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.sun-pay-method {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--sun-border);
  border-radius: 14px;
  background: var(--sun-surface);
  cursor: pointer;
}
.sun-pay-method input { margin-top: 0.2rem; }
.sun-pay-method__body { display: grid; gap: 0.15rem; }
.sun-pay-method__body strong { color: var(--sun-primary, #082B3A); font-size: 0.95rem; }
.sun-pay-method__body span { color: var(--sun-text-secondary); font-size: 0.8rem; }
.sun-pay-method.is-selected,
.sun-pay-method:has(input:checked) {
  border-color: var(--sun-action, #167A50);
  box-shadow: inset 0 0 0 1px var(--sun-action, #167A50);
  background: rgba(22, 122, 80, 0.06);
}

.sun-order-summary {
  border-top: 1px solid var(--sun-border);
  background: var(--sun-bg, #F5F8F7);
  overflow-y: auto;
}
.sun-order-summary__desktop { display: none; padding: 1.15rem 1.25rem; }
.sun-order-summary__desktop h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--sun-primary, #082B3A);
}
.sun-order-summary__mobile { padding: 0; }
.sun-order-summary__toggle {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--sun-primary, #082B3A);
}
.sun-order-summary__toggle::-webkit-details-marker { display: none; }
.sun-order-summary__body { padding: 0 1.25rem 1.15rem; }
.sun-order-summary__items { display: grid; gap: 0.65rem; margin-bottom: 0.85rem; }
.sun-order-line {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.65rem;
  align-items: center;
}
.sun-order-line img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--sun-border);
}
.sun-order-line__title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sun-text);
  line-height: 1.3;
}
.sun-order-line__meta {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--sun-text-secondary);
}
.sun-order-line__price {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--sun-action, #167A50);
  white-space: nowrap;
}
.sun-order-summary__totals {
  margin: 0;
  display: grid;
  gap: 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sun-border);
}
.sun-order-summary__totals > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
}
.sun-order-summary__totals dt { margin: 0; color: var(--sun-text-secondary); }
.sun-order-summary__totals dd { margin: 0; font-weight: 700; }
.sun-order-summary__totals .is-total {
  margin-top: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--sun-border);
  font-size: 1rem;
  color: var(--sun-primary, #082B3A);
}
.sun-checkout-review {
  display: grid;
  gap: 0.75rem;
}
.sun-checkout-review__card {
  border: 1px solid var(--sun-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: var(--sun-surface-muted, #F5F8F7);
}
.sun-checkout-review__card h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sun-text-secondary);
}
.sun-checkout-review__card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--sun-text);
}

@media (max-width: 767px) {
  .sun-checkout {
    width: 100%;
    border-left: 0;
  }
  .sun-checkout-stepper { display: none; }
  .sun-checkout__step-label { display: block; }
  .sun-checkout-fields { grid-template-columns: 1fr; }
  .sun-order-summary__desktop { display: none; }
  .sun-order-summary__mobile { display: block; }
}

/* Drawer ≥640px: form + resumo lado a lado dentro do painel */
@media (min-width: 640px) {
  .sun-checkout__layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(14rem, 0.85fr);
  }
  .sun-checkout-fields {
    grid-template-columns: 1fr 1fr;
  }
  .sun-checkout-fields .sun-field--span2,
  .sun-checkout-fields .sun-field:first-child {
    grid-column: 1 / -1;
  }
  .sun-order-summary {
    border-top: 0;
    border-left: 1px solid var(--sun-border);
    position: sticky;
    top: 0;
    align-self: stretch;
    max-height: none;
    height: 100%;
  }
  .sun-order-summary__mobile { display: none; }
  .sun-order-summary__desktop { display: block; }
}

@media (min-width: 1280px) {
  .sun-checkout { width: min(100%, 760px); }
}

.sun-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--sun-border);
}

.sun-drawer__head h2,
.sun-drawer__head h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--sun-text);
  font-weight: 800;
}

.sun-cart-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--sun-border);
  border-radius: var(--sun-radius-lg);
  background: var(--sun-surface-muted);
  margin-bottom: 0.65rem;
}
.sun-cart-line__img {
  width: 48px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}
.sun-cart-line__body { flex: 1; min-width: 0; }
.sun-cart-line__title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sun-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sun-cart-line__price {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--sun-action);
}
.sun-cart-line__qty {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
}
.sun-qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--sun-border);
  background: var(--sun-surface);
  color: var(--sun-text);
  font-weight: 700;
  cursor: pointer;
}
.sun-cart-line__qty-val {
  min-width: 1.25rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.sun-cart-line__remove {
  border: 0;
  background: transparent;
  color: var(--sun-text-secondary);
  cursor: pointer;
  padding: 0.35rem;
}
.sun-cart-line__remove:hover { color: var(--sun-error); }
.sun-cart-line__remove svg { width: 16px; height: 16px; }

.sun-cart-suggest {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem;
  border: 1px solid var(--sun-border);
  border-radius: var(--sun-radius-md);
  background: var(--sun-surface);
  margin-bottom: 0.5rem;
}
.sun-cart-suggest__img {
  width: 40px;
  height: 56px;
  object-fit: contain;
}
.sun-cart-suggest__title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sun-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sun-cart-suggest__price {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sun-action);
}
.sun-btn--sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
}

.sun-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sun-drawer__foot {
  border-top: 1px solid var(--sun-border);
  padding-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.sun-field {
  display: grid;
  gap: 0.35rem;
}

.sun-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sun-text-secondary);
}

.sun-field input,
.sun-field select,
.sun-field textarea {
  min-height: 44px;
  border: 1px solid var(--sun-border);
  border-radius: var(--sun-radius-md);
  padding: 0.65rem 0.85rem;
  font: inherit;
  background: var(--sun-surface);
  color: var(--sun-text);
}

.sun-field input:focus-visible,
.sun-field select:focus-visible,
.sun-field textarea:focus-visible {
  outline: 3px solid var(--sun-focus);
  outline-offset: 1px;
}

.sun-grid-2 {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .sun-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.sun-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-top: 1rem;
}

.sun-stepper__pill {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.55rem 0.25rem;
  border-radius: var(--sun-radius-md);
  background: var(--sun-surface-muted);
  color: var(--sun-text-secondary);
}

.sun-stepper__pill.is-active {
  background: var(--sun-primary);
  color: var(--sun-text-inverse);
}

.sun-modal-panel {
  position: relative;
  z-index: 61;
  width: min(100% - 2rem, 40rem);
  margin: 4rem auto;
  background: var(--sun-surface);
  border: 1px solid var(--sun-border);
  border-radius: var(--sun-radius-xl);
  box-shadow: var(--sun-shadow-hover);
  padding: 1.5rem;
}

.sun-product-card {
  background: var(--sun-surface);
  border: 1px solid var(--sun-border);
  border-radius: var(--sun-radius-lg);
  box-shadow: var(--sun-shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--sun-motion-default) ease, transform var(--sun-motion-fast) ease;
}

.sun-product-card:hover {
  box-shadow: var(--sun-shadow-hover);
  transform: translateY(-2px);
}

.sun-product-card__media {
  aspect-ratio: 1;
  background: var(--sun-surface-muted);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.sun-product-card__media img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
}

.sun-product-card__body {
  padding: 1.1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.sun-product-card__brand {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sun-text-secondary);
}

.sun-product-card__title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--sun-text);
  font-weight: 800;
}

.sun-product-card__title a {
  color: inherit;
  text-decoration: none;
}

.sun-product-card__specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sun-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: var(--sun-radius-pill);
  background: var(--sun-surface-muted);
  color: var(--sun-text);
  border: 1px solid var(--sun-border);
}

.sun-product-card__price {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--sun-text);
}

.sun-product-card__price.is-pending {
  font-size: 0.95rem;
  color: var(--sun-text-secondary);
}

.sun-product-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: auto;
}

.sun-stock {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sun-action);
}

.sun-stock.is-out {
  color: var(--sun-error);
}

/* Compat mínima para HTML legado ainda emitido pelo app.js em drawers antigos */
.fixed { position: fixed; }
.inset-0 { inset: 0; }
.inset-y-0 { top: 0; bottom: 0; }
.right-0 { right: 0; }
.z-50 { z-index: 50; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.grid { display: grid; }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.relative { position: relative; }
.absolute { position: absolute; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.pt-3 { padding-top: 0.75rem; }
.pb-4 { padding-bottom: 1rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.rounded-xl { border-radius: var(--sun-radius-md); }
.rounded-2xl { border-radius: var(--sun-radius-lg); }
.rounded-3xl { border-radius: var(--sun-radius-xl); }
.rounded-full { border-radius: 999px; }
.min-h-screen { min-height: 100vh; }
