/**
 * Mobile buy bar (new / new a) — ไฟล์แยกเฉพาะ
 * โหลดจาก head.php · ไม่พึ่งกฎใน main.css
 * PC กว้าง (>=900px): ซ่อนทั้งหมด
 */

.mobile-buybar {
  display: none;
}

@media (max-width: 899px) {
  .mobile-buybar {
    --buybar-cta-h: 48px;
    --buybar-icon-col: 52px;
    --buybar-gap: 6px;
    --buybar-pad-x: 8px;
    --buybar-pad-y: 8px;
    --buybar-nav-h: calc(var(--buybar-cta-h) + (var(--buybar-pad-y) * 2));
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 -10px 28px rgba(8, 22, 47, 0.1);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-sizing: border-box;
  }

  /* ใช้คลาสจาก JS — ไม่พึ่ง :has() */
  html.has-mobile-buybar .glass-preview-bar,
  body.has-mobile-buybar .glass-preview-bar {
    display: none !important;
  }
  html.has-mobile-buybar body,
  body.has-mobile-buybar {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.page-product-view .pdp-actions {
    display: none !important;
  }

  .mobile-buybar__nav {
    display: grid;
    grid-template-columns: var(--buybar-icon-col) var(--buybar-icon-col) minmax(0, 1fr) minmax(0, 1.28fr);
    gap: var(--buybar-gap);
    align-items: center;
    height: var(--buybar-nav-h);
    padding: var(--buybar-pad-y) var(--buybar-pad-x);
    box-sizing: border-box;
  }

  .mobile-buybar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    height: var(--buybar-cta-h);
    margin: 0;
    padding: 0;
    text-decoration: none;
    color: #0a1f44;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-buybar__item.is-disabled {
    opacity: 0.45;
    pointer-events: none;
  }

  .mobile-buybar__item--shop,
  .mobile-buybar__item--chat {
    width: 100%;
  }

  .mobile-buybar__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 17px;
    line-height: 1;
    color: #0a1f44;
  }

  .mobile-buybar__icon i {
    line-height: 1;
  }

  .mobile-buybar__label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.1;
  }

  .mobile-buybar__cta {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: var(--buybar-cta-h);
    min-height: var(--buybar-cta-h);
    max-height: var(--buybar-cta-h);
    border-radius: 10px;
    padding: 0 8px;
    overflow: hidden;
    box-sizing: border-box;
  }

  .mobile-buybar__cta--info {
    background: linear-gradient(180deg, #f0e6d4 0%, #dcc7a4 100%);
    border: 1px solid rgba(184, 154, 100, 0.55);
    color: #3d3222;
  }

  .mobile-buybar__cta--info .mobile-buybar__cta-text {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
  }

  .mobile-buybar__cta--cart {
    background: linear-gradient(180deg, #142a52 0%, #0a1f44 100%);
    border: 1px solid rgba(184, 154, 100, 0.45);
    color: #fff;
    padding: 0;
  }

  .mobile-buybar__cta--cart .pdp-buy-form,
  .mobile-buybar__cta--cart form {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
  }

  .mobile-buybar__cta--cart .pdp-buy-btn,
  .mobile-buybar__cta--cart .button-primary,
  .mobile-buybar__cta--cart a.pdp-buy-btn,
  .mobile-buybar__cta--cart .mobile-buybar__cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-buybar__cta--cart a.pdp-buy-btn {
    background: linear-gradient(180deg, #3a4f78 0%, #243a5e 100%);
  }

  /* new a — sheet */
  .mobile-buybar-sheet {
    position: relative;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    box-sizing: border-box;
  }

  .mobile-buybar-sheet__toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 10px 48px 8px;
    border: 0;
    background: transparent;
    color: #0a1f44;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-buybar-sheet__toggle-label {
    white-space: nowrap;
  }

  .mobile-buybar-sheet__notch {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 22px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 10px rgba(8, 22, 47, 0.06);
    color: #8f7a52;
    font-size: 14px;
    line-height: 1;
    padding-bottom: 2px;
    box-sizing: border-box;
  }

  .mobile-buybar-sheet__panel {
    padding: 4px 14px 14px;
    max-height: min(58vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .mobile-buybar-sheet__head {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
  }

  .mobile-buybar-sheet__media {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    background: #f3f1ec;
  }

  .mobile-buybar-sheet__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .mobile-buybar-sheet__name {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 800;
    color: #0a1f44;
    line-height: 1.3;
  }

  .mobile-buybar-sheet__price {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #8f7a52;
    line-height: 1.25;
  }

  .mobile-buybar-sheet__price s {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #98a2b3;
  }

  .mobile-buybar-sheet__price em {
    margin-left: 4px;
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
    color: #a07848;
  }

  .mobile-buybar-sheet__deal {
    margin: 4px 0 0;
    font-size: 12px;
    color: #9c8b6a;
    font-weight: 600;
    line-height: 1.3;
  }

  .mobile-buybar-sheet__variants {
    margin-bottom: 8px;
  }

  .mobile-buybar-sheet .pdp-offers__list {
    display: grid;
    gap: 6px;
  }
}

/* LINE → ใช้ assets/css/mobile-buybar-line.css + partials/mobile-buybar-line.php */
