/* Grain Stock Guard — intentionally mirrors Grain's existing palette/spacing. */
.gsg-low-stock {
  display: none;
  align-items: center;
  gap: .45rem;
  margin: 0 0 1.2rem;
  padding: .58rem .78rem;
  border: 1.5px solid rgba(139, 26, 107, .16);
  border-radius: 10px;
  background: rgba(139, 26, 107, .055);
  color: var(--grape, #8B1A6B);
  font-family: 'Tajawal', sans-serif;
  font-size: .72rem;
  line-height: 1.45;
  font-weight: 900;
}
.gsg-low-stock.is-visible { display: flex; }
.gsg-low-stock::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--red, #D94530);
  box-shadow: 0 0 0 4px rgba(217, 69, 48, .09);
}
#grain-size-opts.gsg-low-stock-active { margin-bottom: .55rem !important; }

/* Grain custom cart drawer: visually show the hard ceiling on +. */
.cart-qty-plus.gsg-at-max,
.cart-qty-plus[aria-disabled="true"] {
  opacity: .38;
  cursor: not-allowed !important;
}

/* Standard Woo quantity inputs, when present. */
.woocommerce input.qty.gsg-clamped {
  border-color: var(--grape, #8B1A6B) !important;
  box-shadow: 0 0 0 2px rgba(139, 26, 107, .08);
}

@media (max-width: 599px) {
  .gsg-low-stock {
    margin-bottom: 1rem;
    padding: .52rem .68rem;
    border-radius: 9px;
    font-size: .68rem;
  }
}

/* v1.1.0 — make stale-cart stock problems impossible to miss. */
.cart-drawer-item.gsg-stock-stale {
  position: relative;
  outline: 1.5px solid rgba(217, 69, 48, .38);
  outline-offset: -1px;
  border-radius: 12px;
  background: rgba(217, 69, 48, .035);
}
.gsg-cart-stock-warning,
.gsg-line-stock-warning {
  margin-top: .45rem;
  padding: .48rem .58rem;
  border: 1px solid rgba(217, 69, 48, .22);
  border-radius: 8px;
  background: rgba(217, 69, 48, .07);
  color: var(--red, #D94530);
  font-family: 'Tajawal', sans-serif;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1.45;
}
.gsg-line-stock-warning {
  display: block;
  max-width: 420px;
}
.gsg-checkout-stock-row > td {
  padding: .5rem 0 1rem !important;
  border: 0 !important;
}
.gsg-checkout-stock-summary {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .72rem .82rem;
  border: 1.5px solid rgba(217, 69, 48, .25);
  border-radius: 10px;
  background: rgba(217, 69, 48, .065);
  color: var(--dark, #1A0F0A);
  font-family: 'Tajawal', sans-serif;
  line-height: 1.45;
}
.gsg-checkout-stock-summary strong {
  color: var(--red, #D94530);
  font-size: .78rem;
  font-weight: 900;
}
.gsg-checkout-stock-summary span {
  font-size: .68rem;
  font-weight: 700;
}
.gsg-stock-stale-pulse {
  animation: gsgStockPulse .7s ease-in-out 2;
}
@keyframes gsgStockPulse {
  0%, 100% { transform: translateZ(0) scale(1); box-shadow: none; }
  50% { transform: translateZ(0) scale(.985); box-shadow: 0 0 0 4px rgba(217, 69, 48, .10); }
}

@media (max-width: 599px) {
  .gsg-cart-stock-warning,
  .gsg-line-stock-warning {
    font-size: .64rem;
    padding: .44rem .52rem;
  }
  .gsg-checkout-stock-summary {
    padding: .64rem .7rem;
  }
}


/* v1.1.1 — plugin-owned stock toast.
   Do not inherit Grain's single-line #grain-toast styling; long Arabic
   messages must wrap cleanly on iPhone/Safari without leaving the viewport. */
.gsg-stock-toast {
  position: fixed;
  z-index: 999999;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  width: auto;
  max-width: min(480px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: .72rem .9rem;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  background: var(--red, #D94530);
  color: var(--cream, #F5EDD8);
  box-shadow: 0 10px 28px rgba(26,15,10,.22);
  font-family: 'Tajawal', sans-serif;
  font-size: .78rem;
  font-weight: 900;
  line-height: 1.55;
  text-align: center;
  direction: rtl;
  white-space: normal !important;
  overflow: visible !important;
  overflow-wrap: anywhere;
  word-break: normal;
  height: auto !important;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(-50%, 12px, 0);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
}
.gsg-stock-toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate3d(-50%, 0, 0);
}

@media (max-width: 599px) {
  .gsg-stock-toast {
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    width: auto;
    max-width: none;
    padding: .68rem .76rem;
    border-radius: 11px;
    font-size: .72rem;
    line-height: 1.5;
    transform: translate3d(0, 12px, 0);
  }
  .gsg-stock-toast.is-visible {
    transform: translate3d(0, 0, 0);
  }
}
