/* ═══════════════════════════════════════════════════════════════════
   CART POPUP MODAL — Centered Overlay with Burst Go-Back Button
   Premium delight animations and staggered item entrance
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --cart-gold: #4E95BC;
  --cart-gold-glow: rgba(78, 149, 188, 0.25);
  --cart-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cart-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Overlay Backdrop ─── */
.k-cart-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s var(--cart-ease);
}

.k-cart-popup-overlay.is-open {
  display: flex;
  opacity: 1;
}

/* ─── Centered Modal ─── */
.k-cart-popup {
  width: 480px;
  max-width: 94vw;
  max-height: 90vh;
  max-height: 90dvh;
  background: #ffffff;
  border-radius: 24px;
  box-shadow:
    0 25px 60px rgba(0,0,0,0.15),
    0 0 0 1px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  animation: k-cart-popup-burst 0.45s var(--cart-ease-spring);
  transform-origin: center center;
  overflow: hidden;
  border: 1px solid rgba(200, 148, 59, 0.06);
}

@keyframes k-cart-popup-burst {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ─── Header with Go-Back Button ─── */
.k-cart-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(200, 148, 59, 0.1);
  flex-shrink: 0;
  gap: 12px;
  background: linear-gradient(180deg, #fafaf8, #fff);
}

.k-cart-popup__header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Go-Back Button — Burst In Animation ─── */
.k-cart-popup__back {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(200, 148, 59, 0.1);
  background: #fff;
  color: #111827;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 0;
  transition: all 0.25s var(--cart-ease-spring);
  flex-shrink: 0;
  animation: k-cart-back-burst 0.5s var(--cart-ease-spring) 0.15s both;
  position: relative;
  overflow: hidden;
}

@keyframes k-cart-back-burst {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.2) rotate(10deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.k-cart-popup__back:hover {
  background: rgba(200, 148, 59, 0.08);
  border-color: var(--cart-gold);
  color: var(--cart-gold);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.k-cart-popup__back:active {
  transform: scale(0.95);
}

.k-cart-popup__back svg {
  width: 18px;
  height: 18px;
  display: block;
}

.k-cart-popup__title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
  letter-spacing: -0.01em;
}

.k-cart-popup__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--cart-gold);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 4px;
  box-shadow: 0 2px 6px var(--cart-gold-glow);
}

/* ─── Close Button ─── */
.k-cart-popup__close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.06);
  background: #f3f4f6;
  color: #6B7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.25s;
  padding: 0;
  flex-shrink: 0;
}

.k-cart-popup__close:hover {
  background: rgba(200, 148, 59, 0.12);
  color: var(--cart-gold);
  border-color: rgba(200, 148, 59, 0.2);
  transform: rotate(90deg) scale(1.08);
}

/* ─── Items Container ─── */
.k-cart-popup__items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px;
}

.k-cart-popup__items::-webkit-scrollbar {
  width: 4px;
}

.k-cart-popup__items::-webkit-scrollbar-track {
  background: transparent;
}

.k-cart-popup__items::-webkit-scrollbar-thumb {
  background: var(--cart-gold);
  border-radius: 2px;
  opacity: 0.3;
}

/* ─── Empty State with Floating Animation ─── */
.k-cart-popup__empty {
  text-align: center;
  padding: 48px 20px;
  color: #6B7280;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.k-cart-popup__empty-icon {
  color: var(--cart-gold);
  margin-bottom: 4px;
  opacity: 0.3;
  animation: k-cart-empty-float 3s ease-in-out infinite;
}

@keyframes k-cart-empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.k-cart-popup__empty p {
  margin: 0;
  font-size: 0.92rem;
  color: #9CA3AF;
}

/* ─── Cart Item — Staggered Entrance ─── */
.k-cart-popup__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(200, 148, 59, 0.06);
  animation: k-cart-item-fade 0.4s var(--cart-ease) both;
  transition: all 0.3s var(--cart-ease);
}

.k-cart-popup__item:hover {
  padding-left: 6px;
  padding-right: 6px;
  background: rgba(200, 148, 59, 0.02);
  border-radius: 8px;
}

@keyframes k-cart-item-fade {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.k-cart-popup__item:last-child {
  border-bottom: none;
}

.k-cart-popup__item-img {
  width: 64px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
  border: 1px solid rgba(200, 148, 59, 0.08);
  transition: transform 0.3s var(--cart-ease);
}

.k-cart-popup__item:hover .k-cart-popup__item-img {
  transform: scale(1.05);
}

.k-cart-popup__item-img--placeholder {
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}

.k-cart-popup__item-img--error {
  object-fit: contain;
  padding: 8px;
}

.k-cart-popup__item-info {
  flex: 1;
  min-width: 0;
}

.k-cart-popup__item-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #111827;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.k-cart-popup__item-size {
  font-size: 0.75rem;
  color: #6B7280;
  margin: 0 0 2px;
}

.k-cart-popup__item-price {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--cart-gold);
  margin: 0;
}

.k-cart-popup__item-remove {
  background: none;
  border: 1px solid transparent;
  color: #9CA3AF;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 6px;
  line-height: 1;
  transition: all 0.25s;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.k-cart-popup__item-remove:hover {
  color: #d41f22;
  background: rgba(212, 31, 34, 0.06);
  border-color: rgba(212, 31, 34, 0.15);
  transform: scale(1.1);
}

/* ─── Footer ─── */
.k-cart-popup__footer {
  padding: 18px 24px 22px;
  border-top: 1px solid rgba(200, 148, 59, 0.08);
  flex-shrink: 0;
  background: linear-gradient(0deg, #fafaf8, #fff);
}

.k-cart-popup__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  color: #111827;
  margin-bottom: 14px;
  font-weight: 600;
}

.k-cart-popup__total span:last-child {
  color: var(--cart-gold);
  font-weight: 700;
  font-size: 1.1rem;
}

/* ─── Checkout Button with Glow Pulse ─── */
.k-cart-popup__checkout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px !important;
  font-size: 0.92rem !important;
  font-weight: 700 !important;
  min-height: 48px !important;
  border-radius: 999px !important;
  margin-bottom: 8px;
  background: #2d241e !important;
  color: #fff !important;
  border: none !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all 0.25s var(--cart-ease-spring);
  position: relative;
  overflow: hidden;
}

.k-cart-popup__checkout::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(200,148,59,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s var(--cart-ease);
  pointer-events: none;
}

.k-cart-popup__checkout:hover {
  background: #1f2937 !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(200, 148, 59, 0.2);
}

.k-cart-popup__checkout:hover::after {
  opacity: 1;
}

.k-cart-popup__checkout:active {
  transform: translateY(0) scale(0.98);
}

.k-cart-popup__checkout svg {
  transition: transform 0.25s var(--cart-ease);
}

.k-cart-popup__checkout:hover svg {
  transform: translateX(4px);
}

/* ─── Continue Shopping ─── */
.k-cart-popup__continue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  text-align: center;
  padding: 12px !important;
  font-size: 0.82rem !important;
  min-height: 42px !important;
  border-radius: 999px !important;
  background: transparent !important;
  border: 1px solid rgba(200, 148, 59, 0.12) !important;
  color: #6B7280 !important;
  cursor: pointer !important;
  transition: all 0.2s var(--cart-ease);
}

.k-cart-popup__continue:hover {
  border-color: var(--cart-gold) !important;
  color: var(--cart-gold) !important;
  background: rgba(200, 148, 59, 0.06) !important;
  transform: translateY(-1px);
}

.k-cart-popup__continue svg {
  transition: transform 0.25s var(--cart-ease);
}

.k-cart-popup__continue:hover svg {
  transform: translateX(-3px);
}

/* ─── Responsive ─── */
@media (max-width: 520px) {
  .k-cart-popup {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    margin-top: auto;
  }

  .k-cart-popup-overlay {
    align-items: flex-end;
  }

  @keyframes k-cart-popup-burst {
    0% {
      opacity: 0;
      transform: translateY(40px) scale(0.95);
    }
    100% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .k-cart-popup__header {
    padding: 16px 18px;
  }

  .k-cart-popup__items {
    padding: 8px 18px;
  }

  .k-cart-popup__footer {
    padding: 16px 18px 20px;
  }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  .k-cart-popup {
    animation: none;
  }

  .k-cart-popup__back {
    animation: none;
  }

  .k-cart-popup__item {
    animation: none;
  }

  .k-cart-popup__empty-icon {
    animation: none;
  }

  .k-cart-popup__close,
  .k-cart-popup__checkout,
  .k-cart-popup__continue {
    transition: none;
  }
}

/* ─── Cart item buttons ─── */
.k-cart-popup .button,
.k-cart-popup .button-ghost {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
