/* ==========================================================================
   OlO Menswear — Slide-Over Bag Drawer
   Clean, luxury, high-converting cart drawer.
   ========================================================================== */

.bag-dialog:not([open]) {
  display: none !important;
}

.bag-dialog[open] {
  display: flex !important;
  flex-direction: column;
}

.bag-dialog {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  inset-inline-start: auto;
  width: min(100vw, 440px);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: var(--space-6);
  border: none;
  border-inline-start: 1px solid var(--color-border);
  background: var(--color-bg);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.16);
  box-sizing: border-box;
  overflow: hidden;
  z-index: 999999;
}

.bag-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.bag-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block-end: var(--space-4);
  border-block-end: 1px solid var(--color-border);
}

.bag-heading h2 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-h4);
  font-weight: 600;
  color: var(--color-text);
}

.bag-heading button[data-bag-close] {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.bag-heading button[data-bag-close]:hover {
  background: var(--color-border);
}

[data-bag-content] {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-block: var(--space-4);
}

/* Free Shipping Progress Tier */
.olo-bag-shipping-tier {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--control-radius);
  padding: var(--space-3) var(--space-4);
  margin-block-end: var(--space-5);
}

.olo-bag-shipping-tier.is-achieved {
  background: rgba(16, 132, 116, 0.08);
  border-color: rgba(16, 132, 116, 0.25);
}

.tier-bar-message {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  color: var(--color-text);
  margin-block-end: var(--space-2);
}

.tier-bar-message .tier-icon {
  font-size: 16px;
}

.tier-bar-track {
  height: 6px;
  width: 100%;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.tier-bar-fill {
  height: 100%;
  background: #108474;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.olo-bag-shipping-tier.is-achieved .tier-bar-fill {
  background: #108474;
}

/* Cart Items List */
.olo-bag-items {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.olo-bag-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: var(--space-4);
  padding-block: var(--space-4);
  border-block-end: 1px solid var(--color-border);
  align-items: start;
}

.olo-bag-item[aria-busy="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.olo-bag-item__media {
  aspect-ratio: 4 / 5;
  border-radius: var(--control-radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.olo-bag-item__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.olo-bag-item__body {
  min-width: 0;
}

.olo-bag-item__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.olo-bag-item__title {
  margin: 0;
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1.35;
}

.olo-bag-item__title a {
  text-decoration: none;
  color: var(--color-text);
}

.olo-bag-remove {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.olo-bag-remove:hover {
  color: #d9383a;
}

.olo-bag-item__variations {
  margin-block-start: var(--space-1);
  font-size: 12px;
  color: var(--color-text-muted);
}

.olo-bag-item__variations .variation {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.olo-bag-item__variations dt,
.olo-bag-item__variations dd {
  display: inline;
  margin: 0;
}

.olo-bag-item__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-block-start: var(--space-3);
}

/* Quantity Stepper */
.olo-quantity {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--control-radius);
  background: var(--color-surface);
  overflow: hidden;
}

.olo-quantity button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.olo-quantity button:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
}

.olo-quantity button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.olo-quantity output {
  min-width: 32px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.olo-bag-item__price {
  font-size: var(--text-small);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

/* Drawer Footer & Actions */
.olo-bag-summary {
  margin-block-start: auto;
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--color-border);
}

.olo-bag-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: var(--space-2);
}

.olo-bag-totals .totals-label {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text);
}

.olo-bag-totals .totals-amount {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.olo-bag-note {
  margin: 0 0 var(--space-4);
  font-size: 12px;
  color: var(--color-text-muted);
}

.olo-bag-reassurance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--control-radius);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.olo-bag-actions {
  display: grid;
  gap: var(--space-3);
}

.olo-bag-checkout-btn {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 52px;
  border-radius: var(--control-radius);
  background: var(--color-accent);
  color: var(--olo-ivory);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.olo-bag-checkout-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

.olo-bag-edit-link {
  display: block;
  text-align: center;
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.olo-bag-edit-link:hover {
  color: var(--color-text);
}

/* Empty State */
.olo-bag-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding-block: var(--space-12);
  gap: var(--space-3);
}

.olo-bag-empty__icon {
  font-size: 48px;
}

.olo-bag-empty__title {
  margin: 0;
  font-size: var(--text-h4);
  font-weight: 600;
}

.olo-bag-empty__subtitle {
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-text-muted);
  max-width: 260px;
}

.olo-bag-error {
  margin-block: 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-inline-start: 3px solid #d9383a;
  background: rgba(217, 56, 58, 0.08);
  font-size: var(--text-small);
  color: #d9383a;
}

/* ==========================================================================
   Mobile Viewport Optimizations (<= 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .bag-dialog {
    width: 100vw;
    padding: var(--space-4);
  }

  .bag-heading {
    padding-block-end: var(--space-3);
  }

  .bag-heading h2 {
    font-size: var(--text-h5, 18px);
  }

  .olo-bag-shipping-tier {
    padding: var(--space-2) var(--space-3);
    margin-block-end: var(--space-3);
  }

  .olo-bag-item {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: var(--space-3);
    padding-block: var(--space-3);
  }

  .olo-bag-reassurance {
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-2);
  }

  .olo-bag-reassurance .reassurance-pill {
    font-size: 10px;
  }

  .olo-bag-summary {
    padding-block-start: var(--space-3);
    padding-block-end: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  }

  .olo-bag-checkout-btn {
    min-height: 50px;
    font-size: 14px;
  }
}
