:root {
  --fade-duration: 300ms;
  --popup-backdrop: rgba(0, 0, 0, 0.55);
  --popup-border: rgba(255, 255, 255, 0.1);
}

.popup {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: var(--popup-backdrop);
  opacity: 1;
  transition: opacity var(--fade-duration) ease;
}

.popup[hidden] {
  opacity: 0;
  pointer-events: none;
}

.popup-scroll-cont {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.popup-content {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background-color: var(--color-card, #1f2937);
  color: inherit;
  border: 0;
  border-radius: 14px;
  position: relative;
  transform: translateY(0);
  transition:
    transform var(--fade-duration) ease,
    opacity var(--fade-duration) ease;
}

.popup[hidden] .popup-content {
  transform: translateY(14px);
}

.popup-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  cursor: pointer;
}

.popup-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.popup-loading .popup-content {
  min-height: 180px;
}

.popup-loading .popup-content::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  animation: popup-spin 0.9s linear infinite;
}

@keyframes popup-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.drawer-down[hidden] .popup-content {
  transform: translateY(100%);
}

.drawer-up[hidden] .popup-content {
  transform: translateY(-100%);
}

.drawer-right[hidden] .popup-content {
  transform: translateX(100%);
}

.drawer-left[hidden] .popup-content {
  transform: translateX(-100%);
}

.basket {
  width: min(860px, 96vw);
}

.basket-popup .popup-scroll-cont {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}

.basket-popup-content {
  width: min(520px, 94vw);
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border-left: 1px solid var(--popup-border);
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
}

.basket-popup[hidden] .basket-popup-content {
  transform: translateX(100%);
}

.basket-title {
  margin: 0;
}

.basket-content {
  overflow: auto;
  flex: 1 1 auto;
}

.basket-item .title {
  margin: 0 0 0.25rem 0;
}

.basket-item .price {
  font-size: 0.9rem;
}

.product-actions {
  width: 100%;
  margin-top: 0.5rem;
}

.product-actions > * + * {
  margin-top: 0.65rem;
}

.product-actions .price {
  margin: 0 0 0.45rem 0;
  line-height: 1.25;
  text-align: center;
}

.package-name-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.package-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}

.package-tag.tag-important {
  background: var(--tag-important-bg, #ef4444);
  color: var(--tag-important-text, #fff);
}

.package-tag.tag-square {
  background: var(--tag-square-bg, #3b82f6);
  color: var(--tag-square-text, #fff);
}

.package-tag.tag-round {
  background: var(--tag-round-bg, #22c55e);
  color: var(--tag-round-text, #fff);
}

.package-tag.tag-curly {
  background: var(--tag-curly-bg, #a855f7);
  color: var(--tag-curly-text, #fff);
}

.package-variant-switcher {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.package-variant-button {
  border: 0;
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--color-card-shadow, rgba(255, 255, 255, 0.12));
  color: var(--color-card-foreground, #fff);
}

.package-variant-button.active {
  background: var(--color-primary, #3b82f6);
  color: var(--color-primary-foreground, #fff);
  border-bottom: 3px solid var(--color-primary-shadow, #1d4ed8);
}

.product-actions .add,
.product-actions .subscribe,
.product-actions .open-basket-cta,
.product-actions .gift {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  min-height: 44px;
  text-decoration: none;
  font-weight: 700;
}

.quantity-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.product-actions .quantity-field {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 56px 40px;
  gap: 0.45rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.8rem;
}

.product-actions .quantity-field .decrease,
.product-actions .quantity-field .increase {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  background: var(--color-primary, #3b82f6);
  color: var(--color-primary-foreground, #fff);
  border-bottom: 4px solid var(--color-primary-shadow, #1d4ed8);
  font-weight: 700;
}

.product-actions .quantity-field .open-basket {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
  background: var(--color-primary, #3b82f6);
  color: var(--color-primary-foreground, #fff);
  border-bottom: 4px solid var(--color-primary-shadow, #1d4ed8);
}

.quantity-field .quantity {
  text-align: center;
  width: 56px;
  height: 40px;
  border-radius: 8px;
  border: 0;
  background: var(--color-card-shadow, rgba(255, 255, 255, 0.1));
  color: inherit;
  font-weight: 700;
}

.basket .remove {
  text-decoration: none;
}

.basket-empty {
  text-align: center;
  color: var(--color-card-foreground, #fff);
  padding: 1.25rem;
  border-radius: 10px;
  background: var(--color-background, #111827);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.basket-checkout {
  border-bottom: 0;
}

.basket-popup-content.basket {
  display: flex;
  flex-direction: column;
}

.basket-checkout .checkout {
  white-space: nowrap;
}

.product-actions.updating,
.basket-popup-content.updating {
  opacity: 1;
}

.product-actions.updating .add,
.product-actions.updating .subscribe,
.product-actions.updating .gift,
.product-actions.updating .open-basket-cta,
.product-actions.updating .quantity-field .decrease,
.product-actions.updating .quantity-field .increase,
.product-actions.updating .quantity-field .open-basket,
.product-actions.updating .quantity-field .quantity {
  position: relative;
  pointer-events: none;
  opacity: 0.5;
}

.product-actions.updating .add,
.product-actions.updating .subscribe,
.product-actions.updating .gift,
.product-actions.updating .open-basket-cta,
.product-actions.updating .quantity-field .decrease,
.product-actions.updating .quantity-field .increase,
.product-actions.updating .quantity-field .open-basket {
  color: transparent !important;
}

.product-actions.updating .add::after,
.product-actions.updating .subscribe::after,
.product-actions.updating .gift::after,
.product-actions.updating .open-basket-cta::after,
.product-actions.updating .quantity-field .decrease::after,
.product-actions.updating .quantity-field .increase::after,
.product-actions.updating .quantity-field .open-basket::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  animation: basket-spin 0.75s linear infinite;
}

.basket-popup-content .loading-control {
  position: relative;
  color: transparent !important;
  opacity: 0.5;
}

.basket-popup-content .loading-control > * {
  visibility: hidden;
}

.basket-popup-content .loading-control::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  animation: basket-spin 0.75s linear infinite;
}

@keyframes basket-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.toaster {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1400;
  display: grid;
  gap: 0.55rem;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--popup-border);
  background: #1e2230;
  color: #fff;
  opacity: 1;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.toast[hidden] {
  opacity: 0;
  transform: translateY(6px);
}

.toast p {
  margin: 0;
}

.toast .toast-close {
  margin-top: 0.55rem;
  border: 0;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.toast-info .toast-close {
  background: #2b3d63;
  color: #dce8ff;
}
.toast-success .toast-close {
  background: #1f5c3f;
  color: #d6ffe8;
}
.toast-warning .toast-close {
  background: #6b5520;
  color: #fff0c7;
}
.toast-error .toast-close {
  background: #632727;
  color: #ffdada;
}
