/* ========================================
   SHOP-CART.CSS - Header cart button, cart sidebar and toasts
   Loaded on every public page (the header cart button is global).
   Every class is prefixed sg- so it cannot collide with Bootstrap or global.css.
   Colours come from the existing olive palette only.
   ======================================== */

/* ---------- Header cart button ---------- */
.sg-header-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  order: 3; /* desktop: after the nav and Request Sourcing */
  color: #636B2F;
  background: transparent;
  border: 1px solid rgba(99, 107, 47, 0.35);
  border-radius: 999px;
  font-size: 1.15rem;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.sg-header-cart:hover,
.sg-header-cart:focus-visible {
  color: #636B2F;
  background-color: rgba(99, 107, 47, 0.1);
  border-color: #636B2F;
  outline: none;
}

.sg-header-cart__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background-color: #636B2F;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.sg-header-cart__count[hidden] {
  display: none;
}

@media (max-width: 1199px) {
  .sg-header-cart {
    order: 0;
    margin-left: auto;
  }

  /* The cart button now takes the auto margin, so the hamburger sits beside it */
  .sg-header-cart + .header__toggler {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .sg-header-cart {
    width: 40px;
    height: 40px;
  }
}

/* ---------- Overlay + sidebar ---------- */
body.sg-cart-locked {
  overflow: hidden;
}

.sg-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 36, 18, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 1990;
}

.sg-cart-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.sg-cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  box-shadow: 0 24px 60px rgba(63, 68, 32, 0.2);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 2000;
}

.sg-cart-sidebar.is-open {
  transform: translateX(0);
}

.sg-cart-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #e3e5db;
}

.sg-cart-sidebar__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1f2412;
}

.sg-cart-sidebar__close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #5b6051;
  font-size: 1.2rem;
  cursor: pointer;
}

.sg-cart-sidebar__close:hover,
.sg-cart-sidebar__close:focus-visible {
  background: rgba(99, 107, 47, 0.1);
  color: #636B2F;
  outline: none;
}

.sg-cart-sidebar__items {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 1.25rem;
}

.sg-cart-sidebar__footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid #e3e5db;
  background: #faf9f1;
}

.sg-cart-sidebar__footer[hidden] {
  display: none;
}

.sg-cart-sidebar__subtotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1rem;
  color: #1f2412;
}

.sg-cart-sidebar__subtotal strong {
  font-size: 1.15rem;
  color: #636B2F;
}

/* "Continue shopping" — a text link, not a third button. Hidden where the
   sidebar is a 400px drawer with the page visible beside it; shown only in
   the phone block below, where the sidebar covers the whole screen. */
.sg-cart-sidebar__continue {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 0.35rem;
  color: #636B2F;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sg-cart-sidebar__continue:hover,
.sg-cart-sidebar__continue:focus-visible {
  color: #7a8439;
  outline: none;
}

.sg-cart-sidebar__note {
  margin: 0.4rem 0 0.9rem;
  font-size: 0.8rem;
  color: #5b6051;
}

/* ---------- Cart line ---------- */
.sg-cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.9rem 0;
  border-bottom: 1px solid #eef0ea;
}

.sg-cart-item:last-child {
  border-bottom: none;
}

/* This class is on the skeleton WRAPPER; skeleton.css sizes the <img> inside it. */
.sg-cart-item__image {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: #eef0ea;
}

.sg-cart-item__body {
  min-width: 0;
}

.sg-cart-item__name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1f2412;
  overflow-wrap: anywhere;
}

.sg-cart-item__price {
  margin: 0.15rem 0 0.45rem;
  font-size: 0.82rem;
  color: #5b6051;
}

.sg-cart-item__controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sg-cart-item__total {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #636B2F;
  white-space: nowrap;
}

.sg-cart-item__remove {
  margin-left: 0.35rem;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #5b6051;
  cursor: pointer;
}

.sg-cart-item__remove:hover,
.sg-cart-item__remove:focus-visible {
  background: rgba(99, 107, 47, 0.1);
  color: #636B2F;
  outline: none;
}

.sg-qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e3e5db;
  border-radius: 8px;
  background: #FFFFFF;
  color: #1f2412;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.sg-qty-btn:hover,
.sg-qty-btn:focus-visible {
  border-color: #636B2F;
  color: #636B2F;
  outline: none;
}

.sg-qty-value {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  color: #1f2412;
}

/* ---------- Empty state ---------- */
.sg-cart-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #5b6051;
}

.sg-cart-empty .fa {
  font-size: 2.5rem;
  color: #636B2F;
  margin-bottom: 0.75rem;
}

.sg-cart-empty p {
  margin: 0 0 1.25rem;
}

/* ---------- Buttons ---------- */
.sg-cart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.sg-cart-btn + .sg-cart-btn {
  margin-top: 0.5rem;
}

.sg-cart-btn--primary {
  background: #636B2F;
  color: #FFFFFF;
  border: 1px solid #636B2F;
}

.sg-cart-btn--primary:hover,
.sg-cart-btn--primary:focus-visible {
  background: #7a8439;
  border-color: #7a8439;
  color: #FFFFFF;
  outline: none;
}

.sg-cart-empty .sg-cart-btn {
  display: inline-flex;
  width: auto;
}

.sg-cart-btn--ghost {
  background: transparent;
  color: #636B2F;
  border: 1px solid #636B2F;
}

.sg-cart-btn--ghost:hover,
.sg-cart-btn--ghost:focus-visible {
  background: rgba(99, 107, 47, 0.1);
  color: #636B2F;
  outline: none;
}

/* ---------- Toasts ---------- */
.sg-toast-container {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 2100;
  pointer-events: none;
}

.sg-toast {
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  background: #1f2412;
  color: #FFFFFF;
  font-size: 0.92rem;
  box-shadow: 0 10px 24px rgba(31, 36, 18, 0.09);
  animation: sg-toast-in 0.25s ease;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Errors are told apart by a solid background, not a left accent strip (owner
   rule: implementation/Removal of AI Generated Styling From Applications ...md).
   #c33 is the app's existing error red (local-sourcing.css, booking.css). */
.sg-toast--error {
  background: #c33;
}

.sg-toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

@keyframes sg-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 576px) {
  .sg-cart-sidebar {
    width: 100%;
  }

  /* Full-screen here, so the small close icon is not enough of a way back */
  .sg-cart-sidebar__continue {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sg-cart-sidebar,
  .sg-cart-overlay,
  .sg-toast {
    transition: none;
    animation: none;
  }
}
