/**
 * ==========================================================
 * Kingdom Nexus - Cart Drawer Style (Production)
 * - Right side drawer
 * - No overlay, no body lock
 * - Scoped to .knx-cart-drawer
 * ==========================================================
 */

.knx-cart-drawer {
  position: fixed;
  top: var(--knx-top-offset, 0px); /* Respect theme header offset */
  right: -420px; /* hidden by default */
  width: 380px;
  max-width: 100%;
  height: calc(100vh - var(--knx-top-offset, 0px)); /* Fill remaining viewport */
  background-color: #ffffff;
  box-shadow: -2px 0 14px rgba(15, 23, 42, 0.18);
  z-index: 1400;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

/* Open state (JS toggles .is-open) */
.knx-cart-drawer.is-open {
  right: 0;
}

/* ===== HEADER ===== */

.knx-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.knx-cart-drawer__header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

.knx-cart-drawer__close {
  border: none;
  background: #f3f4f6;
  color: #111827;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
}

.knx-cart-drawer__close:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

/* ===== BODY (ITEMS) ===== */

.knx-cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 12px 16px;
  background-color: #f9fafb;
}

/* Empty state */
.knx-cart-empty {
  padding: 32px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* ===== CART LINE ===== */

.knx-cart-line {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 12px 10px 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.knx-cart-line__top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Title + price row */
.knx-cart-line__title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.knx-cart-line__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

/* Clickable cart line (entire card) */
.knx-cart-line--clickable {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.knx-cart-line--clickable:hover {
  background-color: #f9fafb;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.knx-cart-line--clickable:hover .knx-cart-line__name {
  color: #0b793a;
}

/* Buttons inside clickable line should not trigger navigation */
.knx-cart-line--clickable .knx-cart-line__qty-btn,
.knx-cart-line--clickable .knx-cart-line__remove {
  position: relative;
  z-index: 1;
}

.knx-cart-line__price {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

/* Modifiers summary */
.knx-cart-line__mods {
  font-size: 13px;
  color: #6b7280;
}

/* Notes */
.knx-cart-line__notes {
  font-size: 12px;
  color: #4b5563;
  background: #f3f4f6;
  border-radius: 6px;
  padding: 4px 6px;
}

/* Bottom row: Qty + Remove */
.knx-cart-line__bottom {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 4px;
}

/* Qty buttons */
.knx-cart-line__qty-btn {
  border: none;
  background: #f3f4f6;
  color: #111827;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.knx-cart-line__qty-btn:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
}

.knx-cart-line__qty {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

/* Remove button */
.knx-cart-line__remove {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, transform 0.15s ease;
}

.knx-cart-line__remove:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  transform: translateY(-1px);
}

/* ===== FOOTER ===== */

.knx-cart-drawer__footer {
  border-top: 1px solid #e5e7eb;
  padding: 10px 16px 14px 16px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Extra bottom padding for mobile bottom nav bar */
  padding-bottom: 90px;
}

/* Total */
.knx-cart-drawer__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
  color: #374151;
}

.knx-cart-drawer__total span {
  font-weight: 500;
}

.knx-cart-drawer__total strong {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

/* Checkout button */
.knx-cart-drawer__checkout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  background: #0b793a;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 3px 10px rgba(11, 121, 58, 0.35);
}

.knx-cart-drawer__checkout:hover {
  background: #08612f;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(11, 121, 58, 0.45);
}

/* ===== SCROLLBAR (only inside drawer body) ===== */

.knx-cart-drawer__body::-webkit-scrollbar {
  width: 6px;
}

.knx-cart-drawer__body::-webkit-scrollbar-track {
  background: #e5e7eb;
}

.knx-cart-drawer__body::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 999px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .knx-cart-drawer {
    width: 100%;
    max-width: 420px;
    right: -420px;
  }

  .knx-cart-drawer.is-open {
    right: 0;
  }

  .knx-cart-drawer__body {
    padding: 10px 12px;
  }

  .knx-cart-line {
    padding: 10px;
  }
}
