/* ========================================
   TANA SHOPPING CART v1.1.0
   Farmacia Tañá - Estilo moderno y limpio
   
   Compatible with Hummingbird (PS9) and Classic themes.
   Wrapped in @layer ps-modules for Hummingbird CSS layer system.
   Fallback: browsers without @layer support still apply all rules.
   ======================================== */

/* Hummingbird layer order:
   vendors, bs-base, bs-components, bs-custom-components,
   ps-base, ps-components, ps-pages, ps-modules, utilities
   
   ps-modules is the correct layer for module styles. */
@layer ps-modules {

/* ── Variables ──────────────────────────────────────────── */
:root {
  --tana-primary: #3b2b4a;
  --tana-primary-light: #5c3d7a;
  --tana-secondary: #b587d1;
  --tana-hover: #ceafe0;
  --tana-bg: #faf7fc;
  --tana-bg-card: #f3eff7;
  --tana-white: #fff;
  --tana-border: #e0e0e0;
  --tana-text-dark: #1a051d;
  --tana-text-gray: #666;
  --tana-text-muted: #999;
  --tana-success: #4CAF50;
  --tana-success-bg: #E8F5E9;
  --tana-error: #f44336;
  --tana-error-bg: #FFEBEE;
  --tana-drawer-width: 420px;
  --tana-radius: 8px;
  --tana-radius-sm: 6px;
  --tana-shadow: 0 4px 32px rgba(59, 43, 74, 0.15);
  --tana-shadow-sm: 0 2px 8px rgba(59, 43, 74, 0.08);
  --tana-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Utility ────────────────────────────────────────────── */
.tana-hidden {
  display: none !important;
}

/* ── Hummingbird/Bootstrap 5 link color override ───────── */
/* BS5 sets a { color: var(--bs-link-color) } which overrides
   our module colors. Force our palette on all drawer links. */
.tana-cart-drawer a,
.tana-cart-drawer a:visited,
.tana-cart-drawer a:hover,
.tana-cart-drawer a:focus,
.tana-cart-recommended a,
.tana-cart-recommended a:visited,
.tana-cart-recommended a:hover,
.tana-cart-recommended a:focus {
  color: var(--tana-text-dark);
  text-decoration: none;
}

.tana-cart-drawer a:hover,
.tana-cart-recommended a:hover {
  color: var(--tana-primary-light);
}

/* CTA buttons keep their own colors */
.tana-cart-cta__btn--primary,
.tana-cart-cta__btn--primary:visited,
.tana-cart-cta__btn--primary:hover {
  color: var(--tana-white);
}

.tana-cart-cta__btn--secondary,
.tana-cart-cta__btn--secondary:visited {
  color: var(--tana-primary);
}

/* ── Botón trigger del carrito ──────────────────────────── */
.tana-cart-trigger {
  display: inline-block;
}

.tana-cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--tana-white);
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius);
  cursor: pointer;
  transition: all var(--tana-transition);
  color: var(--tana-primary);
  padding: 0;
}

.tana-cart-btn:hover {
  background: var(--tana-hover);
  border-color: var(--tana-hover);
  transform: scale(1.05);
}

.tana-cart-btn:active {
  transform: scale(0.97);
}

.tana-cart-icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

/* ── Badge ──────────────────────────────────────────────── */
.tana-cart-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--tana-primary);
  color: var(--tana-white);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  border: 2px solid var(--tana-white);
  transition: transform 0.3s ease;
  pointer-events: none;
}

@keyframes tanaBadgePulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.tana-badge-pulse {
  animation: tanaBadgePulse 0.5s ease;
}

/* ── Overlay ────────────────────────────────────────────── */
.tana-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 5, 29, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tana-cart-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Drawer lateral ────────────────────────────────────── */
.tana-cart-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--tana-drawer-width);
  max-width: 100vw;
  background: var(--tana-white);
  box-shadow: var(--tana-shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tana-cart-drawer[data-drawer-position="right"] {
  right: 0;
  transform: translateX(100%);
}

.tana-cart-drawer[data-drawer-position="left"] {
  left: 0;
  transform: translateX(-100%);
}

.tana-cart-drawer.active {
  transform: translateX(0);
}

/* Loading overlay inside drawer */
.tana-cart-drawer.tana-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  z-index: 10;
  pointer-events: all;
  transition: opacity 0.2s ease;
}

/* ── Header ─────────────────────────────────────────────── */
.tana-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  background: var(--tana-primary);
}

.tana-cart-drawer__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--tana-white);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}

.tana-cart-drawer__count {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.75;
}

.tana-cart-drawer__close {
  width: 34px;
  height: 34px;
  border-radius: var(--tana-radius-sm);
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--tana-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tana-transition);
  padding: 0;
}

.tana-cart-drawer__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.tana-cart-drawer__close svg {
  pointer-events: none;
}

/* ── Body ───────────────────────────────────────────────── */
.tana-cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Barra de envío gratis ──────────────────────────────── */
.tana-cart-free-shipping {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--tana-bg-card);
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius);
  transition: all 0.4s ease;
}

.tana-cart-free-shipping.achieved {
  background: var(--tana-success-bg);
  border-color: var(--tana-success);
}

.tana-cart-free-shipping__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(59, 43, 74, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tana-primary);
  transition: all 0.4s ease;
}

.tana-cart-free-shipping.achieved .tana-cart-free-shipping__icon {
  background: var(--tana-success);
  color: var(--tana-white);
}

.tana-cart-free-shipping__content {
  flex: 1;
  min-width: 0;
}

.tana-cart-free-shipping__text {
  font-size: 13px;
  font-weight: 600;
  color: var(--tana-text-dark);
  margin-bottom: 8px;
  line-height: 1.4;
}

.tana-cart-free-shipping.achieved .tana-cart-free-shipping__text {
  color: var(--tana-success);
}

.tana-cart-free-shipping__bar {
  height: 5px;
  background: rgba(59, 43, 74, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.tana-cart-free-shipping__progress {
  height: 100%;
  background: linear-gradient(90deg, var(--tana-secondary), var(--tana-primary));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.tana-cart-free-shipping.achieved .tana-cart-free-shipping__progress {
  background: var(--tana-success);
}

/* ── Productos ──────────────────────────────────────────── */
.tana-cart-products {
  margin-bottom: 16px;
}

.tana-cart-product {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 8px;
  background: var(--tana-white);
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius);
  position: relative;
  transition: all var(--tana-transition);
}

.tana-cart-product:last-child {
  margin-bottom: 0;
}

.tana-cart-product:hover {
  border-color: var(--tana-hover);
  box-shadow: var(--tana-shadow-sm);
}

/* Updating state */
.tana-cart-product.tana-updating {
  opacity: 0.7;
  pointer-events: none;
}

/* Removing animation */
@keyframes tanaSlideOut {
  to {
    opacity: 0;
    transform: translateX(30px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-width: 0;
  }
}

.tana-cart-product.tana-removing {
  animation: tanaSlideOut 0.3s ease forwards;
  overflow: hidden;
}

/* Image */
.tana-cart-product__image {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--tana-radius-sm);
  overflow: hidden;
  background: var(--tana-bg-card);
  border: 1px solid var(--tana-border);
  display: block;
}

.tana-cart-product__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Info */
.tana-cart-product__info {
  flex: 1;
  min-width: 0;
}

.tana-cart-product__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
  color: var(--tana-text-dark);
  text-decoration: none;
  margin-bottom: 4px;
  line-height: 1.35;
}

.tana-cart-product__name:hover {
  color: var(--tana-primary-light);
}

.tana-cart-product__attributes {
  font-size: 11px;
  color: var(--tana-text-muted);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quantity buttons +/- */
.tana-cart-product__qty-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-bottom: 6px;
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius-sm);
  overflow: hidden;
  height: 28px;
}

.tana-cart-product__qty-btn {
  width: 28px;
  height: 28px;
  background: var(--tana-bg-card);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tana-text-dark);
  transition: all 0.15s ease;
  padding: 0;
}

.tana-cart-product__qty-btn:hover:not(:disabled) {
  background: var(--tana-hover);
  color: var(--tana-primary);
}

.tana-cart-product__qty-btn:active:not(:disabled) {
  background: var(--tana-secondary);
}

.tana-cart-product__qty-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tana-cart-product__qty-btn svg {
  pointer-events: none;
}

.tana-cart-product__qty-value {
  min-width: 30px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--tana-text-dark);
  line-height: 28px;
  background: var(--tana-white);
  user-select: none;
}

/* Price */
.tana-cart-product__price {
  font-size: 15px;
  font-weight: 700;
  color: var(--tana-primary);
}

/* Remove button */
.tana-cart-product__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: var(--tana-radius-sm);
  background: var(--tana-white);
  border: 1px solid transparent;
  color: var(--tana-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tana-transition);
  padding: 0;
}

.tana-cart-product__remove:hover {
  background: var(--tana-error-bg);
  border-color: var(--tana-error);
  color: var(--tana-error);
}

.tana-cart-product__remove svg {
  pointer-events: none;
}

/* ── Producto recomendado (v1.1) ────────────────────────── */
.tana-cart-recommended {
  margin-bottom: 16px;
  padding: 14px;
  background: linear-gradient(135deg, var(--tana-bg-card) 0%, var(--tana-bg) 100%);
  border: 1px dashed var(--tana-secondary);
  border-radius: var(--tana-radius);
}

.tana-cart-recommended__header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--tana-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.tana-cart-recommended__header svg {
  color: var(--tana-secondary);
}

.tana-cart-recommended__product {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tana-cart-recommended__image {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--tana-radius-sm);
  overflow: hidden;
  background: var(--tana-white);
  border: 1px solid var(--tana-border);
  display: block;
}

.tana-cart-recommended__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tana-cart-recommended__info {
  flex: 1;
  min-width: 0;
}

.tana-cart-recommended__name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  color: var(--tana-text-dark);
  text-decoration: none;
  line-height: 1.35;
  margin-bottom: 2px;
}

.tana-cart-recommended__name:hover {
  color: var(--tana-primary-light);
}

.tana-cart-recommended__price {
  font-size: 14px;
  font-weight: 700;
  color: var(--tana-primary);
}

.tana-cart-recommended__add {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tana-white);
  background: var(--tana-primary);
  border: none;
  border-radius: var(--tana-radius-sm);
  cursor: pointer;
  transition: all var(--tana-transition);
  white-space: nowrap;
}

.tana-cart-recommended__add:hover:not(:disabled) {
  background: var(--tana-primary-light);
  transform: scale(1.03);
}

.tana-cart-recommended__add:disabled,
.tana-cart-recommended__add.tana-adding {
  opacity: 0.6;
  pointer-events: none;
}

.tana-cart-recommended__add svg {
  pointer-events: none;
}

/* ── Mensajes de confianza ──────────────────────────────── */
.tana-cart-trust {
  padding: 12px 14px;
  background: var(--tana-bg-card);
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius);
  margin-bottom: 16px;
}

.tana-cart-trust__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--tana-text-dark);
  margin-bottom: 6px;
  line-height: 1.4;
}

.tana-cart-trust__item:last-child {
  margin-bottom: 0;
}

.tana-cart-trust__icon {
  flex-shrink: 0;
  color: var(--tana-success);
}

/* ── Carrito vacío ──────────────────────────────────────── */
.tana-cart-empty {
  text-align: center;
  padding: 48px 20px;
}

.tana-cart-empty__icon {
  margin-bottom: 16px;
  color: var(--tana-border);
}

.tana-cart-empty__text {
  font-size: 16px;
  font-weight: 600;
  color: var(--tana-text-dark);
  margin: 0 0 6px;
}

.tana-cart-empty__sub {
  font-size: 13px;
  color: var(--tana-text-muted);
  margin: 0;
}

/* ── Footer ─────────────────────────────────────────────── */
.tana-cart-drawer__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--tana-border);
  flex-shrink: 0;
  background: var(--tana-white);
}

.tana-cart-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--tana-border);
}

.tana-cart-subtotal__label {
  font-size: 15px;
  font-weight: 600;
  color: var(--tana-text-dark);
}

.tana-cart-subtotal__amount {
  font-size: 19px;
  font-weight: 700;
  color: var(--tana-primary);
}

/* ── Botones CTA ────────────────────────────────────────── */
.tana-cart-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tana-cart-cta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
  border-radius: var(--tana-radius);
  transition: all var(--tana-transition);
  border: 1px solid;
  cursor: pointer;
}

.tana-cart-cta__btn svg {
  pointer-events: none;
}

.tana-cart-cta__btn--primary {
  background: var(--tana-primary);
  color: var(--tana-white);
  border-color: var(--tana-primary);
}

.tana-cart-cta__btn--primary:hover {
  background: var(--tana-primary-light);
  border-color: var(--tana-primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 43, 74, 0.25);
}

.tana-cart-cta__btn--primary:active {
  transform: translateY(0);
}

.tana-cart-cta__btn--secondary {
  background: var(--tana-white);
  color: var(--tana-primary);
  border-color: var(--tana-border);
}

.tana-cart-cta__btn--secondary:hover {
  background: var(--tana-bg-card);
  border-color: var(--tana-hover);
}

/* ── Toast Notifications ────────────────────────────────── */
.tana-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 32px);
}

.tana-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--tana-white);
  border: 1px solid var(--tana-border);
  border-radius: var(--tana-radius);
  box-shadow: 0 8px 24px rgba(59, 43, 74, 0.15);
  padding: 12px 14px;
  pointer-events: auto;
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.tana-toast--visible {
  transform: translateX(0);
  opacity: 1;
}

.tana-toast--exiting {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
}

.tana-toast--success {
  border-left: 3px solid var(--tana-success);
}

.tana-toast--error {
  border-left: 3px solid var(--tana-error);
}

.tana-toast__icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--tana-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tana-toast--success .tana-toast__icon {
  background: var(--tana-success-bg);
  color: var(--tana-success);
}

.tana-toast--error .tana-toast__icon {
  background: var(--tana-error-bg);
  color: var(--tana-error);
}

.tana-toast__body {
  flex: 1;
  min-width: 0;
}

.tana-toast__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tana-text-dark);
  line-height: 1.3;
}

.tana-toast__message {
  font-size: 12px;
  color: var(--tana-text-gray);
  margin-top: 2px;
  line-height: 1.4;
}

.tana-toast__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: none;
  border: none;
  color: var(--tana-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}

.tana-toast__close:hover {
  background: var(--tana-bg-card);
  color: var(--tana-text-dark);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --tana-drawer-width: 100vw;
  }

  .tana-cart-drawer__header {
    padding: 14px 16px;
  }

  .tana-cart-drawer__title {
    font-size: 15px;
  }

  .tana-cart-drawer__body {
    padding: 14px 16px;
  }

  .tana-cart-product {
    padding: 12px;
  }

  .tana-cart-product__image {
    width: 64px;
    height: 64px;
  }

  .tana-cart-drawer__footer {
    padding: 14px 16px;
  }

  .tana-toast-container {
    right: 8px;
    left: 8px;
    max-width: none;
    width: auto;
  }
}

/* ── Accesibilidad ──────────────────────────────────────── */
.tana-cart-btn:focus-visible,
.tana-cart-drawer__close:focus-visible,
.tana-cart-product__qty-btn:focus-visible,
.tana-cart-product__remove:focus-visible,
.tana-cart-recommended__add:focus-visible,
.tana-cart-cta__btn:focus-visible {
  outline: 2px solid var(--tana-primary);
  outline-offset: 2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

} /* end @layer ps-modules */

/* ═══════════════════════════════════════════════════════════
   UNLAYERED OVERRIDES
   These rules live OUTSIDE @layer so they beat Bootstrap's
   layered styles (including utilities layer) in Hummingbird.
   ═══════════════════════════════════════════════════════════ */

/* Force our brand colors on all drawer links (kills BS5 blue) */
.tana-cart-drawer a,
.tana-cart-drawer a:link,
.tana-cart-drawer a:visited,
.tana-cart-drawer a:hover,
.tana-cart-drawer a:focus,
.tana-cart-drawer a:active {
  color: #1a051d;
  text-decoration: none;
}

.tana-cart-drawer a:hover {
  color: #5c3d7a;
}

/* CTA primary button stays white */
.tana-cart-drawer .tana-cart-cta__btn--primary,
.tana-cart-drawer .tana-cart-cta__btn--primary:link,
.tana-cart-drawer .tana-cart-cta__btn--primary:visited,
.tana-cart-drawer .tana-cart-cta__btn--primary:hover {
  color: #fff;
}

/* CTA secondary stays brand purple */
.tana-cart-drawer .tana-cart-cta__btn--secondary,
.tana-cart-drawer .tana-cart-cta__btn--secondary:link,
.tana-cart-drawer .tana-cart-cta__btn--secondary:visited {
  color: #3b2b4a;
}

/* Ensure drawer and overlay sit above everything */
.tana-cart-overlay {
  z-index: 99998 !important;
}

.tana-cart-drawer {
  z-index: 99999 !important;
}

.tana-toast-container {
  z-index: 100000 !important;
}
