/**
 * Mobile buy bar (new / new a) — ไฟล์แยกเฉพาะ
 * โหลดจาก head.php · ไม่พึ่งกฎใน main.css
 * ≤899px: แถบล่างเต็มจอ
 * ≥900px + landing (new a): of ลอยขวา + new ต่อท้าย · PDP ยังซ่อน
 */

.mobile-buybar {
  display: none;
}

.pdp-buy-btn--shopee--pc-only { 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;
  }

  /* ราคา = .pdp-mini-buy__price (product-view) */
  .mobile-buybar-sheet__price,
  .mobile-buybar-sheet__price.pdp-mini-buy__price {
    margin: 0.15rem 0 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: #b91c1c;
    line-height: 1.25;
  }

  .mobile-buybar-sheet__price s {
    margin-left: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #8b93a3;
  }

  .mobile-buybar-sheet__price em {
    margin-left: 0.35rem;
    font-style: normal;
    font-size: 0.8rem;
    font-weight: 800;
    color: #b91c1c;
  }

  .mobile-buybar-sheet .pdp-offers__list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  .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;
  }

}


/* หน้า landing ไม่โหลด pdp.css — ซ่อนปุ่มดูตะกร้า/Shopee แบบ PC บนจอแคบ (เหลือ FAB ส้ม) */
.mobile-buybar--landing > .pdp-buy-btn--cart--pc-only,
.mobile-buybar--landing > .pdp-buy-btn--shopee--pc-only {
  display: none !important;
}

/* PC กว้าง — landing ?buybar=1 เท่านั้น (ไม่แตะเลย์เอาต์แคบ) */
@media (min-width: 900px) {
  .mobile-buybar--pdp {
    display: none !important;
  }

  /* PC landing float = .pdp-mini-buy look (รูปที่ 2) */
  .mobile-buybar--landing {
    --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));
    --buybar-of-w: min(22rem, calc(100vw - 2rem));
    --buybar-mr: 1rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    position: fixed;
    top: 50%;
    right: var(--buybar-mr);
    left: auto;
    bottom: auto;
    width: var(--buybar-of-w);
    max-height: calc(100vh - 2rem);
    z-index: 70;
    padding: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(8, 22, 47, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-sizing: border-box;
    transform: translateY(-50%);
  }

  .mobile-buybar--landing .mobile-buybar-sheet {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .mobile-buybar--landing .mobile-buybar__nav {
    grid-column: 1;
    grid-row: 2;
  }

  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only {
    grid-column: 2;
    grid-row: 2;
  }

  .mobile-buybar--landing > .pdp-buy-btn--shopee--pc-only {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  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: 0;
  }

  .mobile-buybar--landing .mobile-buybar-sheet {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  }

    /* PC landing = .pdp-mini-buy card (รูปที่ 2) — ไม่แตะเลย์เอาต์มือถือ ≤899 */
  .mobile-buybar--landing .mobile-buybar-sheet__toggle {
    display: none !important;
  }

  .mobile-buybar--landing .mobile-buybar-sheet__panel,
  .mobile-buybar--landing .mobile-buybar-sheet__panel[hidden] {
    display: block !important;
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(58vh, 32rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.85rem 0.9rem 0.55rem;
  }

  /* ซ่อนแถบมือถือ: ร้านค้า / แชท / ย้อนกลับ */
  .mobile-buybar--landing .mobile-buybar__item--shop,
  .mobile-buybar--landing .mobile-buybar__item--chat,
  .mobile-buybar--landing .mobile-buybar__cta--info {
    display: none !important;
  }

  .mobile-buybar--landing .mobile-buybar__nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: stretch;
    height: auto;
    margin: 0;
    padding: 0.55rem 0.35rem 0.55rem 0.85rem;
    box-sizing: border-box;
    width: auto;
    min-width: 0;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
  }

  .mobile-buybar--landing .mobile-buybar__cta--cart {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 46px;
    max-height: none;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #0a1f44 0%, #173863 100%);
    border: 0;
    color: #fff;
  }

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

  .mobile-buybar--landing .mobile-buybar__cta--cart .pdp-buy-btn,
  .mobile-buybar--landing .mobile-buybar__cta--cart .button-primary,
  .mobile-buybar--landing .mobile-buybar__cta--cart a.pdp-buy-btn,
  .mobile-buybar--landing .mobile-buybar__cta--cart .mobile-buybar__cart-btn {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 0.55rem 0.85rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.15;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
  }

  /* ปุ่มดูตะกร้าส้ม + Shopee — แถวเดียว ไอคอน|ข้อความ|เลข */
  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only,
  .mobile-buybar--landing > .pdp-buy-btn--shopee--pc-only {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex: 0 0 auto;
    width: auto;
    min-height: 46px;
    margin: 0.55rem 0.85rem 0.55rem 0;
    padding: 0.55rem 0.9rem;
    border-radius: 12px !important;
    white-space: nowrap !important;
    align-self: center;
  }

  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 100%) !important;
    color: #fff !important;
  }

  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only .pdp-buy-btn--cart__icon,
  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only .icon {
    width: 1.15rem !important;
    height: 1.15rem !important;
    display: inline-block !important;
    flex: 0 0 auto !important;
  }

  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only .pdp-buy-btn--cart__text {
    display: inline !important;
    white-space: nowrap !important;
  }

  .mobile-buybar--landing > .pdp-buy-btn--cart--pc-only .pdp-buy-btn--cart__qty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #fff;
    color: #ea580c;
    font-size: 0.78rem;
    font-weight: 800;
  }

  .mobile-buybar--landing > .pdp-buy-btn--shopee--pc-only {
    width: auto;
    margin: 0 0.85rem 0.85rem;
    background: linear-gradient(135deg, #ee4d2d 0%, #f1582c 100%) !important;
    color: #fff !important;
  }

  .mobile-buybar--landing > .pdp-buy-btn--shopee--pc-only .pdp-buy-btn--shopee__icon {
    display: inline-flex;
    flex: 0 0 auto;
  }
}


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