/* ================================
   === SLIDING CART DRAWER ===
   ================================ */
:root {
  --cart-bg-color: var(--white);
  --cart-overlay: rgba(0, 0, 0, 0.5);
  --cart-text-dark: var(--text-dark);
  --cart-text-light: var(--white);
  --cart-border-color: var(--neutral-light);

  /* Header*/
  --cart-header-color: var(--neutral);
  --header-title: var(--h3);
  --header-title-color: var(--white);

  /* Footer */
  --cart-footer-color: var(--white);

  /* Items */
  --cart-items-wrapper-padding: var(--space-s);
  --cart-items-gap: calc(var(--cart-items-wrapper-padding) / 2);
  --single-item-gap: 10px;
  --product-name-size: var(--h4);
  --price-size: var(--h4);
  --thumb-radius: calc(var(--radius) / 2);

  /* info */
  --info-gap: 2px;

  /* input */
  --qty-input-size: var(--text-m);

  /* delete */
  --delete-item-bg: var(--danger);

  /* order note*/
  --order-note-text-size: calc(var(--text-xs) - 2px);
  --order-note-text-color: var(--neutral-dark);
  --order-note-bg: var(--neutral-dark-trans-10);
  --order-note-radius: 0;

  --qty-gap: 10px;

  /* Button */
  --cart-btn-color: var(--neutral);
  --cart-btn-color-hover: var(--neutral-hover);
  --cart-btn-radius: calc(var(--radius) / 2);
}

/* ================================
   === Disable Scroll Body on Cart open ===
   ================================ */
body.cart-open {
  overflow: hidden;
}

/* ================================
   === DRAWER ===
   ================================ */

.custom-cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  visibility: hidden;
}

.custom-cart-drawer.active {
  visibility: visible;
}

.custom-cart-overlay {
  position: absolute;
  inset: 0;
  background: var(--cart-overlay);
}

.custom-cart-panel {
  position: fixed; /* fixed lebih cocok agar panel tetap di tempat saat scroll */
  top: 0;
  right: 0;
  height: 100vh;
  width: 100%;
  background: var(--cart-bg-color); 
  transform: translateX(100%);
  transition: transform .3s ease-in-out;
  z-index: 9999;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.custom-cart-drawer.active .custom-cart-panel {
  transform: translateX(0);
  transition: transform .3s ease-in-out;
}


/* === Responsive Width === */
@media (min-width: 769px) {
  .custom-cart-panel {
    width: 400px;
  }
}

/* ================================
     === STICKY HEADER (TOP) ===
     ================================ */

.custom-cart-header {
  position: sticky;
  top: 0;
  background: var(--cart-header-color);
  padding: 16px 20px;
  z-index: 10;
  border-bottom: var(--cart-border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-cart-header h3 {
  margin: 0;
  color: var(--header-title-color);
  font-size: var(--header-title);
}

.custom-cart-close {
  color: var(--header-title-color);
  font-size: 30px;
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

/* ================================
     === CART ITEMS LIST ===
     ================================ */

.custom-cart-items {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--cart-items-wrapper-padding);
  flex: 1 1 auto;
  gap: var(--cart-items-gap);
}

.custom-cart-items > *:not(:last-child) {
  border-bottom: 1px solid var(--cart-border-color);
  padding-bottom: calc(var(--cart-items-wrapper-padding) / 2);
}

/* === SINGLE ITEM === */
.custom-cart-item {
  display: flex;
  gap: var(--single-item-gap);
  padding: 0;
  align-items: flex-start;
}

/* === THUMBNAIL === */
.cart-thumb {
  flex-shrink: 0;
}

.cart-thumb img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--thumb-radius);
  display: block;
}

/* === PRICE (RIGHT SIDE) === */
.cart-price {
  flex-shrink: 0;
  font-weight: 600;
  font-size: var(--product-name-size);
  color: var(--cart-text-dark);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

/* === INFO (MIDDLE) === */
.cart-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--info-gap);
}

.product-name {
  font-size: var(--product-name-size);
  font-weight: 500;
  line-height: 1.2;
  color: var(--cart-text-dark);
  margin: 0;
}

.product-note {
  font-size: var(--order-note-text-size);
  color: var(--order-note-text-color);
  background: var(--order-note-bg);
  padding: 3px 4px;
  line-height: 1.2;
  border-radius: var(--order-note-radius);
}

/* === QTY BUTTON === */
.qty-remove-wrapper {
  display: flex;
  gap: var(--qty-gap);
  margin-top: 0.2rem;
}

.qty-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-wrapper button {
  width: 20px;
  height: 20px;
  font-size: var(--qty-input-size);
  font-weight: 600;
  background: none;
  border: 1px solid var(--cart-border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease;
}

.qty-wrapper button:hover {
  background-color: #f2f2f2;
}

.qty-input {
  width: 50px;
  height: 20px;
  text-align: center;
  border: 1px solid var(--cart-border-color);
  background: transparent;
  font-size: var(--qty-input-size);
  font-weight: 600;
  pointer-events: none;
}

/* === REMOVE BUTTON === */
.remove-item {
  background: var(--delete-item-bg);
  color: var(--cart-text-light);
  padding: 3px 6px;
  cursor: pointer;
  font-size: var(--qty-input-size);
  font-weight: 600;
  line-height: 1;
  border: none;
  transition: background 0.2s ease;
}

/* === Cart Sub Total === */

.cart-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #222;
}

.cart-subtotal .label {
  flex: 1;
  text-align: left;
}

.cart-subtotal .price {
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}

/* ================================
     === STICKY SUMMARY (BOTTOM) ===
     ================================ */

.custom-cart-summary {
  position: sticky;
  bottom: 0;
  background: var(--cart-footer-color);
  padding: 16px 20px;
  border-top: 1px solid var(--cart-border-color);
  z-index: 10;
}

.custom-cart-summary p {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #222;
}

.custom-cart-checkout,
a.custom-cart-checkout,
a:hover.custom-cart-checkout {
  display: inline-block;
  background: var(--cart-btn-color);
  color: var(--white);
  padding: 12px 20px;
  font-size: var(--text-m);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.6s ease;
  width: 100%;
  text-align: center;
}

/* ================================
     === EMPTY CART ===
     ================================ */

.custom-cart-empty {
  display: none;
  gap: var(--space-m);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-m) var(--space-s);
  height: 100%;
}

.custom-cart-empty h4 {
  font-size: var(--h3);
}

.custom-cart-empty p {
  font-size: var(--text-m);
}

.custom-cart-empty-btn {
  background: var(--cart-btn-color);
  color: var(--white);
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--cart-btn-radius);
  cursor: pointer;
  font-size: var(--text-s);
  font-weight: 600;
}

/* ================================
     === Produk Habis ===
     ================================ */

.custom-cart-notice {
  background: var(--danger-ultra-light);
  border-left: 4px solid var(--danger);
  color: var(--danger-ultra-dark);
  padding: 10px 12px;
  margin-bottom: var(--space-s);
  font-size: var(--text-s);
}
.custom-cart-notice .notice-item {
  margin-bottom: 5px;
}

.custom-cart-checkout.disabled {
  background-color: #ccc;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.6;
}
