/* ==========================================================================
   Mirror Phase Cart Sidebar Widget  v2
   ========================================================================== */

/* ---------- Shared vars ---------- */
.mpc-widget {
  --mpc-duration: 380ms;
  --mpc-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mpc-overlay-opacity: 0;
  display: inline-flex;
  align-items: center;
  position: relative;
  font-family: inherit;
  direction: rtl;
  float: inline-end;
}

/* ==========================================================================
   TRIGGER BUTTON
   ========================================================================== */
.mpc-cart-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  position: relative;
  color: inherit;
  transition: opacity 0.2s;
  font-family: inherit;
}
.mpc-cart-btn:hover {
  opacity: 0.7;
}
.mpc-cart-btn svg {
  display: block;
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  transition: width 0.15s, height 0.15s;
}

/* Badge */
.mpc-badge {
  position: absolute;
  bottom: 0px;
  right: 0px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0336e4;
  color: #fff;
  line-height: 1.6;
  pointer-events: none;
  transform: scale(1);
  opacity: 1;
  transition: transform 0.25s var(--mpc-ease), opacity 0.25s;
  will-change: transform, opacity;
}
.mpc-badge[data-count='0'] {
  transform: scale(0);
  opacity: 0;
}
.mpc-badge i {
  position: absolute;
  top: -1px;
}

/* ==========================================================================
   SIDEBAR WRAPPER
   ========================================================================== */
.mpc-sidebar {
  position: fixed;
  inset: 0;
  z-index: 999999;
  direction: rtl;
  pointer-events: none; /* inactive by default */
}
.mpc-sidebar[hidden] {
  display: none;
}

/* Once removed from hidden, pointer-events come back via is-open */
.mpc-sidebar.is-open {
  pointer-events: auto;
}

/* Overlay */
.mpc-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--mpc-duration) var(--mpc-ease);
  will-change: opacity;
}
.mpc-sidebar.is-open .mpc-overlay {
  opacity: 1;
}

/* ==========================================================================
   PANEL COMMON
   ========================================================================== */
.mpc-panel {
  position: absolute;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: transform;
}

/* ==========================================================================
   PANEL – DESKTOP: slide from right
   ========================================================================== */
@media (min-width: 768px) {
  .mpc-panel {
    top: 0;
    left: 0;
    height: 100%;
    width: 524px;
    max-width: 100vw;
    transform: translateX(-105%); /* start fully off-screen */
    transition: transform var(--mpc-duration) var(--mpc-ease);
  }
  .mpc-sidebar.is-open .mpc-panel {
    transform: translateX(0);
  }
}

/* ==========================================================================
   PANEL – MOBILE: slide from bottom
   ========================================================================== */
@media (max-width: 767px) {
  .mpc-panel {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: var(--mpc-mobile-max-height, 65%);
    border-radius: 16px 16px 0 0;
    transform: translateY(105%); /* start fully below viewport */
    transition: transform var(--mpc-duration) var(--mpc-ease);
  }
  .mpc-sidebar.is-open .mpc-panel {
    transform: translateY(0);
  }

  /* drag handle */
  .mpc-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #d0d0d0;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
}

/* ==========================================================================
   PANEL HEADER
   ========================================================================== */
.mpc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 36px;
  flex-shrink: 0;
}
.mpc-panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #000;
}
.mpc-panel-count:not(:empty)::before {
  content: '(';
}
.mpc-panel-count:not(:empty)::after {
  content: ')';
}

.mpc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  color: inherit;
  transition: opacity 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.mpc-close-btn svg {
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   PANEL BODY
   ========================================================================== */
.mpc-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* no padding here – items carry their own */
}

.mpc-panel [hidden='hidden'] {
  display: none;
}

/* ==========================================================================
   ITEMS LIST
   Desktop: vertical stack
   ========================================================================== */
.mpc-items-list {
  display: flex;
  flex-direction: column;
}

/* Mobile: horizontal scroll track */
@media (max-width: 767px) {
  .mpc-panel-header {
    padding: 16px;
    margin-bottom: 20px;
  }

  .mpc-panel-body {
    overflow-y: hidden;
    overflow-x: auto;
    padding: 16px 16px 8px;
    /* hide scrollbar but keep functionality */
    scrollbar-width: none;
  }
  .mpc-panel-body::-webkit-scrollbar {
    display: none;
  }

  .mpc-items-list {
    flex-direction: row;
    gap: 20px;
    padding: 0;
    width: max-content;
    min-width: 100%;
  }
}

/* ==========================================================================
   ITEM – Desktop: horizontal (image left/right, details next to it)
   ========================================================================== */
.mpc-item {
  display: flex;
  flex-direction: row; /* image + details side by side */
  align-items: flex-start;
  gap: 24px;
  padding: 0 36px 20px;
}

/* ==========================================================================
   ITEM – Mobile: horizontal card with image on right, text on left
   ========================================================================== */
@media (max-width: 767px) {
  .mpc-item {
    flex-direction: row-reverse; /* keep row: image RIGHT, details LEFT */
    align-items: flex-start;
    gap: 10px;
    padding: 0;
    border-bottom: none;
    background: transparent !important;
    width: 87.38vw;
    flex-shrink: 0;
  }
  .mpc-item:last-child {
    padding-left: 16px; /* right padding on last card */
  }
}

/* ==========================================================================
   ITEM IMAGE
   ========================================================================== */
.mpc-item-image {
  width: 95px;
  min-width: 95px;
  height: 110px;
  object-fit: cover;
  background: #f0f0f0;
  flex-shrink: 0;
  display: block;
  order: 2; /* image on the LEFT in desktop RTL = visually right of details */
}

/* On desktop RTL: image goes to the right side */
@media (min-width: 768px) {
  .mpc-item-image {
    order: 1; /* image after details in DOM order → visually left because RTL */
  }
  .mpc-item-details {
    order: 2;
  }
}

/* ==========================================================================
   ITEM DETAILS
   ========================================================================== */
.mpc-item-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mpc-item-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #000;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 20px;
}

.mpc-item-meta {
  font-size: 16px;
  color: #666;
  line-height: 26px;
}
.mpc-item-meta span {
  display: block;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 0.5px solid #e0e0e0;
}

.mpc-item-qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.mpc-item-qty-title {
  flex-grow: 1;
}

.mpc-qty-btn {
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
}

.mpc-qty-value {
  font-size: 16px;
  line-height: 26px;
  min-width: 38px;
  text-align: center;
  font-weight: 700;
}

.mpc-item-price {
  font-size: 13px;
  color: #000;
  margin-bottom: 13px;
  font-weight: 500;
}

.mpc-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  text-decoration: underline;
  color: #000;
  transition: opacity 0.2s;
  font-family: inherit;
  align-self: end;
  text-underline-offset: 4px;
  padding: 0;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.mpc-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 180px;
  padding: 40px 20px;
}
.mpc-empty-text {
  font-size: 14px;
  color: #000;
  text-align: center;
  margin: 0;
}

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */
.mpc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
.mpc-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e0e0e0;
  border-top-color: #000;
  border-radius: 50%;
  animation: mpc-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes mpc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   PANEL FOOTER
   ========================================================================== */
.mpc-panel-footer {
  flex-shrink: 0;
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (max-width: 768px) {
  .mpc-panel-footer {
    padding: 16px;
    margin-top: 20px;
  }
}

.mpc-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mpc-total-value {
  direction: ltr;
  unicode-bidi: embed;
}

.mpc-checkout-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: #000;
  color: #fff;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  border-radius: 0;
  transition: opacity 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}
.mpc-checkout-btn:hover {
  opacity: 0.85;
  text-decoration: none;
  color: #fff;
}

/* ==========================================================================
   TRUST BADGES
   ========================================================================== */
.mpc-trust-badges {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.mpc-trust-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #000;
}
.mpc-trust-badge svg {
  width: 20px;
  height: 20px;
  fill: none;
  flex-shrink: 0;
}
.mpc-trust-badge span {
  font-size: 10px;
  color: #000;
  line-height: 1.3;
  white-space: nowrap;
}

.mpc-trust-badge-devider:last-child {
  display: none;
}
.mpc-trust-badge-devider {
  height: 36.5px;
  width: 1px;
  background: #e0e0e0;
  top: 2px;
}

/* ==========================================================================
   BODY SCROLL LOCK
   ========================================================================== */
body.mpc-no-scroll {
  overflow: hidden;
}

/* Item loading state */
.mpc-item--loading {
    pointer-events: none;
}
.mpc-item--loading .mpc-item-details {
    opacity: 0.4;
}
.mpc-item--loading .mpc-item-image {
    opacity: 0.4;
}
.mpc-item--loading .mpc-qty-value {
    position: relative;
}
.mpc-item--loading .mpc-qty-value::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    border: 1.5px solid #ccc;
    border-top-color: #000;
    border-radius: 50%;
    animation: mpc-spin 0.6s linear infinite;
}

/* Pointer cursor on qty buttons */
.mpc-qty-btn {
    cursor: pointer;
}
