/* ============================================================
   NOVA Store - Cart Page
   ============================================================ */

.cart-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 32px;
  align-items: flex-start;
}

.cart-items-wrapper {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
}

.cart-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.cart-items-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.btn-clear-cart {
  background: transparent;
  border: none;
  color: var(--danger);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  transition: var(--transition);
}

.btn-clear-cart:hover {
  background: #FEF2F2;
}

.cart-items {
  padding: 8px 0;
}

.cart-item {
  display: grid;
  grid-template-columns: 100px 1fr auto auto 40px;
  gap: 20px;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line-soft);
  transition: var(--transition);
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item:hover {
  background: var(--bg);
}

.cart-item-image {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--line-soft);
  flex-shrink: 0;
}

.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item-details {
  min-width: 0;
}

.cart-item-category {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.cart-item-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  line-height: 1.4;
}

.cart-item-title:hover {
  color: var(--primary);
}

.cart-item-variant {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.variant-tag {
  font-size: 11px;
  color: var(--gray);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
}

.cart-item-price-mobile {
  display: none;
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 8px;
}

.qty-selector-small {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--white);
}

.qty-selector-small button {
  width: 34px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.qty-selector-small button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.qty-selector-small input {
  width: 40px;
  height: 36px;
  border: none;
  text-align: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  outline: none;
}

.cart-item-price {
  text-align: left;
  min-width: 100px;
}

.price-unit {
  font-size: 11px;
  color: var(--gray);
  margin-top: 2px;
}

.cart-item-remove {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition);
}

.cart-item-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #FEF2F2;
}

.cart-actions-bottom {
  padding: 20px 28px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.cart-summary {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 140px;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 28px;
}

.summary-card h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
  color: var(--ink-2);
}

.summary-row span:last-child {
  font-weight: 700;
  color: var(--ink);
}

.discount-row span:last-child {
  color: var(--success);
}

.free-shipping {
  color: var(--success) !important;
  font-weight: 800 !important;
}

.summary-divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.summary-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  padding: 8px 0 20px;
}

.summary-total span:last-child {
  font-size: 22px;
  color: var(--primary);
}

.free-shipping-notice {
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-2);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-checkout {
  width: 100%;
  padding: 16px 24px;
  font-size: 15px;
  margin-bottom: 14px;
}

.secure-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray);
  font-weight: 600;
}

.secure-badge i {
  color: var(--success);
}

.coupon-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 22px;
}

.coupon-card h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 14px;
}

.coupon-input-wrapper {
  display: flex;
  gap: 8px;
}

.coupon-input-wrapper input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: var(--transition);
  background: var(--bg);
}

.coupon-input-wrapper input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.coupon-input-wrapper button {
  padding: 11px 18px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.coupon-input-wrapper button:hover {
  background: var(--primary-dark);
}

#couponMessage {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
}

#couponMessage.success { color: var(--success); }
#couponMessage.error { color: var(--danger); }

/* ================= Empty Cart ================= */
.empty-cart {
  text-align: center;
  padding: 80px 20px;
  max-width: 500px;
  margin: 0 auto;
}

.empty-cart-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto 28px;
  background: var(--primary-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--primary);
}

.empty-cart h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.empty-cart p {
  font-size: 15px;
  color: var(--gray);
  margin-bottom: 28px;
  line-height: 1.8;
}

/* ================= Responsive ================= */
@media (max-width: 1200px) {
  .cart-layout {
    grid-template-columns: 1fr 360px;
    gap: 24px;
  }
}

@media (max-width: 900px) {
  .cart-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .cart-item {
    grid-template-columns: 90px 1fr auto;
    gap: 14px;
    padding: 16px 18px;
  }

  .cart-item-image {
    width: 90px;
    height: 90px;
  }

  .cart-item-qty,
  .cart-item-price,
  .cart-item-remove {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .cart-item-qty {
    display: flex;
  }

  .cart-item-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    min-width: 0;
  }

  .cart-item-price-mobile {
    display: block;
  }

  .cart-item-remove {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
  }

  .cart-item {
    position: relative;
  }

  .cart-item-remove {
    grid-column: auto;
    margin-right: auto;
  }

  .cart-item-details {
    padding-left: 0;
  }

  .cart-summary {
    position: static;
  }

  .cart-items-header {
    padding: 18px 20px;
  }

  .cart-items-header h2 {
    font-size: 16px;
  }

  .summary-card {
    padding: 22px;
  }
}

@media (max-width: 600px) {
  .cart-item {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cart-item-image {
    width: 100%;
    height: 200px;
  }

  .cart-item-image img {
    object-fit: cover;
  }

  .cart-item-remove {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--white);
    box-shadow: var(--shadow-md);
  }

  .cart-item-qty {
    justify-content: center;
  }

  .cart-item-price {
    text-align: center;
    justify-content: center;
  }
}
/* ============================================================
   Animations for AJAX Updates
   ============================================================ */

/* Badge Pulse */
.badge,
.mobile-tab-badge {
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Cart Item Smooth Transitions */
.cart-item {
  transition: background-color 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

/* Quantity Input Pulse */
.qty-selector-small input {
  transition: color 0.3s ease, background-color 0.3s ease;
}

.qty-selector-small input.updating {
  background-color: var(--primary-soft);
  color: var(--primary);
}

/* Price Update Animation */
.price-current,
.cart-item-price-mobile {
  transition: transform 0.2s ease, color 0.2s ease;
}

.price-current.updated,
.cart-item-price-mobile.updated {
  color: var(--primary);
  transform: scale(1.08);
}

/* Summary Rows Fade */
.summary-row {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.summary-row.updating {
  opacity: 0.5;
}

/* Total Update */
.summary-total span:last-child {
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), color 0.2s ease;
  display: inline-block;
}

/* Smooth Remove Animation */
.cart-item.removing {
  opacity: 0;
  transform: translateX(20px);
}

/* Loading Spinner */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  right: 50%;
  top: 50%;
  transform: translate(50%, -50%);
}

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

/* Cart Item Shimmer (Update Effect) */
@keyframes shimmer {
  0% { background-color: var(--primary-soft); }
  100% { background-color: transparent; }
}

.cart-item.updating {
  animation: shimmer 0.6s ease;
}

/* Empty Cart Fade In */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-cart {
  animation: fadeInUp 0.5s ease;
}

/* Free Shipping Notice Highlight */
@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.free-shipping-notice.updated {
  animation: pulseSoft 1s ease;
}

/* ============================================================
   Cart Popup (Modal - Simple & Safe)
   ============================================================ */

#cartPopupContainer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.cart-popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  animation: cartPopupFadeIn 0.3s ease;
}

@keyframes cartPopupFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cart-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 80px);
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  animation: cartPopupSlideIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
}

@keyframes cartPopupSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Header */
.cart-popup-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  flex-shrink: 0;
}

.cart-popup-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-popup-header h3 i {
  color: var(--primary);
  font-size: 18px;
}

.cart-popup-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: var(--transition);
  flex-shrink: 0;
}

.cart-popup-close:hover {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

/* Body */
.cart-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.cart-popup-body::-webkit-scrollbar {
  width: 6px;
}

.cart-popup-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

/* Loader */
.cart-popup-loader {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: cartSpin 0.8s linear infinite;
}

@keyframes cartSpin {
  to { transform: rotate(360deg); }
}

/* Empty */
.cart-popup-empty {
  text-align: center;
  padding: 60px 24px;
}

.cart-popup-empty-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto 20px;
  background: var(--primary-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--primary);
}

.cart-popup-empty h4 {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
}

.cart-popup-empty p {
  font-size: 13.5px;
  color: var(--gray);
  margin-bottom: 24px;
}

/* Items */
.cart-popup-items {
  max-height: 340px;
  overflow-y: auto;
  padding: 8px 0;
}

.cart-popup-items::-webkit-scrollbar {
  width: 6px;
}

.cart-popup-items::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.cart-popup-item {
  display: flex;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
  transition: background 0.2s ease;
}

.cart-popup-item:hover {
  background: var(--bg);
}

.cart-popup-item:last-child {
  border-bottom: none;
}

.cart-popup-item-image {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--line-soft);
  flex-shrink: 0;
}

.cart-popup-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-popup-item-info {
  flex: 1;
  min-width: 0;
}

.cart-popup-item-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cart-popup-item-name:hover {
  color: var(--primary);
}

.cart-popup-item-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
}

.cart-popup-item-qty {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--white);
}

.cart-popup-item-qty button {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: var(--transition);
}

.cart-popup-item-qty button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.cart-popup-item-qty span {
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 32px;
  min-width: 40px;
  text-align: center;
}

.cart-popup-item-remove {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
}

.cart-popup-item-remove:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

/* Footer */
.cart-popup-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}

.cart-popup-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.cart-popup-total-row span:last-child {
  font-weight: 700;
  color: var(--ink);
}

.cart-popup-total-final {
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 16px;
  font-weight: 800;
}

.cart-popup-total-final span:last-child {
  font-size: 20px;
  color: var(--primary);
}

.cart-popup-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.cart-popup-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: var(--transition);
}

.cart-popup-btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.cart-popup-btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.cart-popup-btn-outline {
  background: var(--white);
  border: 1.5px solid var(--line);
  color: var(--ink);
}

.cart-popup-btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Responsive */
@media (max-width: 600px) {
  .cart-popup {
    width: calc(100% - 24px);
    max-height: calc(100vh - 40px);
    border-radius: 16px;
  }

  .cart-popup-header {
    padding: 16px 18px;
  }

  .cart-popup-item {
    padding: 14px 18px;
    gap: 12px;
  }

  .cart-popup-item-image {
    width: 60px;
    height: 60px;
  }

  .cart-popup-footer {
    padding: 16px 18px;
  }

  .cart-popup-actions {
    flex-direction: column;
  }
}