/*
 * MoPower mobile cart RC2
 * Presentation-only overrides for the header mini-cart and checkout cart.
 * Requires the existing MoPowerLab v3 stylesheet stack.
 */

.mopowerlab-theme .mpl-mini-cart-menu {
  color: var(--mpl-muted, #d6dee7);
}

/* Override the legacy ID-based 100% minimum without changing the desktop design. */
.mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  width: min(380px, calc(100vw - 32px));
  min-width: 0;
  max-width: none;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-table,
.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-totals {
  width: 100%;
  margin: 0;
  table-layout: fixed;
}

.mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu > li > div {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-table td {
  box-sizing: border-box;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-thumb {
  width: 58px;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-quantity {
  width: 48px;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-price {
  width: 96px;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-remove {
  width: 50px;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-name,
.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-name a,
.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-name small {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-name > a {
  color: #fff;
  font-weight: 700;
  line-height: 1.35;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-quantity,
.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-price {
  white-space: nowrap;
}

.mopowerlab-theme .mpl-mini-cart-menu .mpl-mini-cart-remove .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mopowerlab-theme .mpl-mini-cart-actions {
  margin: 14px 0 0;
  text-align: right;
}

.mopowerlab-theme .mpl-mini-cart-action {
  text-decoration: none;
}

/* Restore the normal desktop table at the v3 768-800px overlap. */
@media (min-width: 768px) and (max-width: 800px) {
  .mpl-v3 #checkout-cart table.mpl-cart-table {
    display: table !important;
    width: 100%;
  }

  .mpl-v3 #checkout-cart table.mpl-cart-table thead {
    position: static;
    display: table-header-group !important;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .mpl-v3 #checkout-cart table.mpl-cart-table tbody {
    display: table-row-group !important;
  }

  .mpl-v3 #checkout-cart table.mpl-cart-table tr.mpl-cart-row {
    display: table-row !important;
    width: auto;
    padding: 0;
    border: 0;
  }

  .mpl-v3 #checkout-cart table.mpl-cart-table td.mpl-cart-cell {
    display: table-cell !important;
    width: auto;
    padding: 12px 8px;
  }

  .mpl-v3 #checkout-cart table.mpl-cart-table td.mpl-cart-cell::before {
    display: none !important;
    content: none !important;
  }
}

@media (max-width: 768px) {
  /* Anchor the panel to the actual responsive header, not the 38/44px cart button. */
  .mopowerlab-theme .mpl-site-header {
    overflow: visible;
  }

  .mopowerlab-theme .mpl-cart-wrap,
  .mopowerlab-theme .mpl-cart-wrap #cart {
    position: static;
  }

  .mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu {
    position: absolute;
    top: 100%;
    right: -8px;
    left: auto;
    width: min(440px, calc(100vw - 24px));
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - 200px);
    max-height: calc(100dvh - 200px);
    margin: 0;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    box-sizing: border-box;
    border: 1px solid var(--mpl-line, rgba(137, 151, 166, .22));
    border-radius: 6px;
    background: #111a24;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  }

  .mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu > li,
  .mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu > li > div {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .mopowerlab-theme .mpl-mini-cart-table,
  .mopowerlab-theme .mpl-mini-cart-table tbody {
    display: block;
    width: 100%;
  }

  .mopowerlab-theme .mpl-mini-cart-table tr {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto auto;
    gap: 8px 10px;
    align-items: start;
    width: 100%;
    padding: 12px 0;
    border-bottom: 1px solid rgba(137, 151, 166, .18);
  }

  .mopowerlab-theme .mpl-mini-cart-table tr:first-child {
    padding-top: 0;
  }

  .mopowerlab-theme .mpl-mini-cart-table td {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left !important;
  }

  .mopowerlab-theme .mpl-mini-cart-thumb {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .mopowerlab-theme .mpl-mini-cart-thumb .img-thumbnail {
    width: 48px;
    max-width: 48px;
    height: auto;
    padding: 4px;
  }

  .mopowerlab-theme .mpl-mini-cart-name {
    grid-column: 2 / 4;
    grid-row: 1;
    padding-right: 4px;
  }

  .mopowerlab-theme .mpl-mini-cart-quantity {
    grid-column: 2;
    grid-row: 2;
    color: var(--mpl-soft, #8997a6);
    font-size: 13px;
  }

  .mopowerlab-theme .mpl-mini-cart-price {
    grid-column: 3;
    grid-row: 2;
    color: #fff;
    font-weight: 800;
    text-align: right !important;
  }

  .mopowerlab-theme .mpl-mini-cart-remove {
    grid-column: 4;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .mopowerlab-theme .mpl-mini-cart-remove .btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 4px;
  }

  .mopowerlab-theme .mpl-mini-cart-voucher .mpl-mini-cart-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--mpl-line, rgba(137, 151, 166, .22));
    border-radius: 6px;
    color: var(--mpl-blue-2, #36a3ff);
  }

  .mopowerlab-theme .mpl-mini-cart-summary {
    position: sticky;
    bottom: -12px;
    margin: 0 -12px -12px;
    padding: 12px;
    border-top: 1px solid var(--mpl-line, rgba(137, 151, 166, .22));
    background: #111a24;
  }

  .mopowerlab-theme .mpl-mini-cart-totals td {
    padding: 7px 4px;
    border-color: rgba(137, 151, 166, .18);
  }

  .mopowerlab-theme .mpl-mini-cart-totals td:last-child {
    color: #fff;
    font-weight: 800;
  }

  .mopowerlab-theme .mpl-mini-cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mopowerlab-theme .mpl-mini-cart-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--mpl-line-blue, rgba(33, 150, 243, .32));
    border-radius: 4px;
    background: rgba(33, 150, 243, .12);
    color: #fff;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
  }

  .mopowerlab-theme .mpl-mini-cart-action:hover,
  .mopowerlab-theme .mpl-mini-cart-action:focus {
    border-color: var(--mpl-blue-2, #36a3ff);
    background: rgba(33, 150, 243, .22);
    color: #fff;
  }

  .mopowerlab-theme .mpl-mini-cart-action-primary {
    border-color: var(--mpl-blue, #2196f3);
    background: var(--mpl-blue, #2196f3);
    color: #06090d;
  }

  .mopowerlab-theme .mpl-mini-cart-empty {
    margin: 0;
    padding: 22px 14px;
    color: var(--mpl-muted, #d6dee7);
    line-height: 1.5;
  }
}

@media (max-width: 480px) {
  .mopowerlab-theme .mpl-cart-wrap #cart .mpl-mini-cart-menu {
    right: -4px;
  }
}

@media (max-width: 767px) {
  /* Full cart: mobile product cards, while desktop/tablet keeps the table. */
  .mopowerlab-theme #checkout-cart .mpl-cart-table,
  .mopowerlab-theme #checkout-cart .mpl-cart-table tbody {
    display: block;
    width: 100%;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-table .mpl-cart-row {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px 14px;
    width: 100%;
    margin: 0 0 16px;
    padding: 16px;
    border: 1px solid var(--mpl-line, rgba(137, 151, 166, .22));
    border-radius: 6px;
    background: rgba(16, 23, 32, .96);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-table .mpl-cart-cell {
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    white-space: normal;
    text-align: left !important;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-image {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-image .img-thumbnail {
    width: 78px;
    max-width: 78px;
    height: auto;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-product {
    grid-column: 2;
    grid-row: 1;
    overflow-wrap: anywhere;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-product > a {
    display: inline-block;
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.35;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-product small,
  .mopowerlab-theme #checkout-cart .mpl-cart-product .label {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-model {
    grid-column: 2;
    grid-row: 2;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-quantity,
  .mopowerlab-theme #checkout-cart .mpl-cart-price,
  .mopowerlab-theme #checkout-cart .mpl-cart-line-total {
    grid-column: 1 / -1;
    padding-top: 12px;
    border-top: 1px solid rgba(137, 151, 166, .16);
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-model::before,
  .mopowerlab-theme #checkout-cart .mpl-cart-quantity::before,
  .mopowerlab-theme #checkout-cart .mpl-cart-price::before,
  .mopowerlab-theme #checkout-cart .mpl-cart-line-total::before {
    display: block;
    margin: 0 0 5px;
    color: var(--mpl-soft, #8997a6);
    content: attr(data-label) !important;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-model::before {
    margin-bottom: 3px;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-quantity .input-group {
    display: flex;
    width: 100%;
    max-width: none !important;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-quantity .form-control {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-quantity .input-group-btn {
    display: flex;
    width: auto;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-quantity .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-price,
  .mopowerlab-theme #checkout-cart .mpl-cart-line-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    color: #fff;
    font-weight: 700;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-price::before,
  .mopowerlab-theme #checkout-cart .mpl-cart-line-total::before {
    margin: 0;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-line-total {
    font-size: 18px;
    font-weight: 900;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-voucher-row .mpl-cart-image,
  .mopowerlab-theme #checkout-cart .mpl-cart-voucher-row .mpl-cart-model {
    display: none;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-voucher-row .mpl-cart-product {
    grid-column: 1 / -1;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-totals,
  .mopowerlab-theme #checkout-cart .mpl-cart-totals tbody {
    display: table;
    width: 100%;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-totals tbody {
    display: table-row-group;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-totals tr {
    display: table-row;
    width: auto;
    padding: 0;
    border: 0;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-totals td {
    display: table-cell;
    width: auto;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(137, 151, 166, .14);
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-buttons {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 12px;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-buttons > div,
  .mopowerlab-theme #checkout-cart .mpl-cart-buttons .btn {
    width: 100%;
  }

  .mopowerlab-theme #checkout-cart .mpl-cart-checkout {
    min-height: 54px;
    font-size: 17px;
    font-weight: 900;
  }
}

@media (max-width: 380px) {
  /* Preserve all four actions while allowing the logo/actions to stack cleanly. */
  .mopowerlab-theme .mpl-header-main {
    flex-wrap: wrap;
    row-gap: 10px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .mopowerlab-theme .mpl-header-main .mpl-brand {
    flex: 0 0 100%;
    width: 100%;
    max-width: none;
    min-width: 0;
    text-align: center;
  }

  .mopowerlab-theme .mpl-header-main .mpl-brand a {
    width: 145px;
    max-width: 100%;
    margin: 0 auto;
  }

  .mopowerlab-theme .mpl-header-main .mpl-header-actions {
    margin-right: auto;
    margin-left: auto;
    gap: 2px;
  }

  .mopowerlab-theme .mpl-mini-cart-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mopowerlab-theme .mpl-mini-cart-menu,
  .mopowerlab-theme #checkout-cart * {
    scroll-behavior: auto;
  }
}
