/* Estructura y estilos del componente de carrito */
.cesta-drawer {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-light);
  box-sizing: border-box;
}

/* Modo Drawer en Escritorio */
@media (min-width: 769px) {
  .cesta-drawer--desktop-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    width: 100%;
    max-width: 400px;
    border-left: 1px solid var(--border-light);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  }

  .cesta-drawer--desktop-drawer.cesta-drawer--open {
    transform: translateX(0);
    visibility: visible;
  }
}

/* Modo Dropdown en Escritorio */
@media (min-width: 769px) {
  .cesta-drawer--desktop-dropdown {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    z-index: 1100;
    width: 380px;
    max-height: calc(100vh - 5.5rem);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  }

  .cesta-drawer--desktop-dropdown.cesta-drawer--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .cesta-drawer--desktop-dropdown .cesta-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
  }

  .cesta-drawer--desktop-dropdown .cesta-drawer__body {
    padding: 1rem 1.25rem;
    max-height: calc(100vh - 13.5rem);
  }

  .cesta-drawer--desktop-dropdown .cesta-drawer__footer {
    padding: 1rem 1.25rem 1.25rem;
  }
}

/* Modal Centrado en Móvil */
@media (max-width: 768px) {
  .cesta-drawer--mobile-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.96);
    width: min(420px, calc(100vw - 2rem));
    max-height: min(640px, calc(100vh - 3rem));
    z-index: 1100;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  }

  .cesta-drawer--mobile-modal.cesta-drawer--open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
  }

  .cesta-drawer--mobile-modal .cesta-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  .cesta-drawer--mobile-modal .cesta-drawer__body {
    padding: 1rem 1.25rem;
  }

  .cesta-drawer--mobile-modal .cesta-drawer__footer {
    padding: 1rem 1.25rem 1.25rem;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }

  /* Drawer Lateral en Móvil */
  .cesta-drawer--mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    width: 100%;
    max-width: 88vw;
    border-left: 1px solid var(--border-light);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  }

  .cesta-drawer--mobile-drawer.cesta-drawer--open {
    transform: translateX(0);
    visibility: visible;
  }

  .cesta-drawer--mobile-drawer .cesta-drawer__header {
    height: 3.5rem;
    padding: 0 1.25rem;
  }

  .cesta-drawer--mobile-drawer .cesta-drawer__body {
    padding: 1rem 1.25rem;
  }

  .cesta-drawer--mobile-drawer .cesta-drawer__footer {
    padding: 1rem 1.25rem 1.25rem;
  }
}

/* Capa de fondo oscurecida */
.cesta-drawer__overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background-color: var(--overlay-bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cesta-drawer__overlay--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (min-width: 769px) {
  .cesta-drawer--desktop-dropdown ~ .cesta-drawer__overlay {
    display: none !important;
  }
}

/* Cabecera del panel */
.cesta-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 1.5rem;
  background-color: var(--primary);
  border-bottom: 1px solid var(--primary-hover);
  flex-shrink: 0;
}

.cesta-drawer__header-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.cesta-drawer__header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--accent);
  flex-shrink: 0;
}

.cesta-drawer__title {
  margin: 0;
  color: var(--text-inverse);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  white-space: nowrap;
}

.cesta-drawer__header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cesta-drawer__btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0 0.75rem;
  color: var(--text-inverse);
  font-size: var(--fs-xs);
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.cesta-drawer__btn-clear:hover {
  color: var(--text-inverse);
  border-color: var(--error);
  background-color: var(--error);
}

.cesta-drawer__close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--text-inverse);
  font-size: var(--fs-lg);
  line-height: 1;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.cesta-drawer__close-btn:hover {
  color: var(--accent);
  background-color: var(--primary-hover);
}

.cesta-drawer__close-btn:focus-visible {
  outline: 2px solid var(--accent);
}

.cesta-drawer__btn-clear:focus-visible {
  outline: 2px solid var(--text-inverse);
}

/* Cuerpo y contenedor de items */
.cesta-drawer__body {
  flex: 1 1 auto;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  background-color: var(--bg-light);
  -webkit-overflow-scrolling: touch;
}

.cesta-drawer__body::-webkit-scrollbar {
  width: 5px;
}

.cesta-drawer__body::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

.cesta-drawer__empty {
  margin: 0;
  padding: 3.5rem 1rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
}

.cesta-drawer__list {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Item individual de producto */
.cesta-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding-right: 1.75rem;
  padding-bottom: 1.125rem;
  border-bottom: 1px solid var(--border-light);
}

.cesta-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.cesta-item__media {
  width: 3.75rem;
  height: 5.25rem;
  flex-shrink: 0;
  overflow: hidden;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-sizing: border-box;
}

.cesta-item__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cesta-item__details {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 5.25rem;
  gap: 0.5rem;
}

.cesta-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.cesta-item__title {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
}

.cesta-item__title-link,
.cesta-item__title-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  transition: color 0.15s ease;
}

.cesta-item__title-link:hover {
  color: var(--primary);
}

.cesta-item__author {
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cesta-item__pricing {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.15rem 0 0;
}

.cesta-item__price-old {
  color: var(--price-old);
  font-size: var(--fs-xs);
  text-decoration: line-through;
}

.cesta-item__price-current {
  color: var(--price-regular);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.cesta-item__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
}

.cesta-item__subtotal {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

/* Selector numérico de cantidad */
.cesta-quantity {
  display: inline-flex;
  align-items: center;
  height: 1.875rem;
  flex-shrink: 0;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  overflow: hidden;
}

.cesta-quantity__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  color: var(--text);
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.cesta-quantity__btn i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  line-height: 1;
}

.cesta-quantity__btn:hover {
  color: var(--primary);
  background-color: var(--bg);
}

.cesta-quantity__value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.25rem;
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  border-right: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
}

/* Botón de eliminación */
.cesta-item__btn-remove {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  color: var(--text-muted);
  background-color: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.cesta-item__btn-remove i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  line-height: 1;
}

.cesta-item__btn-remove:hover {
  color: var(--error);
  background-color: var(--bg-dark);
}

.cesta-item__btn-remove:focus-visible,
.cesta-quantity__btn:focus-visible {
  outline: 2px solid var(--primary);
}

/* Pie del drawer */
.cesta-drawer__footer {
  flex-shrink: 0;
  padding: 1.25rem 1.5rem 1.5rem;
  background-color: var(--bg-light);
  border-top: 1px solid var(--border-light);
}

.cesta-drawer__total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cesta-drawer__total-label {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.cesta-drawer__total-amount {
  color: var(--price-regular);
  font-size: var(--fs-md);
  font-weight: 700;
  white-space: nowrap;
}

.cesta-drawer__checkout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.875rem;
  padding: 0 1rem;
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-decoration: none;
  background-color: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: 0 3px 0 var(--accent-hover);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.cesta-drawer__checkout-btn:hover {
  background-color: var(--accent-hover);
}

.cesta-drawer__checkout-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Estado deshabilitado para botón de checkout */
.cesta-drawer__checkout-btn--disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
  box-shadow: none;
}