/* JO Carrito lateral y WhatsApp */

:root {
  --jo-cw-dark: var(--jo-dark, #0e3d3e);
  --jo-cw-mid: var(--jo-mid, #1a5657);
  --jo-cw-gold: var(--jo-gold, #c9a96e);
  --jo-cw-cream: var(--jo-cream, #faf8f5);
  --jo-cw-stone: var(--jo-stone, #e8e3dc);
  --jo-cw-muted: var(--jo-muted, #8a847c);
  --jo-cw-danger: #a8322d;
  --jo-cw-sans: var(--jo-font-sans, 'Questrial', sans-serif);
  --jo-cw-serif: var(--jo-font-serif, 'Playfair Display', serif);
  --jo-cw-ease: var(--jo-ease, cubic-bezier(.4, 0, .2, 1));
  --jo-cw-banner: 0px;
  --jo-cw-sbar: 0px;
}

/* ═════════ Capas: el carrito siempre por encima de la barra de descuento ═════════ */

#joMinicart { z-index: 1200 !important; }
body.jo-cw-open #joOverlay { z-index: 1150 !important; }
body.jo-cw-open #joBanner,
body.jo-cw-open #joSbar,
body.jo-cw-open .jo-toast { visibility: hidden !important; }

/* ═════════ Carrito lateral ═════════ */

#joMinicart .jo-minicart__title { display: inline-flex; gap: .5em; align-items: baseline; }
#joMinicart .jo-cw-count { color: var(--jo-cw-muted); letter-spacing: .08em; font-weight: 400; }

/* Barra de carga */
#joMinicart { overflow: hidden; }
#joMinicart::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--jo-cw-gold), transparent);
  background-size: 50% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity .2s;
}
#joMinicart.jo-cw-loading::after { opacity: 1; animation: jo-cw-bar 1s linear infinite; }
@keyframes jo-cw-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* Aviso superior */
.jo-cw-notice {
  display: flex; align-items: center; gap: 10px;
  max-height: 0; overflow: hidden; opacity: 0;
  padding: 0 24px;
  font-family: var(--jo-cw-sans); font-size: .78rem; line-height: 1.4; color: var(--jo-cw-dark);
  transition: max-height .3s var(--jo-cw-ease), opacity .25s, padding .3s var(--jo-cw-ease);
}
.jo-cw-notice.is-on { max-height: 80px; opacity: 1; padding: 12px 24px; }
.jo-cw-notice--ok { background: #f6f0e4; border-bottom: 1px solid #ecdfc6; }
.jo-cw-notice--info { background: var(--jo-cw-cream); border-bottom: 1px solid var(--jo-cw-stone); }
.jo-cw-notice--warn { background: #fbefee; border-bottom: 1px solid #f1d6d3; color: #7a231f; }
.jo-cw-notice > span:not(.jo-cw-notice__ico) { flex: 1; min-width: 0; }
.jo-cw-notice__ico {
  width: 20px; height: 20px; border-radius: 50%; background: var(--jo-cw-gold);
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px;
}
.jo-cw-notice__ico svg { width: 10px; height: 10px; stroke: #fff; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.jo-cw-notice__undo {
  flex: 0 0 auto; background: none; border: 0; padding: 4px 0; cursor: pointer;
  font-family: var(--jo-cw-sans); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--jo-cw-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}

/* Lista */
.jo-cw-body { scroll-behavior: smooth; }
.jo-cw-items { list-style: none; margin: 0; padding: 0; }
.jo-cw-item {
  display: grid; grid-template-columns: 76px 1fr 32px; gap: 14px; align-items: start;
  padding: 16px 0; border-bottom: 1px solid #f1ede7;
  transition: opacity .2s, transform .22s var(--jo-cw-ease);
}
.jo-cw-item:last-child { border-bottom: 0; }
.jo-cw-item.is-busy { opacity: .55; pointer-events: none; }
.jo-cw-item.is-leaving { opacity: 0; transform: translateX(24px); }
.jo-cw-item.is-new { animation: jo-cw-flash 2.4s var(--jo-cw-ease); }
@keyframes jo-cw-flash { 0%, 35% { background: #f8f2e6; box-shadow: -24px 0 0 #f8f2e6, 24px 0 0 #f8f2e6; } 100% { background: transparent; box-shadow: -24px 0 0 transparent, 24px 0 0 transparent; } }

.jo-cw-item__img { display: block; width: 76px; height: 76px; background: var(--jo-cw-cream); border-radius: 4px; overflow: hidden; }
.jo-cw-item__img img { width: 100% !important; height: 100% !important; object-fit: contain; display: block; margin: 0; }
.jo-cw-item__info { min-width: 0; font-family: var(--jo-cw-sans); }
.jo-cw-item__tag {
  display: inline-block; margin-bottom: 4px;
  font-size: .56rem; letter-spacing: .16em; text-transform: uppercase; color: #9c7a3c;
}
.jo-cw-item__name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .8rem; line-height: 1.4; color: var(--jo-cw-dark); text-decoration: none;
}
a.jo-cw-item__name:hover { text-decoration: underline; text-underline-offset: 2px; }
.jo-cw-item__meta { margin-top: 3px; font-size: .7rem; color: var(--jo-cw-muted); line-height: 1.45; }
.jo-cw-item__meta dl, .jo-cw-item__meta dd, .jo-cw-item__meta p { margin: 0; }
.jo-cw-item__meta dt, .jo-cw-item__meta dd { display: inline; font-weight: 400; }
.jo-cw-item__meta dd::after { content: ""; display: block; }
.jo-cw-item__meta dd p { display: inline; }
.jo-cw-item__unit { margin-top: 2px; font-size: .68rem; color: var(--jo-cw-muted); }

.jo-cw-item__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.jo-cw-item__price { font-size: .84rem; font-weight: 600; color: var(--jo-cw-dark); white-space: nowrap; }
.jo-cw-item__price del { font-weight: 400; color: var(--jo-cw-muted); margin-right: 4px; }
.jo-cw-qty-fixed { font-size: .7rem; color: var(--jo-cw-muted); }

.jo-cw-qty {
  display: inline-flex; align-items: center; height: 32px;
  border: 1px solid var(--jo-cw-stone); border-radius: 999px; background: #fff;
}
.jo-cw-qty button {
  width: 32px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  color: var(--jo-cw-dark); transition: background .15s;
}
.jo-cw-qty button:hover:not([disabled]) { background: var(--jo-cw-cream); }
.jo-cw-qty button[disabled] { opacity: .3; cursor: default; }
.jo-cw-qty svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.jo-cw-qty__n { min-width: 22px; text-align: center; font-family: var(--jo-cw-sans); font-size: .78rem; color: var(--jo-cw-dark); }

.jo-cw-item__remove {
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--jo-cw-muted);
  transition: background .15s, color .15s;
}
.jo-cw-item__remove:hover, .jo-cw-item__remove:focus-visible { background: #fbefee; color: var(--jo-cw-danger); }
.jo-cw-item__remove svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

#joMinicart button:focus-visible, #joMinicart a:focus-visible { outline: 2px solid var(--jo-cw-gold); outline-offset: 2px; }

/* Cesta vacía */
.jo-cw-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 12px; gap: 6px; font-family: var(--jo-cw-sans);
}
.jo-cw-empty svg { width: 40px; height: 40px; stroke: var(--jo-cw-gold); fill: none; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 10px; }
.jo-cw-empty__title { margin: 0; font-family: var(--jo-cw-serif); font-size: 1.2rem; color: var(--jo-cw-dark); }
.jo-cw-empty__text { margin: 0 0 18px; font-size: .8rem; color: var(--jo-cw-muted); }
.jo-cw-empty .jo-cw-btn { width: auto; padding: 12px 32px; }

/* Pie */
.jo-cw-footer.is-empty { display: none; }
.jo-cw-sum { margin-bottom: 6px; font-family: var(--jo-cw-sans); }
.jo-cw-sum__row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .82rem; color: var(--jo-cw-dark); letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  padding: 2px 0;
}
.jo-cw-sum__row--disc { font-weight: 400; color: #2e6b3e; font-size: .76rem; }
.jo-cw-note { margin: 0 0 14px; font-family: var(--jo-cw-sans); font-size: .68rem; color: var(--jo-cw-muted); }

.jo-cw-btn {
  display: block; width: 100%; padding: 14px; box-sizing: border-box; text-align: center; text-decoration: none;
  font-family: var(--jo-cw-sans); font-size: .64rem; letter-spacing: .2em; text-transform: uppercase;
  transition: background .2s, border-color .2s, color .2s; cursor: pointer;
}
.jo-cw-btn--dark { background: var(--jo-cw-dark); color: #fff; border: 1px solid var(--jo-cw-dark); }
.jo-cw-btn--dark:hover { background: var(--jo-cw-mid); color: #fff; }
.jo-cw-btn--outline { background: #fff; color: var(--jo-cw-dark); border: 1px solid var(--jo-cw-stone); }
.jo-cw-btn--outline:hover { border-color: var(--jo-cw-dark); background: var(--jo-cw-cream); color: var(--jo-cw-dark); }
.jo-cw-footer .jo-cw-btn--outline { margin-top: 8px; }
.jo-cw-continue {
  display: block; margin: 12px auto 0; padding: 4px 8px; border: 0; background: none; cursor: pointer;
  font-family: var(--jo-cw-sans); font-size: .7rem; color: var(--jo-cw-muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.jo-cw-continue:hover { color: var(--jo-cw-dark); }

@media (max-width: 480px) {
  .jo-cw-item { grid-template-columns: 64px 1fr 32px; gap: 12px; }
  .jo-cw-item__img { width: 64px; height: 64px; }
  .jo-cw-notice, .jo-cw-notice.is-on { padding-left: 16px; padding-right: 16px; }
}

/* ═════════ Botón "Añadir a la cesta" mientras añade ═════════ */

.jo-cw-btn-loading { position: relative !important; color: transparent !important; pointer-events: none; }
.jo-cw-btn-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: jo-cw-spin .7s linear infinite;
}
@keyframes jo-cw-spin { to { transform: rotate(360deg); } }

.jo-cw-form-error {
  flex-basis: 100%; width: 100%; margin-top: 12px; padding: 10px 14px;
  border-left: 3px solid var(--jo-cw-danger); background: #fbefee; color: #7a231f;
  font-family: var(--jo-cw-sans); font-size: .8rem; line-height: 1.45;
}
.jo-cw-form-error p { margin: 0; }
.jo-cw-form-error p + p { margin-top: 4px; }

/* ═════════ Barra de descuento: no tapa nada ═════════ */

body.jo-cw-no-banner #joBanner { display: none !important; }
body.jo-cw-banner-fix { padding-bottom: var(--jo-cw-banner); }
body.jo-cw-banner-fix #joSbar { bottom: var(--jo-cw-banner) !important; }

@media (max-width: 768px) {
  body.jo-cw-banner-fix #joBanner {
    padding: 10px 42px 10px 14px !important; gap: 12px !important;
    justify-content: space-between !important; text-align: left;
    font-size: 12px !important; letter-spacing: .02em !important; line-height: 1.35;
  }
  body.jo-cw-banner-fix #joBanner > span { flex: 1; min-width: 0; }
  body.jo-cw-banner-fix #joBanner > a { flex: 0 0 auto; padding: 9px 14px !important; font-size: 10px !important; }
  body.jo-cw-banner-fix #joBanner > button {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; font-size: 20px !important; opacity: .75 !important;
  }
  body.jo-cw-banner-fix .jo-toast { bottom: calc(24px + var(--jo-cw-banner) + var(--jo-cw-sbar)) !important; }
}
@media (max-width: 560px) {
  body.jo-cw-banner-fix #joBanner .jo-cw-banner-more { display: none; }
}

/* ═════════ WhatsApp ═════════ */

.jo-cw-wa {
  position: fixed; z-index: 990;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--jo-cw-banner) + var(--jo-cw-sbar) + env(safe-area-inset-bottom, 0px));
  font-family: var(--jo-cw-sans);
  opacity: 0; transform: translateY(12px);
  transition: bottom .3s var(--jo-cw-ease), opacity .35s var(--jo-cw-ease), transform .35s var(--jo-cw-ease);
}
.jo-cw-wa.is-ready { opacity: 1; transform: none; }
.jo-cw-wa--left { right: auto; left: calc(18px + env(safe-area-inset-left, 0px)); }

body.jo-cw-open .jo-cw-wa,
body:has(#joMobile.open) .jo-cw-wa,
body:has(.jo-search-overlay.open) .jo-cw-wa { opacity: 0; pointer-events: none; transform: translateY(12px); }

.jo-cw-wa__btn {
  position: relative; display: flex; align-items: center; height: 58px; border-radius: 999px;
  text-decoration: none; color: #fff; background: var(--jo-cw-dark);
  box-shadow: 0 10px 28px rgba(14, 61, 62, .28), 0 2px 6px rgba(14, 61, 62, .16), inset 0 0 0 1px rgba(201, 169, 110, .55);
  transition: transform .2s var(--jo-cw-ease), box-shadow .2s, background .2s;
}
.jo-cw-wa--left .jo-cw-wa__btn { flex-direction: row; }
.jo-cw-wa--right .jo-cw-wa__btn { flex-direction: row-reverse; }
.jo-cw-wa__btn:hover { transform: translateY(-2px); background: var(--jo-cw-mid); color: #fff; box-shadow: 0 14px 34px rgba(14, 61, 62, .32), inset 0 0 0 1px rgba(201, 169, 110, .8); }
.jo-cw-wa__btn:focus-visible { outline: 2px solid var(--jo-cw-gold); outline-offset: 3px; }

.jo-cw-wa__icon { position: relative; display: flex; align-items: center; justify-content: center; width: 58px; height: 58px; flex: 0 0 58px; }
.jo-cw-wa__icon svg { width: 29px; height: 29px; display: block; }
.jo-cw-wa__icon::after {
  content: ""; position: absolute; top: 11px; right: 11px; width: 10px; height: 10px; border-radius: 50%;
  background: #3fcf74; box-shadow: 0 0 0 2px var(--jo-cw-dark);
}
.jo-cw-wa__btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(201, 169, 110, .55);
  animation: jo-cw-ring 2.6s ease-out 1.2s 3;
}
@keyframes jo-cw-ring { 0% { box-shadow: 0 0 0 0 rgba(201, 169, 110, .55); } 70%, 100% { box-shadow: 0 0 0 14px rgba(201, 169, 110, 0); } }

.jo-cw-wa__label {
  white-space: nowrap; font-size: .66rem; letter-spacing: .18em; text-transform: uppercase;
  padding: 0 4px 0 22px;
}
.jo-cw-wa--left .jo-cw-wa__label { padding: 0 22px 0 4px; }

@media (max-width: 768px) {
  .jo-cw-wa { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + var(--jo-cw-banner) + var(--jo-cw-sbar) + env(safe-area-inset-bottom, 0px)); }
  .jo-cw-wa--left { left: calc(14px + env(safe-area-inset-left, 0px)); }
  .jo-cw-wa__label { display: none; }
  .jo-cw-wa__btn { height: 54px; }
  .jo-cw-wa__icon { width: 54px; height: 54px; flex-basis: 54px; }
  .jo-cw-wa__icon svg { width: 27px; height: 27px; }
  .jo-cw-wa__icon::after { top: 10px; right: 10px; }
}

/* Estilo "verde WhatsApp" */
.jo-cw-wa--whatsapp .jo-cw-wa__btn { background: #25d366; box-shadow: 0 10px 28px rgba(18, 140, 70, .3), 0 2px 6px rgba(0, 0, 0, .12); }
.jo-cw-wa--whatsapp .jo-cw-wa__btn:hover { background: #1fbd5a; box-shadow: 0 14px 34px rgba(18, 140, 70, .36); }
.jo-cw-wa--whatsapp .jo-cw-wa__icon::after { background: #fff; box-shadow: 0 0 0 2px #25d366; }
.jo-cw-wa--whatsapp .jo-cw-wa__btn::before { animation-name: jo-cw-ring-green; }
@keyframes jo-cw-ring-green { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .5); } 70%, 100% { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); } }

/* Tarjeta de saludo */
.jo-cw-wa__card {
  position: absolute; bottom: calc(100% + 16px); right: 0;
  width: 316px; max-width: calc(100vw - 28px); box-sizing: border-box;
  padding: 20px 18px 18px; background: #fff; border-radius: 16px;
  border-top: 3px solid var(--jo-cw-gold);
  box-shadow: 0 22px 60px rgba(14, 61, 62, .2), 0 4px 14px rgba(14, 61, 62, .08);
  transform-origin: bottom right; opacity: 0; transform: translateY(8px) scale(.96);
  transition: opacity .25s var(--jo-cw-ease), transform .25s var(--jo-cw-ease);
}
.jo-cw-wa--left .jo-cw-wa__card { right: auto; left: 0; transform-origin: bottom left; }
.jo-cw-wa.is-greeting .jo-cw-wa__card { opacity: 1; transform: none; }
.jo-cw-wa__card[hidden] { display: none; }
.jo-cw-wa__card::after {
  content: ""; position: absolute; bottom: -7px; right: 24px; width: 14px; height: 14px;
  background: #fff; transform: rotate(45deg); box-shadow: 4px 4px 8px rgba(14, 61, 62, .06);
}
.jo-cw-wa--left .jo-cw-wa__card::after { right: auto; left: 24px; }

.jo-cw-wa__x {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--jo-cw-muted);
}
.jo-cw-wa__x:hover { background: var(--jo-cw-cream); color: var(--jo-cw-dark); }

.jo-cw-wa__head { display: flex; align-items: center; gap: 12px; padding-right: 24px; }
.jo-cw-wa__avatar {
  position: relative; flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--jo-cw-dark); color: var(--jo-cw-gold);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--jo-cw-serif); font-size: 15px; letter-spacing: .06em;
  box-shadow: inset 0 0 0 1px rgba(201, 169, 110, .6);
}
.jo-cw-wa__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.jo-cw-wa__dot {
  position: absolute; right: 1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%;
  background: #3fcf74; box-shadow: 0 0 0 2px #fff;
}
.jo-cw-wa__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.jo-cw-wa__who strong { font-family: var(--jo-cw-serif); font-weight: 500; font-size: 1.02rem; color: var(--jo-cw-dark); }
.jo-cw-wa__who small { font-size: .7rem; color: var(--jo-cw-muted); margin-top: 2px; }

.jo-cw-wa__bubble {
  margin: 14px 0 16px; padding: 12px 14px;
  background: #f5f1ea; border-radius: 4px 16px 16px 16px;
  font-size: .82rem; line-height: 1.55; color: #2a2620;
}

.jo-cw-wa__cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 46px;
  border-radius: 999px; text-decoration: none; color: #fff; background: var(--jo-cw-dark);
  font-size: .68rem; letter-spacing: .18em; text-transform: uppercase;
  transition: background .2s;
}
.jo-cw-wa__cta:hover { background: var(--jo-cw-mid); color: #fff; }
.jo-cw-wa__cta svg { width: 19px; height: 19px; }
.jo-cw-wa--whatsapp .jo-cw-wa__cta { background: #25d366; }
.jo-cw-wa--whatsapp .jo-cw-wa__cta:hover { background: #1fbd5a; }

@media (prefers-reduced-motion: reduce) {
  .jo-cw-wa, .jo-cw-wa__card, .jo-cw-item, .jo-cw-notice { transition: none !important; }
  .jo-cw-wa__btn::before, .jo-cw-item.is-new, #joMinicart.jo-cw-loading::after { animation: none !important; }
}

@media print { .jo-cw-wa { display: none !important; } }
