/* ======================================================
   Location: assets/css/header-cart.css
   Purpose:
   - Header cart icon + compact dropdown widget styling.
   - Same visual system for desktop, tablet, and mobile.
   - Reduced panel height with scrollable product list.
====================================================== */

.stm-cart{
  position: relative;
  display: inline-flex;
  align-items: center;
}

.stm-cart__toggle{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid #d9dee8;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.stm-cart__toggle:hover,
.stm-cart.is-open .stm-cart__toggle{
  border-color: #bcc5d3;
  background: #fff;
}

.stm-cart__toggle:focus-visible{
  outline: 2px solid #ff8a00;
  outline-offset: 2px;
}

.stm-cart__toggle:active{
  transform: translateY(1px);
}

.stm-cart__icon{
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111827;
  flex: 0 0 auto;
}

.stm-cart__icon svg{
  width: 20px !important;
  height: 20px !important;
  display: block;
  fill: currentColor;
}

.stm-cart__total{
  display: inline-flex;
  align-items: center;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.stm-cart__badge{
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #1db954;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.stm-cart:not(.is-active) .stm-cart__badge{
  background: #111827;
}

.stm-cart__panel{
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 352px;
  max-width: calc(100vw - 24px);
  max-height: min(390px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d7dbe2;
  border-radius: 16px;
  box-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .16s ease, visibility .16s ease, transform .16s ease;
  z-index: 9999;
  overflow: hidden;
}

.stm-cart.is-open .stm-cart__panel{
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.stm-cart__panel[hidden]{
  display: none !important;
}

.stm-cart__panel-arrow{
  position: absolute;
  top: -8px;
  right: 26px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-top: 1px solid #d7dbe2;
  border-left: 1px solid #d7dbe2;
  transform: rotate(45deg);
}

.stm-cart__head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 10px;
  border-bottom: 1px solid #eef0f4;
  background: #fff;
  flex: 0 0 auto;
}

.stm-cart__head-main{
  min-width: 0;
  display: grid;
  gap: 2px;
}

.stm-cart__title{
  display: block;
  color: #111827;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.stm-cart__count{
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.stm-cart__clear-link{
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ef4444;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: color .14s ease, opacity .14s ease;
}

.stm-cart__clear-link:hover,
.stm-cart__clear-link:focus-visible{
  color: #dc2626;
  text-decoration: underline;
  outline: none;
}

.stm-cart__clear-link:disabled{
  opacity: .45;
  cursor: not-allowed;
  text-decoration: none;
}

.stm-cart__body{
  min-height: 0;
  padding: 9px 9px 0;
  background: #fff;
  flex: 1 1 auto;
}

.stm-cart__empty{
  padding: 18px 10px 20px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.stm-cart__list{
  list-style: none;
  margin: 0;
  padding: 0 5px 0 0;
  display: grid;
  gap: 8px;
  max-height: 216px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.stm-cart__list::-webkit-scrollbar{
  width: 7px;
}

.stm-cart__list::-webkit-scrollbar-track{
  background: transparent;
}

.stm-cart__list::-webkit-scrollbar-thumb{
  background: #c7ccd5;
  border: 2px solid #fff;
  border-radius: 999px;
}

.stm-cart__list::-webkit-scrollbar-thumb:hover{
  background: #9ca3af;
}

.stm-cart__item{
  min-height: 70px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 28px;
  gap: 9px;
  align-items: start;
  padding: 8px;
  border: 1px solid #d9dde5;
  border-radius: 13px;
  background: #fff;
}

.stm-cart__thumb{
  width: 52px;
  height: 52px;
  display: block;
  overflow: hidden;
  border: 1px solid #e6e9ef;
  border-radius: 9px;
  background: #fff;
}

.stm-cart__thumb img{
  width: 52px !important;
  height: 52px !important;
  display: block;
  object-fit: contain !important;
  object-position: center;
}

.stm-cart__meta{
  min-width: 0;
  padding-top: 1px;
}

.stm-cart__name{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.28;
  text-decoration: none;
}

.stm-cart__name:hover{
  text-decoration: underline;
}

.stm-cart__line{
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stm-cart__qty{
  color: #2563eb;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.stm-cart__lineTotal{
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.stm-cart__remove{
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #f3b6b6;
  border-radius: 999px;
  background: #fff5f5;
  color: #ef4444;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .14s ease;
}

.stm-cart__remove:hover,
.stm-cart__remove:focus-visible{
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  outline: none;
}

.stm-cart__remove:active{
  transform: translateY(1px);
}

.stm-cart__remove:disabled{
  opacity: .6;
  cursor: not-allowed;
}

.stm-cart__foot{
  padding: 10px 14px 13px;
  background: #fff;
  flex: 0 0 auto;
}

.stm-cart__subtotal{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 9px;
  border-top: 1px solid #d9dde5;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.stm-cart__subtotal strong{
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
}

.stm-cart__actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stm-cart__btn{
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .14s ease;
}

.stm-cart__btn--ghost{
  background: #fff;
  border-color: #cfd5de;
  color: #1f2937;
}

.stm-cart__btn--ghost:hover,
.stm-cart__btn--ghost:focus-visible{
  background: #f8fafc;
  border-color: #bfc8d4;
  color: #1f2937;
  outline: none;
  text-decoration: none;
}

.stm-cart__btn--primary{
  background: #ff7a00;
  border-color: #ff7a00;
  color: #fff;
}

.stm-cart__btn--primary:hover,
.stm-cart__btn--primary:focus-visible{
  background: #eb6f00;
  border-color: #eb6f00;
  color: #fff;
  outline: none;
  text-decoration: none;
}

.stm-cart__btn:active{
  transform: translateY(1px);
}

.stm-cart__clear{
  display: none !important;
}

.stm-cart.is-empty .stm-cart__foot{
  display: none;
}

@media (max-width: 1023px){
  .stm-cart__panel{
    position: fixed;
    top: calc(78px + env(safe-area-inset-top, 0px));
    left: 50%;
    right: auto;
    width: min(352px, calc(100vw - 18px));
    max-height: calc(100vh - 102px - env(safe-area-inset-top, 0px));
    transform: translate(-50%, 8px);
  }

  .stm-cart.is-open .stm-cart__panel{
    transform: translate(-50%, 0);
  }

  .stm-cart__panel-arrow{
    right: 50%;
    margin-right: -8px;
  }
}

@media (max-width: 640px){
  .stm-cart__total{
    display: none;
  }

  .stm-cart__panel{
    width: min(352px, calc(100vw - 14px));
    max-height: calc(100vh - 96px - env(safe-area-inset-top, 0px));
  }

  .stm-cart__head{
    padding: 12px 13px 9px;
  }

  .stm-cart__body{
    padding: 8px 8px 0;
  }

  .stm-cart__foot{
    padding: 9px 13px 12px;
  }
}

@media (prefers-reduced-motion: reduce){
  .stm-cart__panel,
  .stm-cart__toggle,
  .stm-cart__btn,
  .stm-cart__clear-link,
  .stm-cart__remove{
    transition: none !important;
  }
}

/* ======================================================
   Tablet/mobile action-size sync
   - Cart button follows the same size as the mobile location action button.
   - Desktop cart total button remains unchanged.
====================================================== */
@media (max-width: 1023px){
  .stm-header .stm-cart,
  .stm-cart{
    flex: 0 0 var(--stm-header-action-size-responsive, 38px) !important;
  }

  .stm-header .stm-cart__toggle,
  .stm-cart__toggle{
    width: var(--stm-header-action-size-responsive, 38px) !important;
    min-width: var(--stm-header-action-size-responsive, 38px) !important;
    max-width: var(--stm-header-action-size-responsive, 38px) !important;
    height: var(--stm-header-action-size-responsive, 38px) !important;
    min-height: var(--stm-header-action-size-responsive, 38px) !important;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 10px !important;
    flex: 0 0 var(--stm-header-action-size-responsive, 38px) !important;
  }

  .stm-header .stm-cart__icon,
  .stm-header .stm-cart__icon svg,
  .stm-cart__icon,
  .stm-cart__icon svg{
    width: var(--stm-header-action-icon-responsive, 18px) !important;
    height: var(--stm-header-action-icon-responsive, 18px) !important;
    flex: 0 0 var(--stm-header-action-icon-responsive, 18px) !important;
  }

  .stm-header .stm-cart__total,
  .stm-cart__total{
    display: none !important;
  }
}
