/* ================================================================
   ตั๋วคูปองแบบ Shopee — ใช้ร่วมกันทุกที่ (ตะกร้า, หน้าโค้ดส่วนลด, ป๊อปอัปคูปอง)
   โหลดจาก views/coupons/popup.php (อยู่ใน footer ทุกหน้า) HTML สร้างโดย CouponTicket.html()
   โครงสร้าง:
     <div class="coupon-chip [wide] [applied|is-off]" style="--cc:#RRGGBB">
       <div class="coupon-icon"><i></i><span>ชื่อไอคอน</span></div>   แถบสี ขอบปรุ
       <div class="coupon-body">
         <div class="coupon-badges">..</div>        (ไม่บังคับ)
         <div class="coupon-amount">ส่วนลด ฿10</div>
         <div class="coupon-min">ขั้นต่ำ ฿50</div>
         <span class="coupon-name">ชื่อคูปอง</span>  (ไม่บังคับ)
         <div class="coupon-expiry">ใช้ได้ถึง ..</div>
       </div>
       <div class="coupon-act"><button class="coupon-action">เก็บ</button></div>
       <span class="coupon-stamp">หมดอายุ</span>     (ไม่บังคับ)
     </div>
   ================================================================ */

.coupon-chip {
    --cc: #d35b3a;          /* สีแถบหน้า (ตั้งต่อคูปองได้) */
    --btn: #d35b3a;         /* สีปุ่ม/กรอบชื่อ */
    --scallop: 4px;
    position: relative;
    display: flex;
    align-items: stretch;
    width: 300px;
    min-height: 104px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-left: 0;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.coupon-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
}

/* แถบซ้าย: สีของคูปอง + ขอบซ้ายปรุครึ่งวงกลม */
.coupon-chip .coupon-icon {
    flex: 0 0 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 55%),
        var(--cc);
    color: #fff;
    text-align: center;
    -webkit-mask: radial-gradient(circle at 0 50%, transparent var(--scallop), #000 calc(var(--scallop) + 0.5px)) 0 0 / 100% 11px repeat-y;
    mask: radial-gradient(circle at 0 50%, transparent var(--scallop), #000 calc(var(--scallop) + 0.5px)) 0 0 / 100% 11px repeat-y;
}

.coupon-chip .coupon-icon i {
    font-size: 30px;
    line-height: 1;
}

.coupon-chip .coupon-icon span {
    font-size: 12px;
    line-height: 1.2;
}

/* กลาง: ข้อมูลคูปองบนพื้นขาว */
.coupon-chip .coupon-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 10px 6px 10px 14px;
    cursor: pointer;
}

.coupon-chip .coupon-amount {
    font-size: 17px;
    font-weight: 800;
    color: #222;
    line-height: 1.2;
}

.coupon-chip .coupon-min {
    font-size: 13px;
    color: #757575;
    line-height: 1.3;
}

/* กรอบชื่อคูปอง (แบบป้าย "ลูกค้าใหม่") */
.coupon-chip .coupon-name {
    align-self: flex-start;
    max-width: 100%;
    margin: 3px 0 1px;
    padding: 0 6px;
    overflow: hidden;
    border: 1px solid var(--btn);
    border-radius: 3px;
    color: var(--btn);
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.coupon-chip .coupon-expiry {
    font-size: 11px;
    color: #9e9e9e;
    line-height: 1.4;
}

.coupon-chip .coupon-expiry b {
    color: #e53935;
    font-weight: 600;
}

.coupon-chip .coupon-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 2px;
}

.coupon-chip .coupon-member {
    padding: 0 6px;
    border-radius: 999px;
    background: #fff3e0;
    color: #e65100;
    font-size: 10px;
    font-weight: 600;
    line-height: 17px;
}

/* ขวา: ปุ่มมน */
.coupon-chip .coupon-act {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: 0 12px 0 4px;
}

.coupon-chip .coupon-action {
    min-width: 64px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 4px;
    background: var(--btn);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 32px;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.2s;
}

.coupon-chip .coupon-action:hover {
    filter: brightness(0.92);
}

.coupon-chip .coupon-action:disabled {
    background: #d6d6d6;
    color: #fff;
    cursor: default;
    filter: none;
}

/* กำลังใช้อยู่ */
.coupon-chip.applied {
    border-color: #43a047;
}

.coupon-chip.applied .coupon-action {
    background: #43a047;
}

/* ใช้แล้ว / หมดอายุ / สิทธิ์เต็ม — เทา + ตราประทับ */
.coupon-chip.is-off:hover {
    transform: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.coupon-chip.is-off .coupon-icon {
    background: #bdbdbd;
}

.coupon-chip.is-off .coupon-body {
    cursor: default;
}

.coupon-chip.is-off .coupon-amount,
.coupon-chip.is-off .coupon-min,
.coupon-chip.is-off .coupon-expiry {
    color: #b0b0b0;
}

.coupon-chip.is-off .coupon-name {
    border-color: #c4c4c4;
    color: #b0b0b0;
}

.coupon-chip .coupon-stamp {
    position: absolute;
    top: 50%;
    right: 92px;
    padding: 1px 8px;
    border: 2px solid #b0b0b0;
    border-radius: 6px;
    color: #b0b0b0;
    font-size: 13px;
    font-weight: 700;
    transform: translateY(-50%) rotate(-12deg);
    pointer-events: none;
}

/* แบบเต็มความกว้าง (หน้าโค้ดส่วนลด / ป๊อปอัป / ตะกร้า) */
.coupon-chip.wide {
    width: 100%;
    max-width: 420px;
    margin-bottom: 12px;
}

/* ป๊อปอัป: เลือกใบนี้แล้ว */
.coupon-chip.picked {
    border-color: var(--btn);
    box-shadow: 0 0 0 2px var(--btn);
}

/* จอเล็กมาก: ย่อแถบซ้าย */
@media (max-width: 360px) {
    .coupon-chip .coupon-icon {
        flex-basis: 80px;
    }

    .coupon-chip .coupon-icon i {
        font-size: 26px;
    }
}

/* ================================================================
   แถบเลื่อนคูปองแนวนอนแบบ Shopee — ปัดนิ้วได้ + ปุ่มลูกศร (CouponTicket.slider)
   ================================================================ */
.coupon-slider {
    position: relative;
    margin-bottom: 8px;
}

.coupon-slider .cs-track {
    display: flex;
    gap: 12px;
    padding: 6px 2px 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.coupon-slider .cs-track::-webkit-scrollbar {
    display: none;
}

/* มือถือ: ใบละ 88% ให้ใบถัดไปโผล่ / จอกว้าง: ใบละไม่เกิน 360px */
.coupon-slider .cs-track > .coupon-chip.wide {
    flex: 0 0 88%;
    max-width: 360px;
    margin-bottom: 0;
    scroll-snap-align: start;
}

.coupon-slider .cs-track > .coupon-chip.wide:only-child {
    flex-basis: 100%;
}

.coupon-slider .cs-arrow {
    position: absolute;
    top: calc(50% - 8px);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    color: #333;
    font-size: 22px;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

/* ยื่นออกนอกขอบตั๋วให้ไม่บังตัวหนังสือ (หน้าที่ใช้มี padding ด้านข้าง ≥ 14px) */
.coupon-slider .cs-prev { left: -14px; }
.coupon-slider .cs-next { right: -14px; }

.coupon-slider .cs-arrow[hidden] {
    display: none;
}

.coupon-slider .cs-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
}

.coupon-slider .cs-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #d9d9d9;
    transition: width .2s, background .2s;
}

.coupon-slider .cs-dots span.on {
    width: 16px;
    border-radius: 3px;
    background: #d35b3a;
}

/* ตั๋วในแถบเลื่อน (พื้นที่แคบ เช่นคอลัมน์ตะกร้า) — ย่อแถบซ้าย/ปุ่ม ให้ยอดส่วนลดอยู่บรรทัดเดียว */
.coupon-slider .coupon-chip .coupon-icon {
    flex-basis: 78px;
}

.coupon-slider .coupon-chip .coupon-icon i {
    font-size: 26px;
}

.coupon-slider .coupon-chip .coupon-body {
    padding: 8px 4px 8px 10px;
}

.coupon-slider .coupon-chip .coupon-amount {
    font-size: 16px;
    white-space: nowrap;
}

.coupon-slider .coupon-chip .coupon-expiry {
    white-space: nowrap;
}

.coupon-slider .coupon-chip .coupon-act {
    padding: 0 10px 0 2px;
}

.coupon-slider .coupon-chip .coupon-action {
    min-width: 52px;
    padding: 0 10px;
}
