/*
 * NarinElectric – WC Tiered Pricing Frontend Styles
 *
 * หลักการ:
 *   - ไม่กำหนด font-family / font-size (inherit จาก theme)
 *   - ไม่กำหนดขอบ outer container (ดูสะอาด กลมกลืนกับ layout เว็บ)
 *   - ใช้สี accent จาก NarinElectric: #111 (header) / #3a9900 (green)
 *   - ทุก width เป็น 100% / auto ตามกรอบที่วาง
 */

/* ── Volume Price Table ──────────────────────────────────────────────────── */

.wctp-volume-table {
    margin: 16px 0;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* Header bar — NarinElectric black */
.wctp-vol-title {
    margin: 0;
    padding: 8px 14px;
    font-weight: 700;
    background: #111;
    color: #fff;
}

/* Table */
.wctp-vol-tbl {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    table-layout: auto;
}

/* Column header row — dark gray */
.wctp-vol-tbl thead tr {
    background: #2a2a2a;
    color: #fff;
}

.wctp-vol-tbl thead th {
    padding: 7px 14px;
    font-weight: 600;
    text-align: left;
    border: none;
    color: #fff;
}

.wctp-vol-tbl thead th:nth-child(2),
.wctp-vol-tbl thead th:nth-child(3) {
    text-align: right;
}

/* Body rows */
.wctp-vol-tbl tbody tr {
    border-bottom: 1px solid #eee;
    transition: background 0.12s;
}

.wctp-vol-tbl tbody tr:last-child {
    border-bottom: none;
}

.wctp-vol-tbl td {
    padding: 10px 14px;
    vertical-align: middle;
    border: none;
}

.wctp-vol-tbl td:nth-child(2),
.wctp-vol-tbl td:nth-child(3) {
    text-align: right;
}

/* แถวปลีก — ราคาสีเทา (ยังไม่ถึง tier) */
.wctp-vol-retail td:nth-child(2) {
    opacity: 0.55;
}

/* แถว A */
.wctp-vol-highlight {
    background: #f5fcf0;
}

/* แถว B */
.wctp-vol-highlight-2 {
    background: #edf7e5;
}

/* ราคา A / B — เขียว NarinElectric */
.wctp-vol-highlight td:nth-child(2) strong,
.wctp-vol-highlight-2 td:nth-child(2) strong {
    color: #3a9900;
}

/* sub-label "ราคา A" / "ราคา B" */
.wctp-price-label {
    display: block;
    font-size: 0.75em;
    color: #3a9900;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 1px;
}

/* ส่วนลด % */
.wctp-discount {
    color: #3a9900 !important;
    font-weight: 700;
    white-space: nowrap;
}

/* ── Clickable rows ──────────────────────────────────────────────────────── */

.wctp-row-clickable {
    cursor: pointer;
    user-select: none;
}

.wctp-row-clickable:hover {
    filter: brightness(0.95);
}

/* Active / selected row — กรอบเขียว + เครื่องหมาย ✓ */
.wctp-row-active {
    outline: 2px solid #3a9900 !important;
    outline-offset: -2px;
}

.wctp-row-active td:first-child::before {
    content: '✓ ';
    color: #3a9900;
    font-weight: 700;
}

/* ── [wctp_price] Shortcode — Price Badge ────────────────────────────────── */
/* แสดง: ราคาขีดค่า  ราคาลด  % ส่วนลด  หน่วย                                */

.wctp-price-badge {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 5px;
}

/* ราคาปกติ (ขีดค่า) */
.wctp-pb-regular {
    color: #999;
    font-size: 0.9em;
    text-decoration: line-through;
    font-weight: 400;
}

/* ราคาลด / ราคาที่ใช้จริง */
.wctp-pb-sale {
    font-weight: 700;
    color: #111;
}

/* % ส่วนลด badge */
.wctp-pb-discount {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    font-size: 0.78em;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    line-height: 1.6;
    vertical-align: middle;
}

/* หน่วย (เช่น / ดวง, / ชิ้น) */
.wctp-pb-unit {
    color: #777;
    font-size: 0.88em;
    font-weight: 400;
}

/* ── Badges (cart item / shop loop) ─────────────────────────────────────── */

.wctp-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.78em;
    font-weight: 700;
    vertical-align: middle;
    line-height: 1.6;
    margin-left: 4px;
}

.wctp-badge-a    { background: #f5a623; color: #fff; }
.wctp-badge-b    { background: #3a9900; color: #fff; }
.wctp-badge-ws   { background: #3a9900; color: #fff; }
.wctp-badge-tech { background: #111;    color: #fff; }

.wctp-badge-vol {
    background: #e6f5d8;
    color: #2a7000;
    border: 1px solid #b0d990;
}

.wctp-badge-vol-hint {
    display: inline-block;
    font-size: 0.78em;
    color: #3a9900;
    font-weight: 700;
    margin-top: 3px;
}

/* ── Role Notices ────────────────────────────────────────────────────────── */

.wctp-ws-notice,
.wctp-tech-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 12px 0;
    border-radius: 0 4px 4px 0;
    width: 100%;
    box-sizing: border-box;
}

.wctp-ws-notice {
    background: #f5fcf0;
    border-left: 4px solid #3a9900;
    color: #1a4d00;
}

.wctp-tech-notice {
    background: #f5f5f5;
    border-left: 4px solid #111;
    color: #111;
}

/* ── Checkout MOQ Block ──────────────────────────────────────────────────── */

/* กล่องแจ้งเตือน — ยังไม่ถึงขั้นต่ำ */
.wctp-moq-block {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    margin: 0 0 20px;
    background: #fff8e1;
    border: 2px solid #f59e0b;
    border-radius: 6px;
    box-sizing: border-box;
}

.wctp-moq-block__icon {
    font-size: 1.6em;
    line-height: 1;
    flex-shrink: 0;
}

.wctp-moq-block__body {
    flex: 1;
}

.wctp-moq-block__title {
    margin: 0 0 4px;
    font-weight: 700;
    color: #92400e;
}

.wctp-moq-block__detail {
    margin: 0 0 10px;
    color: #78350f;
}

/* Progress bar */
.wctp-moq-bar__wrap {
    height: 8px;
    background: #fde68a;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 10px;
}

.wctp-moq-bar__fill {
    height: 100%;
    background: #f59e0b;
    border-radius: 99px;
    transition: width 0.4s ease;
    min-width: 4px;
}

.wctp-moq-block__need {
    margin: 0;
    color: #92400e;
}

.wctp-moq-need-amt {
    color: #b45309;
    font-size: 1.05em;
}

/* กล่องยืนยัน — ผ่าน MOQ แล้ว */
.wctp-moq-ok {
    padding: 10px 14px;
    margin: 0 0 16px;
    background: #f0fdf4;
    border-left: 4px solid #3a9900;
    border-radius: 0 4px 4px 0;
    color: #14532d;
    box-sizing: border-box;
}

/* ── Loading state ระหว่าง WC AJAX refresh ──────────────────────────────── */

/* Wrapper ที่ถูก register เป็น WC fragment — transition ให้ดูเนียน */
.wctp-moq-wrap {
    transition: opacity 0.2s ease;
}

/* เมื่อ update_checkout กำลังทำงาน → หรี่แสงเพื่อบอกผู้ใช้ว่ากำลังอัปเดต */
.wctp-moq-updating {
    opacity: 0.45;
    pointer-events: none;
}
