/*
 * ปุ่มรีเฟรช/ล้างการค้นหา (ปุ่มที่มีแค่ไอคอน fa-undo อย่างเดียว) ใช้ทั้งระบบ
 * ปุ่มนี้เขียนแยกในหลายหน้า (ไม่มี component กลาง) จึงจับด้วย :has() จากไฟล์นี้ไฟล์เดียว
 * - ปุ่มที่มีข้อความด้วย (เช่น "↺ คืน", "↺ กลับที่เดิม") ไม่โดน เพราะไอคอนไม่ใช่ลูกตัวเดียว
 * - เบราว์เซอร์ที่ไม่รองรับ :has() จะเห็นปุ่มแบบเดิม (ไม่พัง)
 * หมุนไอคอนตอนกด: สคริปต์เล็กใน layout/partials/head.blade.php ใส่คลาส is-refresh-spinning
 */
.btn:has(> i.fa-undo:only-child) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0 10px;
    border: 1.5px solid #ff9f43 !important;
    border-radius: 12px !important;
    background-color: #ff9f43 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(255, 159, 67, 0.35) !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:has(> i.fa-undo:only-child):hover,
.btn:has(> i.fa-undo:only-child):focus {
    background-color: #f58f2e !important;
    border-color: #f58f2e !important;
    color: #ffffff !important;
}

.btn:has(> i.fa-undo:only-child):active {
    background-color: #e8862a !important;
    border-color: #e8862a !important;
}

.btn:has(> i.fa-undo:only-child):focus-visible {
    outline: 3px solid rgba(255, 159, 67, 0.35);
    outline-offset: 2px;
}

.btn:has(> i.fa-undo:only-child):disabled,
.btn:has(> i.fa-undo:only-child).disabled {
    opacity: 0.5;
}

/* เปลี่ยนไอคอนเป็นลูกศรวงกลม (fa-sync-alt) */
.btn:has(> i.fa-undo:only-child) > i.fa-undo {
    font-size: 16px;
    line-height: 1;
}

.btn:has(> i.fa-undo:only-child) > i.fa-undo::before {
    content: "\f2f1";
}

/* กดแล้วหมุน 1 รอบ */
.btn > i.fa-undo.is-refresh-spinning {
    animation: refresh-button-spin 0.6s ease-in-out;
}

@keyframes refresh-button-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn > i.fa-undo.is-refresh-spinning {
        animation: none;
    }
}
