/* ── Cart Drawer (Knuspr-style) ── */
.cart-drawer-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,.4); opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.cart-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.cart-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 92vw; z-index: 8001;
  background: #fff;
  box-shadow: -4px 0 32px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  /* Verde Made in Market (em vez do amarelo global da loja) */
  --c-primary: #82AD49;
  --c-primary-dark: #6A9238;
  --c-primary-light: #e8f5ee;
}
.cart-drawer.open { transform: translateX(0); }

/* ── Header (verde Made in Market) ── */
.cart-drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.15rem;
  background: var(--c-primary-dark, #6A9238);
  color: #fff;
  flex-shrink: 0;
}
.cart-drawer__header-left {
  display: flex; align-items: center; gap: .65rem;
}
.cart-drawer__cart-icon {
  position: relative;
  width: 32px; height: 32px;
  display: grid; place-items: center;
}
.cart-drawer__cart-icon svg { stroke: #fff; }
.cart-drawer__badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  font-size: .6rem; font-weight: 700;
  background: var(--c-primary, #82AD49); color: #fff;
  border-radius: 999px;
  display: grid; place-items: center;
  line-height: 1;
}
.cart-drawer__total {
  font-size: 1.05rem; font-weight: 700;
}
.cart-drawer__close {
  width: 32px; height: 32px;
  border: none; background: rgba(255,255,255,.12);
  border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
  color: #fff; font-size: 1.15rem;
  transition: background .15s;
}
.cart-drawer__close:hover { background: rgba(255,255,255,.2); }

/* ── Body ── */
.cart-drawer__body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Empty state */
.cart-drawer__empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  min-height: 60vh;
}
.cart-drawer__empty svg { color: #d0d5d2; margin-bottom: 1rem; }
.cart-drawer__empty-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--c-text, #1a1d1b);
  margin-bottom: .4rem;
}
.cart-drawer__empty-text {
  font-size: .9rem; color: var(--c-text-muted, #6b706d);
  max-width: 28ch; line-height: 1.55;
  margin-bottom: .75rem;
}
.cart-drawer__empty-cta {
  display: inline-block;
  padding: .65rem 1.5rem;
  background: var(--c-primary, #82AD49); color: #fff;
  border-radius: 10px; font-weight: 700; font-size: .9rem;
  text-decoration: none;
  transition: background .15s;
}
.cart-drawer__empty-cta:hover { background: var(--c-primary-dark, #6A9238); text-decoration: none; }

/* ── Supplier group ── */
.cd-group {
  border-bottom: 6px solid var(--c-bg, #f5f5f3);
}
.cd-group__header {
  padding: .65rem 1.15rem;
  font-size: .78rem; font-weight: 800;
  color: #1a1d1b;
  background: #fff;
  border-bottom: 1px solid #e4e6e5;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Cart item ── */
.cd-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: .75rem;
  align-items: start;
  padding: .85rem 1.15rem;
  border-bottom: 1px solid var(--c-border, #e4e6e5);
  position: relative;
}
.cd-item__img {
  width: 56px; height: 56px;
  border-radius: 10px;
  background: var(--c-bg, #f5f5f3);
  display: grid; place-items: center;
  font-size: 1.3rem;
  overflow: hidden;
}
.cd-item__img img {
  width: 100%; height: 100%;
  object-fit: contain; padding: 2px;
}

.cd-item__info { min-width: 0; }
.cd-item__name {
  font-size: .84rem; font-weight: 600;
  line-height: 1.3; margin-bottom: .15rem;
  color: var(--c-text, #1a1d1b);
}
.cd-item__unit {
  font-size: .72rem;
  color: var(--c-text-muted, #6b706d);
  line-height: 1.25;
  margin-bottom: .2rem;
}
.cd-item__meta {
  font-size: .72rem; color: var(--c-text-muted, #6b706d);
  margin-bottom: .45rem;
}

.cd-item__controls {
  display: flex; align-items: center; gap: 0;
  background: var(--c-bg, #f5f5f3);
  border-radius: 8px;
  border: 1px solid var(--c-border, #e4e6e5);
  overflow: hidden;
}
.cd-item__trash {
  width: 32px; height: 32px;
  border: none; background: none;
  cursor: pointer; color: var(--c-text-muted, #999);
  display: grid; place-items: center;
  transition: color .15s, background .15s;
}
.cd-item__trash:hover { color: #dc2626; background: #fef2f2; }
.cd-item__qty {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700;
  color: var(--c-text, #1a1d1b);
  border-left: 1px solid var(--c-border, #e4e6e5);
  border-right: 1px solid var(--c-border, #e4e6e5);
}
.cd-item__plus {
  width: 32px; height: 32px;
  border: none; background: var(--c-primary, #82AD49);
  cursor: pointer; color: #fff;
  display: grid; place-items: center;
  font-size: 1.1rem; font-weight: 700;
  border-radius: 0 7px 7px 0;
  transition: background .15s;
}
.cd-item__plus:hover { background: var(--c-primary-dark, #6A9238); }

.cd-item__right {
  text-align: right;
  display: flex; flex-direction: column;
  align-items: flex-end; gap: .25rem;
}
.cd-item__price {
  font-size: .9rem; font-weight: 700;
  color: var(--c-text, #1a1d1b);
  white-space: nowrap;
}
.cd-item__remove {
  border: none; background: none;
  cursor: pointer; color: #ccc; font-size: .75rem;
  padding: 0; transition: color .15s;
}
.cd-item__remove:hover { color: #dc2626; }

/* ── Opções por produto: aceitar substituição + nota (estilo Continente) ── */
.cd-item__options {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 1rem;
  margin-top: .4rem;
}
.cd-item__sub {
  display: flex; align-items: center; gap: .4rem;
  font-size: .76rem; color: var(--c-text-muted, #6b706d);
  cursor: pointer; user-select: none;
}
.cd-item__sub input {
  width: 15px; height: 15px;
  accent-color: var(--c-primary, #82AD49);
  cursor: pointer; margin: 0;
}
.cd-item__note-btn {
  display: flex; align-items: center; gap: .3rem;
  border: none; background: none; padding: 0;
  font-size: .76rem; font-weight: 600;
  color: var(--c-primary, #82AD49);
  cursor: pointer; font-family: inherit;
  transition: color .15s;
}
.cd-item__note-btn:hover { color: var(--c-primary-dark, #6A9238); text-decoration: underline; }
.cd-item__note-btn.has-note { color: var(--c-primary-dark, #6A9238); }
.cd-item__note-preview {
  grid-column: 1 / -1;
  margin-top: .3rem;
  padding: .4rem .6rem;
  background: var(--c-bg, #f5f5f3);
  border-left: 3px solid var(--c-primary, #82AD49);
  border-radius: 6px;
  font-size: .74rem; color: var(--c-text, #1a1d1b);
  line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
}
.cd-item__note-form {
  grid-column: 1 / -1;
  margin-top: .4rem;
}
.cd-item__note-input {
  width: 100%;
  padding: .5rem .65rem;
  border: 1.5px solid var(--c-border, #e4e6e5);
  border-radius: 8px;
  font-size: .8rem; font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.cd-item__note-input:focus {
  outline: none;
  border-color: var(--c-primary, #82AD49);
}
.cd-item__note-actions {
  display: flex; gap: .5rem; margin-top: .35rem;
}
.cd-item__note-save {
  border: none; border-radius: 7px;
  padding: .4rem .9rem;
  background: var(--c-primary, #82AD49); color: #fff;
  font-size: .76rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.cd-item__note-save:hover { background: var(--c-primary-dark, #6A9238); }
.cd-item__note-cancel {
  border: none; border-radius: 7px;
  padding: .4rem .9rem;
  background: var(--c-bg, #f5f5f3); color: var(--c-text-muted, #6b706d);
  font-size: .76rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.cd-item__note-cancel:hover { background: var(--c-border, #e4e6e5); }

/* ── Footer ── */
.cart-drawer__footer {
  flex-shrink: 0;
  border-top: 1px solid var(--c-border, #e4e6e5);
  padding: .85rem 1.15rem;
  background: #fff;
}

/* Encomenda mínima - aviso positivo (não bloqueia) */
.cart-min-order {
  margin: .35rem 0 .15rem;
  font-size: .8rem;
}
.cart-min-order__track {
  background: #eee;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}
.cart-min-order__fill {
  background: #1f8b4c;
  height: 100%;
  width: 0;
  transition: width .3s ease;
}
.cart-min-order__msg {
  margin-top: .35rem;
  color: #1f8b4c;
  font-weight: 600;
}
.cart-min-order__msg--pending {
  color: #555;
  font-weight: 400;
}
.cart-min-order__msg--pending strong {
  font-weight: 700;
}
.cart-min-order.is-complete .cart-min-order__fill {
  background: #82AD49;
}

.cd-plus-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  margin: .55rem 0 .5rem;
  padding: .7rem .9rem;
  background: linear-gradient(135deg, #82AD49 0%, #1b6d3d 55%, #0f3d24 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, transform .15s, box-shadow .15s;
  font-family: inherit;
  box-sizing: border-box;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset;
}
.cd-plus-btn:hover {
  filter: brightness(1.06);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.cd-plus-btn__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .15rem .45rem;
  border-radius: 6px;
  background: var(--c-primary, #82AD49);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.cd-plus-btn__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .35);
}
.cd-plus-btn__text {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}
.cd-plus-btn__title {
  display: block;
  font-weight: 700;
  font-size: .9rem;
  line-height: 1.2;
  color: #fff;
}
.cd-plus-btn__sub {
  display: block;
  font-weight: 500;
  font-size: .72rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, .88);
}
.cd-plus-btn__arrow { opacity: .9; font-weight: 600; color: #fff; }

.cd-checkout-btn {
  display: block; width: 100%;
  padding: .85rem;
  background: var(--c-primary, #82AD49); color: #fff;
  border: none; border-radius: 12px;
  font-weight: 700; font-size: 1rem;
  text-align: center; cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.cd-checkout-btn:hover { background: var(--c-primary-dark, #6A9238); text-decoration: none; color: #fff; }
.cd-checkout-btn:disabled,
.cd-checkout-btn.is-disabled {
  background: #c5c9c3;
  color: #fff;
  cursor: not-allowed;
  opacity: .72;
  pointer-events: none;
}
.cd-checkout-btn:disabled:hover,
.cd-checkout-btn.is-disabled:hover {
  background: #c5c9c3;
  color: #fff;
}

.cd-continue-btn {
  display: block; width: 100%; margin-top: .5rem;
  padding: .55rem;
  background: transparent; color: var(--c-text-muted, #6b706d);
  border: none; font-weight: 500;
  font-size: .82rem; text-align: center; cursor: pointer;
  transition: color .15s;
}
.cd-continue-btn:hover { color: var(--c-primary, #82AD49); }

/* ── Cart toast ── */
.cart-toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--c-dark-bg, #1a1d1b); color: #fff;
  padding: .65rem 1.25rem;
  border-radius: 10px;
  font-size: .85rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 9999;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
}
.cart-toast.show { transform: translateX(-50%) translateY(0); }

/* ── Dark · Knuspr tangerine-dark ── */
html[data-theme="dark"] .cart-drawer {
  background: #252525;
  color: #f2f4f4;
  --c-primary: #9dcb9a;
  --c-primary-dark: #2a7337;
  --c-primary-light: #164523;
  box-shadow: -4px 0 32px rgba(0, 0, 0, .55);
}
html[data-theme="dark"] .cart-drawer__header {
  background: var(--c-primary-dark, #2a7337);
}
html[data-theme="dark"] .cart-drawer__footer {
  background: #252525;
  border-top-color: #374045;
}
html[data-theme="dark"] .cart-drawer__empty-title,
html[data-theme="dark"] .cd-item__name,
html[data-theme="dark"] .cd-group__title {
  color: #f2f4f4;
}
html[data-theme="dark"] .cart-drawer__empty-text,
html[data-theme="dark"] .cd-item__meta,
html[data-theme="dark"] .cd-item__unit,
html[data-theme="dark"] .cd-continue-btn {
  color: #b6bdc0;
}
html[data-theme="dark"] .cart-drawer__empty svg { color: #5d676c; }
html[data-theme="dark"] .cd-group {
  border-bottom-color: #000;
}
html[data-theme="dark"] .cd-group__header {
  background: #1c2529;
  border-bottom-color: #374045;
  color: #b6bdc0;
}
html[data-theme="dark"] .cd-item {
  border-color: #374045;
}
html[data-theme="dark"] .cd-item__img,
html[data-theme="dark"] .cd-item__ph {
  background: #1c2529;
}
html[data-theme="dark"] .cd-item__controls {
  background: #1c2529;
  border-color: #374045;
}
html[data-theme="dark"] .cd-item__qty {
  color: #f2f4f4;
  border-color: #374045;
}
html[data-theme="dark"] .cd-item__trash:hover {
  background: rgba(218, 64, 51, .18);
  color: #da4033;
}
html[data-theme="dark"] .cd-item__price { color: #f2f4f4; }
html[data-theme="dark"] .cd-item__plus {
  background: #9dcb9a;
  color: #0f351a;
}
html[data-theme="dark"] .cd-item__plus:hover {
  background: #2a7337;
  color: #fff;
}
html[data-theme="dark"] .cd-item__note-cancel {
  background: #1c2529;
  color: #b6bdc0;
}
html[data-theme="dark"] .cart-min-order__track { background: #374045; }
html[data-theme="dark"] .cart-min-order__fill { background: #9dcb9a; }
html[data-theme="dark"] .cart-min-order__msg { color: #9dcb9a; }
html[data-theme="dark"] .cart-min-order__msg--pending { color: #b6bdc0; }
html[data-theme="dark"] .cd-plus-btn {
  background: linear-gradient(135deg, #82AD49 0%, #1b6d3d 55%, #0f3d24 100%);
  border: none;
}
html[data-theme="dark"] .cd-plus-btn:hover { filter: brightness(1.08); }
html[data-theme="dark"] .cd-plus-btn__logo { background: #fff; }
html[data-theme="dark"] .cd-checkout-btn {
  background: #9dcb9a;
  color: #0f351a;
}
html[data-theme="dark"] .cd-checkout-btn:disabled,
html[data-theme="dark"] .cd-checkout-btn.is-disabled {
  background: #3a4246;
  color: #8a9397;
}
html[data-theme="dark"] .cd-checkout-btn:hover {
  background: #2a7337;
  color: #fff;
}
html[data-theme="dark"] .cart-drawer__empty-cta {
  background: #9dcb9a;
  color: #0f351a;
}
html[data-theme="dark"] .cart-drawer__empty-cta:hover {
  background: #2a7337;
  color: #fff;
}
