/* Estructura y estilos de la página de la cesta */
.cesta-page {
  width: 100%;
  min-height: calc(100vh - 120px);
  padding: 3rem 0 5rem;
  background-color: var(--bg);
  box-sizing: border-box;
}

.cesta-page__container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  box-sizing: border-box;
}

/* Encabezado de página */
.cesta-page__title-section {
  margin-bottom: 2rem;
}

.cesta-page__title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

/* Distribución en columnas */
.cesta-page__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  align-items: start;
  gap: 2rem;
}

/* Tarjetas de contenido */
.cesta-page__card,
.cesta-page__checkout-card {
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

.cesta-page__card {
  min-width: 0;
  overflow: hidden;
}

.cesta-page__checkout-card {
  position: sticky;
  top: 6rem;
}

/* Encabezado del listado */
.cesta-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  padding: 0 1.75rem;
  background-color: var(--primary);
  border-bottom: 1px solid var(--primary-hover);
  box-sizing: border-box;
}

.cesta-page__header-title-wrapper {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
}

.cesta-page__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-page__subtitle {
  margin: 0;
  color: var(--text-inverse);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.cesta-page__btn-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.125rem;
  padding: 0 0.75rem;
  color: var(--text-inverse);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.cesta-page__btn-clear i {
  font-size: var(--fs-sm);
  line-height: 1;
}

.cesta-page__btn-clear:hover {
  color: var(--text-inverse);
  background-color: var(--error);
  border-color: var(--error);
}

.cesta-page__btn-clear:focus-visible {
  outline: 2px solid var(--text-inverse);
}

/* Listado de productos */
.cesta-page__list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0 1.75rem;
}

.cesta-page__empty-message {
  margin: 0;
  padding: 4.5rem 1.5rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
}

/* Fila de producto individual */
.cesta-page .cesta-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 1.5rem;
  padding: 1.75rem 2.5rem 1.75rem 0;
  border-bottom: 1px solid var(--border-light);
  box-sizing: border-box;
}

.cesta-page .cesta-item:last-child {
  border-bottom: none;
}

.cesta-page .cesta-item__media {
  width: 5rem;
  height: 7rem;
  flex-shrink: 0;
  overflow: hidden;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-sizing: border-box;
}

.cesta-page .cesta-item__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cesta-page .cesta-item__details {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  min-height: 7rem;
  gap: 0.75rem;
}

.cesta-page .cesta-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.cesta-page .cesta-item__title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.35;
}

.cesta-page .cesta-item__title-link,
.cesta-page .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-page .cesta-item__title-link:hover {
  color: var(--primary);
}

.cesta-page .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-page .cesta-item__pricing {
  margin: 0.25rem 0 0;
}

.cesta-page .cesta-item__price-current {
  color: var(--price-regular);
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.25;
}

.cesta-page .cesta-item__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cesta-page .cesta-item__subtotal {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
}

/* Selector numérico de cantidad */
.cesta-page .cesta-quantity {
  display: inline-flex;
  align-items: center;
  height: 2.125rem;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  overflow: hidden;
}

.cesta-page .cesta-quantity__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--text);
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.cesta-page .cesta-quantity__btn:hover {
  color: var(--primary);
  background-color: var(--bg);
}

.cesta-page .cesta-quantity__value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.125rem;
  height: 2rem;
  padding: 0 0.35rem;
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  border-right: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
}

.cesta-page .cesta-item__btn-remove {
  position: absolute;
  top: 1.75rem;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  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-page .cesta-item__btn-remove:hover {
  color: var(--error);
  background-color: var(--bg-dark);
}

.cesta-page .cesta-item__btn-remove:focus-visible,
.cesta-page .cesta-quantity__btn:focus-visible {
  outline: 2px solid var(--primary);
}

/* Formulario de checkout */
.cesta-checkout-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.75rem;
  box-sizing: border-box;
}

.cesta-checkout-form__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.cesta-checkout-form__header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--primary);
  flex-shrink: 0;
}

.cesta-checkout-form__title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.cesta-checkout-form__group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cesta-checkout-form__label {
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.25;
}

.cesta-checkout-form__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.cesta-checkout-form__input-icon {
  position: absolute;
  left: 0.875rem;
  font-size: var(--fs-md);
  line-height: 1;
  color: var(--placeholder);
  pointer-events: none;
  transition: color 0.2s ease;
}

.cesta-checkout-form__input {
  width: 100%;
  height: 2.875rem;
  padding: 0 0.875rem 0 2.5rem;
  color: var(--text);
  font-size: var(--fs-sm);
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cesta-checkout-form__input::placeholder {
  color: var(--placeholder);
  font-size: var(--fs-sm);
}

.cesta-checkout-form__input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.cesta-checkout-form__input-wrap:focus-within .cesta-checkout-form__input-icon {
  color: var(--primary);
}

/* Resumen del pedido */
.cesta-summary {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1.25rem;
  margin-top: 0.5rem;
  background-color: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
}

.cesta-summary__title {
  margin: 0 0 0.25rem;
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.25;
}

.cesta-summary__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.cesta-summary__label {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.3;
}

.cesta-summary__value {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.cesta-summary__value--free {
  color: var(--success);
}

.cesta-summary__row--total {
  padding-top: 1rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border-light);
}

.cesta-summary__row--total .cesta-summary__label {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.cesta-summary__amount {
  color: var(--price-regular);
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.cesta-summary__note {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: var(--fs-2xs);
  line-height: 1.45;
}

/* Feedback de estado */
.cesta-checkout-form__feedback:empty {
  display: none;
}

.cesta-checkout-form__feedback--info,
.cesta-checkout-form__feedback--success,
.cesta-checkout-form__feedback--error {
  padding: 0.75rem 1rem;
  font-size: var(--fs-xs);
  line-height: 1.4;
  background-color: var(--bg-light);
  border: 1px solid var(--border-light);
  border-left-width: 4px;
  border-radius: 6px;
}

.cesta-checkout-form__feedback--info {
  color: var(--info);
  border-left-color: var(--info);
  background-color: var(--bg);
}

.cesta-checkout-form__feedback--success {
  color: var(--success);
  border-left-color: var(--success);
  background-color: var(--bg);
}

.cesta-checkout-form__feedback--error {
  color: var(--error);
  font-weight: 500;
  border-left-color: var(--error);
  background-color: var(--bg);
}

/* Botón de envío */
.cesta-checkout-form__submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 100%;
  height: 2.875rem;
  padding: 0 1.25rem;
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  font-weight: 700;
  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;
}

.cesta-checkout-form__submit-btn i {
  font-size: var(--fs-lg);
  line-height: 1;
}

.cesta-checkout-form__submit-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.cesta-checkout-form__submit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.cesta-checkout-form__submit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Aviso de seguridad */
.cesta-checkout-form__disclaimer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-2xs);
  line-height: 1.4;
  text-align: center;
}

.cesta-checkout-form__disclaimer i {
  font-size: var(--fs-base);
  line-height: 1;
  color: var(--success);
}

/* Adaptabilidad responsive */
@media (max-width: 1024px) {
  .cesta-page__layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    gap: 1.5rem;
  }
}

@media (max-width: 840px) {
  .cesta-page {
    padding: 2rem 0 3.5rem;
  }

  .cesta-page__layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .cesta-page__checkout-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .cesta-page__container {
    padding: 0 1.25rem;
  }

  .cesta-page__title {
    font-size: var(--fs-xl);
  }

  .cesta-page__header {
    height: 3.5rem;
    padding: 0 1.25rem;
  }

  .cesta-page__list {
    padding: 0 1.25rem;
  }

  .cesta-page .cesta-item {
    padding: 1.25rem 2rem 1.25rem 0;
    gap: 1rem;
  }

  .cesta-page .cesta-item__media {
    width: 4.25rem;
    height: 6rem;
  }

  .cesta-page .cesta-item__details {
    min-height: 6rem;
  }

  .cesta-checkout-form {
    padding: 1.25rem;
  }
}