/* ==========================================================================
   Teletubbies Library — tt-smooth.css (v1)
   ชั้นปรับปรุงล่าสุด (ไฟล์ CSS อย่างเดียว ไม่เปลี่ยนโครงสร้าง/Logic เดิม)
   1) ลื่นขึ้น ไม่กระตุก: ปิดเอฟเฟกต์ที่กินเครื่องขณะเลื่อนหน้า (blur ซ้อน, พื้นหลัง fixed, แอนิเมชันวนไม่รู้จบ)
   2) โลโก้กลมตรง ไม่เบี้ยว ทุกขนาดหน้าจอ
   3) ปุ่มจัดการ ดู / แก้ไข / ลบ = สีทึบ ไอคอนขาวชัด
   4) ตารางทุกหน้า → การ์ดบนมือถือ (คู่กับ assets/js/tt-cards.js)
   ใช้ตัวเลือก :not(#_sN) หลายชั้นเพื่อให้มีผลเหนือสไตล์เดิมโดยไม่ต้องแก้ไฟล์อื่น
   ลบบรรทัด <link ... tt-smooth.css> ออกเพื่อกลับเป็นแบบเดิม
   ========================================================================== */

/* ---------- 1) ความลื่น ---------- */
/* พื้นหลังแบบ fixed ทำให้ต้องวาดหน้าใหม่ทุกครั้งที่เลื่อน → ใช้ scroll แทน */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6),
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) * {
    background-attachment: scroll !important;
}
/* blur ซ้อนกันหลายชั้น (การ์ดกระจก) เป็นต้นเหตุหลักของอาการกระตุกตอนเลื่อน */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .portal, .sidebar-left) *,
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.sidebar-left, .global-topbar, .opx-nav, .opx-search, .opx-hero .opx-search) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
/* แถบด้านบนที่เคยโปร่ง + blur → ทึบขึ้นเล็กน้อยแทน (ข้อความด้านหลังไม่ทะลุ) */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full > .global-topbar,
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .global-topbar {
    background-color: rgba(255, 255, 255, .97) !important;
    background-image: none !important;
}
html body.opx:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .opx-nav {
    background: rgba(255, 255, 255, .97) !important;
}
/* แถวตารางไม่ต้องขยับขึ้นลงเวลาชี้ (ทำให้ทั้งตารางวาดใหม่) */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full tbody tr,
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full tbody tr:hover {
    transform: none !important;
}
/* แอนิเมชันวนไม่รู้จบของโลโก้ */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left .sidebar-logo,
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left > .text-center::after {
    animation: none !important;
    translate: none !important;
}
/* รูปภาพ: จองพื้นที่ไว้ก่อน ไม่ให้เนื้อหากระโดด/ซ้อนกันตอนภาพโหลด */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full img { max-width: 100%; }
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full .book-cover-thumb { aspect-ratio: 3 / 4; height: auto; }
/* เนื้อหาไม่ล้นจอด้านข้าง */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full { min-width: 0 !important; overflow-x: clip; }

/* ---------- 2) โลโก้กลมตรง ไม่เบี้ยว ---------- */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left > .text-center {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left .sidebar-logo {
    flex: 0 0 auto !important;
    width: 128px !important;
    height: 128px !important;
    min-width: 128px !important;
    max-width: 128px !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 auto !important;
    padding: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    transform: none !important;
    transform-style: flat !important;
    rotate: none !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left .sidebar-logo:hover {
    transform: translateY(-2px) !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.global-brand-logo, .opx-logo img) {
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    transform: none !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .opx-logo {
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden !important;
}
@media (max-width: 992px) {
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left .sidebar-logo {
        width: 96px !important; height: 96px !important; min-width: 96px !important; max-width: 96px !important;
    }
}
@media (max-width: 768px) {
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .sidebar-left .sidebar-logo {
        width: 76px !important; height: 76px !important; min-width: 76px !important; max-width: 76px !important;
    }
}

/* ---------- 3) ปุ่มจัดการ ดู / แก้ไข / ลบ = สีทึบ ไอคอนชัด ---------- */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(
    .tt-icon-btn.view, .tt-icon-btn.edit, .tt-icon-btn.delete,
    .um-action.um-edit, .um-action.um-delete,
    .resv-smallbtn.resv-edit, .resv-smallbtn.resv-delete,
    .inventory-action-btn, .be-act.edit, .be-act.del, .bd-ico-btn[title="แก้ไข"],
    .table-book-list a.btn[title="ดูรายละเอียด"], .table-book-list a.btn[title="แก้ไข"], .table-book-list a.btn[title="ลบ"]
) {
    --sb: #475569; --sd: #1e293b;
    width: 38px !important; height: 38px !important; min-width: 38px !important; min-height: 38px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    border: 0 !important;
    background-color: var(--sb) !important;
    background-image: none !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    opacity: 1 !important;
    text-shadow: none !important;
    filter: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 3px 0 var(--sd), 0 8px 14px -8px var(--sd) !important;
    transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(
    .tt-icon-btn.view, .tt-icon-btn.edit, .tt-icon-btn.delete,
    .um-action.um-edit, .um-action.um-delete,
    .resv-smallbtn.resv-edit, .resv-smallbtn.resv-delete,
    .inventory-action-btn, .be-act.edit, .be-act.del, .bd-ico-btn[title="แก้ไข"],
    .table-book-list a.btn[title="ดูรายละเอียด"], .table-book-list a.btn[title="แก้ไข"], .table-book-list a.btn[title="ลบ"]
) :is(i, svg) {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    fill: currentColor;
    font-size: 17px !important;
    opacity: 1 !important;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)) !important;
    transform: none !important;
}
/* ดู = เขียว */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(.tt-icon-btn.view, .table-book-list a.btn[title="ดูรายละเอียด"], .inventory-action-btn[title^="ดู"]) {
    --sb: #16a34a; --sd: #14532d;
}
/* แก้ไข = น้ำเงิน */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(.tt-icon-btn.edit, .um-action.um-edit, .resv-smallbtn.resv-edit, .be-act.edit, .bd-ico-btn[title="แก้ไข"], .table-book-list a.btn[title="แก้ไข"], .inventory-action-btn[title^="แก้"]) {
    --sb: #2563eb; --sd: #1e3a8a;
}
/* ลบ = แดง */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(.tt-icon-btn.delete, .um-action.um-delete, .resv-smallbtn.resv-delete, .inventory-action-btn.danger, .be-act.del, .table-book-list a.btn[title="ลบ"]) {
    --sb: #dc2626; --sd: #7f1d1d;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(
    .tt-icon-btn.view, .tt-icon-btn.edit, .tt-icon-btn.delete,
    .um-action.um-edit, .um-action.um-delete,
    .resv-smallbtn.resv-edit, .resv-smallbtn.resv-delete,
    .inventory-action-btn, .be-act.edit, .be-act.del, .bd-ico-btn[title="แก้ไข"],
    .table-book-list a.btn[title="ดูรายละเอียด"], .table-book-list a.btn[title="แก้ไข"], .table-book-list a.btn[title="ลบ"]
):hover {
    background-color: var(--sd) !important;
    background-image: none !important;
    color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 0 var(--sd), 0 12px 18px -8px var(--sd) !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) :is(.main-content-full, .mn-page, .portal) :is(
    .tt-icon-btn.view, .tt-icon-btn.edit, .tt-icon-btn.delete,
    .um-action.um-edit, .um-action.um-delete,
    .resv-smallbtn.resv-edit, .resv-smallbtn.resv-delete,
    .inventory-action-btn, .be-act.edit, .be-act.del, .bd-ico-btn[title="แก้ไข"],
    .table-book-list a.btn[title="ดูรายละเอียด"], .table-book-list a.btn[title="แก้ไข"], .table-book-list a.btn[title="ลบ"]
):active {
    transform: translateY(2px) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3) !important;
}

/* ---------- 4) ตาราง → การ์ดบนมือถือ (แบบเดียวกับหน้าจัดการสมาชิก) ---------- */
@media (max-width: 768px) {
    /* กล่องที่หุ้มตาราง: ไม่ต้องเลื่อนแนวนอนแล้ว */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full :is(div, section):has(> table.ttm-cards) {
        overflow-x: visible !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        border: 0 !important;
        border-spacing: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        table-layout: auto !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > thead { display: none !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody { display: block !important; width: 100% !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr:not([style*="display: none"]):not([style*="display:none"]):not([hidden]):not(.d-none):not(.hidden) {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 4px 10px !important;
        width: 100% !important;
        margin: 0 0 12px !important;
        padding: 12px 14px !important;
        background: #fff !important;
        border: 1px solid var(--tt-line, #eee2d6) !important;
        border-radius: 18px !important;
        box-shadow: 0 3px 0 color-mix(in srgb, var(--tt-p, #f97316) 10%, #efe5db), 0 12px 22px -18px rgba(16, 24, 40, .45) !important;
        transform: none !important;
        height: auto !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td {
        order: 10;
        display: block !important;
        flex: 1 1 100% !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 8px 2px !important;
        border: 0 !important;
        border-top: 1px solid var(--tt-line, #eee2d6) !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        text-align: left !important;
        vertical-align: top !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        font-size: 13.5px !important;
        line-height: 1.55 !important;
        position: static !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td * { max-width: 100%; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards,
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody,
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr,
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td { box-sizing: border-box !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td[data-label]::before {
        content: attr(data-label) " : ";
        color: var(--tt-muted, #8a7466);
        font-size: 12.5px;
        font-weight: 500;
        white-space: nowrap;
    }
    /* ลำดับ (#) ไม่ต้องแสดงบนการ์ด */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-idx { display: none !important; }
    /* แถวหัวการ์ด: เลือก / ปก / ชื่อ / สถานะ */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td:is(.ttm-check, .ttm-media, .ttm-head, .ttm-status) {
        border-top: 0 !important;
        padding: 0 !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td:is(.ttm-check, .ttm-media, .ttm-head, .ttm-status, .ttm-act)::before { content: none !important; display: none !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-check { order: 1; flex: 0 0 auto !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-media { order: 2; flex: 0 0 auto !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-media :is(.books-cover-cell) { display: flex !important; align-items: center !important; gap: 10px !important; }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-media :is(img, .book-cover-thumb, .rv-cover) {
        width: 52px !important; height: 70px !important; min-width: 52px !important; object-fit: cover !important; border-radius: 8px !important; margin: 0 !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-head {
        order: 3;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        font-size: 15px !important;
        font-weight: 700 !important;
        color: var(--tt-heading, #3b2414) !important;
        padding-bottom: 6px !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-status {
        order: 4;
        flex: 0 1 auto !important;
        max-width: 55% !important;
        text-align: right !important;
        align-self: flex-start !important;
        padding-bottom: 6px !important;
    }
    /* ปุ่มจัดการ: ชิดขวาด้านล่างการ์ด */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-act {
        order: 20;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 8px !important;
        padding-top: 10px !important;
        border-top: 1px dashed var(--tt-line-2, #e3d3c3) !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr > td.ttm-act > :is(div, form) {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 8px !important;
        min-width: 0 !important;
        width: auto !important;
        margin: 0 !important;
    }
    /* แถวว่าง / "ไม่พบข้อมูล" */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr.ttm-empty:not([style*="display: none"]):not([style*="display:none"]) {
        display: block !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr.ttm-empty > td {
        border: 0 !important; text-align: center !important; padding: 18px 6px !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full table.ttm-cards > tbody > tr.ttm-empty > td::before { content: none !important; }

    /* หัวกล่อง (ชื่อรายการ + ป้ายจำนวน) ไม่ล้นขอบจอ */
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full :is(section, .card, [class*="-card"], [class*="-wrap"]) {
        min-width: 0 !important;
        max-width: 100% !important;
    }
    html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full :is([class$="-head"], [class*="-head "], .borrow-head, .borrow-fines-head, .resv-head, .um-head, .al-head) {
        flex-wrap: wrap !important;
        gap: 8px !important;
        min-width: 0 !important;
    }
}

/* ---------- 5) สถานะการคืน: คืนแล้ว = เขียว / คืนชำรุด = แดง / คืน (สูญหาย) = ส้ม ---------- */
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full .borrow-status:is(.returned, .damaged, .lost) {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 5px 13px !important;
    border-radius: 999px !important;
    border: 0 !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .25) !important;
    background-image: none !important;
    white-space: nowrap !important;
}
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full .borrow-status.returned { background-color: #16a34a !important; box-shadow: 0 2px 0 #14532d !important; }
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full .borrow-status.damaged { background-color: #dc2626 !important; box-shadow: 0 2px 0 #7f1d1d !important; }
html body:not(#_s1):not(#_s2):not(#_s3):not(#_s4):not(#_s5):not(#_s6) .main-content-full .borrow-status.lost { background-color: #ea580c !important; box-shadow: 0 2px 0 #9a3412 !important; }
