/* ==========================================================================
   Food Store - 主样式（改进版）
   说明：类名全部保持不变（包括 desciption / summery 这两个拼写，
   因为 HTML/PHP 模板里用的是同样的拼写）。
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. 设计变量（颜色 / z-index / 偏移量）
   -------------------------------------------------------------------------- */
:root {
  /* 主题色：如果插件设置里定义了 --wfs-primary-color 就用它，否则用默认蓝 */
  --wfs-primary: var(--wfs-primary-color, #337ab7);

  --wfs-text: #000;
  --wfs-text-body: #474747;
  --wfs-text-muted: #6b6b6b; /* 与白底对比度 ≥ 4.5:1 */
  --wfs-border: #ececec;
  --wfs-border-soft: #f3f3f3;
  --wfs-hover-bg: #eee;
  --wfs-badge-bg: #757575; /* 白字对比度 ≥ 4.5:1 */
  --wfs-danger: #ff2121;
  --wfs-link: #1244ff;

  /* 主题如果有固定头部，在这里（或主题 CSS 里）设置它的高度 */
  --wfs-sticky-top: 0px;

  /* z-index 统一管理：fade 必须高于 sidebar，cart 高于 fade */
  --wfs-z-sidebar: 3;
  --wfs-z-fade: 5;
  --wfs-z-cart-overview: 99;
  --wfs-z-cart-expanded: 101;
  --wfs-z-cart-wrapper: 9999;
}

/* --------------------------------------------------------------------------
   1. 整体布局
   -------------------------------------------------------------------------- */
#foodstore {
  margin: 20px 0;
}

#foodstore > .fs-row {
  display: flex;
}

/* 覆盖主题容器宽度限制，这里保留 !important */
.fs-container {
  max-width: 100% !important;
}

#wfs-sticky-sidebar {
  box-sizing: border-box;
  flex: 0 0 25%;
  padding: 0 15px;
}

#wfs-food-items {
  box-sizing: border-box;
  flex: 1;
  min-width: 0; /* 防止长内容把 flex 子项撑出容器 */
  padding: 0 15px;
}

/* --------------------------------------------------------------------------
   2. 侧边分类菜单
   -------------------------------------------------------------------------- */
.wfs-sidebar-menu ul {
  padding: 0;
  margin: 0;
  list-style: none !important;
}

.wfs-sidebar-menu ul a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  color: var(--wfs-text);
  border-bottom: 1px solid var(--wfs-border);
  text-decoration: none !important;
  transition: background-color 0.2s ease;
}

.wfs-sidebar-menu ul li a:hover,
.wfs-sidebar-menu ul li a:focus-visible {
  background-color: var(--wfs-hover-bg);
}

.wfs-sidebar-menu ul li a:focus-visible {
  outline: 2px solid var(--wfs-primary);
  outline-offset: -2px;
}

.wfs-sidebar-menu ul li a.active {
  background-color: var(--wfs-hover-bg);
  font-weight: 700;
}

.wfs-sidebar-menu ul li a span.wfs-items-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  background-color: var(--wfs-badge-bg);
}

.wfs-sidebar-menu ul li a span.wfs-items-count.active {
  background-color: var(--wfs-primary);
}

/* --------------------------------------------------------------------------
   3. 店铺状态提示 / 搜索
   -------------------------------------------------------------------------- */
.wfs-store-close-msg {
  margin-bottom: 10px;
}

.wfs-store-close-msg span {
  display: block;
  padding: 10px;
  background-color: #eff5ce;
}

.wfs-search-container {
  position: relative;
  padding: 0;
  margin: 0;
}

.wfs-search-container .wfs-food-search {
  box-sizing: border-box;
  width: 100%;
  height: 45px;
  padding: 0 44px 0 15px; /* 右侧给搜索图标留位置 */
  border: 1px solid #b4b4b4;
  border-radius: 8px;
  background-color: #fff;
  color: #000;
}

.wfs-search-container .wfs-food-search:focus {
  border-color: var(--wfs-primary);
  outline: 2px solid var(--wfs-primary);
  outline-offset: 1px;
}

.wfs-search-container i.wfs-icon-search {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: #5e5d5d;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   4. 分类标题
   -------------------------------------------------------------------------- */
.wfs-category-title-container.not-in-search {
  display: none;
}

.wfs-category-title-container.in-search {
  display: block;
}

h3.wfs-category-title {
  display: block;
  margin: 5px 0 !important;
  padding: 6px 0;
  font-size: 24px;
  font-weight: 400;
  background-color: transparent;
}

.wfs-category-short-desciption {
  display: block;
  margin-top: -10px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 15px;
  color: var(--wfs-text-muted);
}

/* --------------------------------------------------------------------------
   5. 菜品列表项
   -------------------------------------------------------------------------- */
.wfs-food-item-container {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px 10px;
  border: none;
}

/* 分割线：作为 flex 子项独占一行 */
.wfs-food-item-container::after {
  content: "";
  flex: 0 0 96%;
  height: 10px;
  margin: 0 auto;
  border-bottom: 1px solid var(--wfs-border-soft);
}

.wfs-food-item-type {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  width: 13px;
  height: 13px;
  border-width: 1px;
  border-style: solid;
  background: #fff;
  text-align: center;
}

.wfs-food-item-type > div {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.wfs-food-item-type.veg {
  border-color: green;
}

.wfs-food-item-type.veg > div {
  background-color: green;
}

.wfs-food-item-type.nonveg {
  border-color: red;
}

.wfs-food-item-type.nonveg > div {
  background-color: red;
}

.wfs-food-item-image-container {
  position: relative;
  padding: 0 0 0 15px;
}

.wfs-food-item-image-container img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  cursor: pointer;
  border-radius: 6px !important;
}

.wfs-food-item-image-container .wfs-food-item-type {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 1;
}

.wfs-food-item-summery {
  flex: 2;
  padding: 0 1rem;
}

.wfs-food-item-title {
  font-size: 20px;
  font-weight: 300;
  text-decoration: none !important;
}

.wfs-food-item-description {
  font-size: 14px;
  color: var(--wfs-text-body);
  text-align: left;
}

.wfs-food-item-cart-action {
  padding-right: 15px;
}

.button-add-to-cart {
  margin-top: 10px;
}

.wfs-product-add-to-cart.disabled.variation-selection-needed {
  opacity: 0.5 !important;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   6. 购物车：底部概览栏
   -------------------------------------------------------------------------- */
.wfs-cart-wrapper {
  position: relative;
  z-index: var(--wfs-z-cart-wrapper);
}

.wfs-cart-overview {
  position: fixed;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: var(--wfs-z-cart-overview);
  box-sizing: border-box;
  width: auto;
  padding: 6px;
  background: #fff;
  box-shadow: -7px -5px 16px #00000024;
}

.wfs-cart-overview-row {
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
}

.wfs-cart-overview-description {
  width: 18%;
  padding: 7px 0;
}

.wfs-cart-overview-description p {
  font-size: 22px;
}

.wfs-cart-overview-items {
  color: #717171;
}

.wfs-cart-service-settings {
  padding: 10px 0;
  color: #000;
}

.wfs-cart-purchase-actions {
  flex: auto;
  padding: 7px 0 6px;
}

.wfs-cart-purchase-actions-mobile {
  padding: 4px;
}

.wfs-cart-purchase-actions-mobile > a {
  margin: 0 5px;
}

.wfs-cart-purchase-actions-mobile > a i {
  font-size: 26px;
}

.wfs-cart-purchase-actions-mobile .wfs-cart-subtotal {
  position: relative;
  bottom: 2px;
  font-size: 20px;
}

.wfs-cart-purchase-actions-mobile .wfs-change-service-mobile i {
  position: relative;
  top: 3px;
  font-size: 30px;
}

.wfs-cart-toggle {
  width: 5%;
  min-width: 44px; /* 保证点击区域 */
  padding: 2px 0 0;
}

.wfs-expand-cart,
.wfs-compress-cart {
  font-size: 30px;
  cursor: pointer;
}

.wfs-cart-subtotal {
  margin: 0 0.8rem;
  font-size: 1.2rem;
  font-weight: 400;
  color: rgb(28, 28, 28);
  user-select: none;
}

.wfs-cart-subtotal small {
  display: none;
}

/* --------------------------------------------------------------------------
   7. 购物车：展开面板
   -------------------------------------------------------------------------- */
.wfs-cart-expanded {
  position: fixed;
  z-index: var(--wfs-z-cart-expanded);
  width: 100%;
  height: 0;
  padding: 10px 0;
  overflow: hidden;
  background: #fff;
  opacity: 0;
  visibility: hidden; /* 收起时不可聚焦、不被读屏读取 */
  transition:
    height 0.4s ease-in-out,
    opacity 0.4s ease-in-out,
    visibility 0.4s;
}

.wfs-cart-expanded .fs-container {
  padding-left: 40px;
}

.wfs-cart-expanded.active {
  height: 400px;
  height: min(400px, 75dvh);
  opacity: 1;
  visibility: visible;
}

.wfs-cart-expanded.empty.active {
  height: 350px;
  height: min(350px, 70dvh);
}

.wfs-cart-expanded-header {
  display: flex;
  justify-content: flex-end;
  padding: 12px 12px 6px 0;
}

.wfs-cart-expanded-header-title {
  flex: 1;
  font-size: 22px;
}

.wfs-close-cart-icon {
  width: 44px;
  height: 44px;
  font-size: 18px;
  line-height: 44px;
  text-align: center;
  vertical-align: middle;
  color: #bd0000;
  cursor: pointer;
}

/* 新的 Flex 内容区 */
.wfs-cart-content-area {
  display: flex;
  justify-content: space-between;
  padding-left: 4px;
  height: 330px;
  height: min(330px, calc(75dvh - 70px));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #a7a7a7 #f5f5f5;
}

.cart-content-left {
  width: 66%;
}

.cart-content-right {
  width: 32%;
}

/* 自定义滚动条（WebKit） */
.wfs-cart-content-area::-webkit-scrollbar {
  width: 5px;
  background-color: #f5f5f5;
}

.wfs-cart-content-area::-webkit-scrollbar-track {
  background-color: #fff;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}

.wfs-cart-content-area::-webkit-scrollbar-thumb {
  background-color: #a7a7a7;
}

/* 购物车条目 */
.wfs-cart-item-container,
.wfs-cart-totals-container {
  padding: 12px;
}

.wfs-cart-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 10px 0;
  border-bottom: 1px dashed #dcdcdc;
}

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

.wfs-cart-item-left,
.wfs-cart-totals-item-left {
  flex: 1;
}

.wfs-cart-item-title {
  display: flex;
  margin-bottom: 8px;
}

.wfs-cart-item-title p {
  font-size: 18px;
  line-height: 1em;
  color: #383838;
}

.wfs-cart-item-title .wfs-food-item-type {
  margin-top: 3px;
  margin-right: 10px;
}

.wfs-cart-item-price {
  margin-right: 10px;
}

.wfs-cart-actions.wfs-cart-item-edit {
  color: var(--wfs-link);
  cursor: pointer;
}

.wfs-cart-actions.wfs-cart-item-delete {
  color: var(--wfs-danger);
  cursor: pointer;
}

.wfs-cart-addon-item,
.wfs-cart-variation-item,
.wfs-special-instruction {
  padding: 2px 1px;
  font-size: 14px;
  color: #3c3c3c;
}

.wfs-special-instruction {
  font-style: italic;
  font-weight: bold;
}

dd.variation-SpecialNote {
  font-style: italic;
}

span.wfs_order_meta {
  display: block;
  margin: 3px 0;
}

/* 合计 */
.wfs-cart-totals-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0 0;
}

.wfs-cart-totals-item.order-total {
  padding: 0;
}

.wfs-cart-totals-container hr {
  margin: 10px 0;
}

/* 空购物车 */
.wfs-empty-cart-image {
  text-align: center;
}

.wfs-empty-cart-container .wfs-empty-cart-image img {
  margin: 0 auto;
}

.wfs-empty-cart-container .wfs-empty-cart-text {
  margin: 20px;
  font-size: 20px;
  font-weight: 700;
  font-style: italic;
  text-align: center;
}

/* --------------------------------------------------------------------------
   8. 遮罩层 / 弹窗 / 错误提示
   -------------------------------------------------------------------------- */
.wfs-body-fade {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--wfs-z-fade);
  width: 100%;
  height: 100%;
  margin: 0;
  background: rgb(28, 28, 28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.wfs-body-fade.active {
  opacity: 0.3;
  visibility: visible;
  pointer-events: auto;
}

.wfs-service-modal-container select {
  display: block;
  clear: both;
  width: 100%;
  height: 41px;
  margin-top: 8px;
  margin-bottom: 9px;
  padding: 10px;
}

.wfsmodal .nav-link {
  cursor: pointer;
}

.foodstore_service_error {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  background-color: #fb5757;
  color: #fff;
}

.foodstore_service_error.inactive {
  display: none;
}

/* --------------------------------------------------------------------------
   9. 规格 / 加料
   -------------------------------------------------------------------------- */
.wfs-pricing-option-label,
.wfs-addon-category-title,
.wfs-special-note-label {
  margin: 0;
  padding: 6px 0;
  font-size: 18px;
  font-weight: 600;
  color: #000;
}

.wfs-item-addons-container {
  margin-bottom: 5px;
}

.wfs-addon-category {
  margin: 4px 0;
}

.wfs-addon-category label {
  display: inline-block !important;
}

.wfs-addon-category span {
  color: #000;
}

.wfs-addon-category input {
  margin-right: 5px;
}

.wfs-addon-category > span {
  float: right;
}

/* --------------------------------------------------------------------------
   10. 多列菜品列表
   -------------------------------------------------------------------------- */
.fs-2-columns {
  padding: 0;
}

/* 两个 class 的特异性已高于 .wfs-food-item-container，无需 !important */
.fs-2-columns .wfs-food-item-container {
  margin-right: 0;
  margin-left: 0;
}

/* --------------------------------------------------------------------------
   11. Mini Cart（侧边抽屉）
   用 transform 控制显隐：任何屏幕宽度下都会露出 40px 的把手区域
   -------------------------------------------------------------------------- */
.wfs-cart-wrapper.mini-cart {
  position: fixed;
  top: 50%;
  right: 0;
  z-index: var(--wfs-z-cart-wrapper);
  width: min(460px, 100vw);
  margin: 0;
  padding-left: 40px;
  transform: translate(calc(100% - 40px), -50%);
  transition: transform 0.4s ease;
}

.wfs-cart-wrapper.mini-cart.active {
  transform: translate(0, -50%);
}

.wfs-mini-cart-icon {
  position: absolute;
  top: 0;
  left: -30px;
  min-width: 70px;
  max-height: 65px;
  padding: 20px;
  border-radius: 9px 0 0 9px;
  background: #000;
  color: #fff;
  font-weight: bold;
  text-align: center;
}

.wfs-mini-cart-icon:hover {
  background: #000;
  color: #fff;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-content-area {
  display: block;
}

.wfs-cart-wrapper.mini-cart .cart-content-left {
  width: 97%;
}

.wfs-cart-wrapper.mini-cart .cart-content-right {
  width: 100%;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-expanded {
  width: 95%;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-expanded.active {
  /* 横屏手机上设置下限，避免高度变成 0 */
  height: max(220px, calc(100vh - 400px));
  height: max(220px, calc(100dvh - 400px));
  border: 1px solid var(--wfs-border);
  overflow: auto;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-totals-container {
  padding: 10px 0;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-overview {
  position: relative;
  right: auto;
  left: auto;
  bottom: -11px;
  width: auto;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-service-settings {
  width: 100%;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-overview-row {
  display: block;
}

.wfs-cart-wrapper.mini-cart .fs-container {
  padding-left: 20px;
}

.wfs-cart-wrapper.mini-cart .wfs-cart-subtotal {
  margin-left: 0;
}

/* --------------------------------------------------------------------------
   12. 营业状态短代码
   -------------------------------------------------------------------------- */
.foodstore-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.4;
}

.foodstore-status .foodstore-status-indicator {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.foodstore-status .foodstore-status-text {
  font-weight: 500;
}

/* 营业中（两套类名并存，兼容旧版本） */
.foodstore-status.status-open,
.foodstore-status.foodstore-status-open {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.foodstore-status.status-open .foodstore-status-indicator,
.foodstore-status.foodstore-status-open .foodstore-status-indicator {
  background-color: #2e7d32;
}

/* 仅接受预订 */
.foodstore-status.status-preorder,
.foodstore-status.foodstore-status-preorder {
  background-color: #fff8e1;
  color: #b76e00;
  border: 1px solid #ffe082;
}

.foodstore-status.status-preorder .foodstore-status-indicator,
.foodstore-status.foodstore-status-preorder .foodstore-status-indicator {
  background-color: #f57f17;
}

/* 已打烊 */
.foodstore-status.status-closed,
.foodstore-status.foodstore-status-closed {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

.foodstore-status.status-closed .foodstore-status-indicator,
.foodstore-status.foodstore-status-closed .foodstore-status-indicator {
  background-color: #c62828;
}

/* --------------------------------------------------------------------------
   13. 减少动态效果（系统开启“减少动态效果”时关闭动画）
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .wfs-cart-expanded,
  .wfs-body-fade,
  .wfs-cart-wrapper.mini-cart,
  .wfs-sidebar-menu ul a {
    transition: none;
  }
}
